标签:log version data 系统 openid eof gid mil attribute
注意自己的数据结构
实体类如下:
//[Serializable] // 表示该类可以被序列化 [XmlRoot("xml")] // 设置为XML中的根元素名称 /// <summary> /// 事件推送群发结果 /// </summary> public class ResponseMassSendJobFinish : ResponseReceivingEvent { /// <summary> /// 群发的消息ID /// </summary> public long MsgID { get; set; } /// <summary> /// 群发的结果,为“send success”或“send fail”或“err(num)”。 /// 但send success时,也有可能因用户拒收公众号的消息、系统错误等原因造成少量用户接收失败。 /// err(num)是审核失败的具体原因,可能的情况如下: err(10001), //涉嫌广告 err(20001), /// //涉嫌政治 err(20004), //涉嫌社会 err(20002), /// //涉嫌色情 err(20006), //涉嫌违法犯罪 err(20008), /// //涉嫌欺诈 err(20013), //涉嫌版权 err(22000), /// //涉嫌互推(互相宣传) err(21000), //涉嫌其他 err(30001) /// // 原创校验出现系统错误且用户选择了被判为转载就不群发 err(30002) /// // 原创校验被判定为不能群发 err(30003) // 原创校验被判定为转载文且用户选择了被判为转载就不群发 /// </summary> public string Status { get; set; } /// <summary> /// tag_id下粉丝数;或者openid_list中的粉丝数 /// </summary> public int TotalCount { get; set; } /// <summary> /// 过滤(过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,FilterCount 约等于 SentCount + ErrorCount /// </summary> public long FilterCount { get; set; } /// <summary> /// 发送成功的粉丝数 /// </summary> public long SentCount { get; set; } /// <summary> /// 发送失败的粉丝数 /// </summary> public long ErrorCount { get; set; } [XmlElement("CopyrightCheckResult")] public CopyrightCheckResultData CopyrightCheckResult { get; set; } [XmlElement("ArticleUrlResult")] public ArticleUrlResultData ArticleUrlResult { get; set; } ///// <summary> ///// 整体校验结果 ///// </summary> //public string CheckState { get; set; } ///// <summary> ///// 1-未被判为转载,可以群发,2-被判为转载,可以群发,3-被判为转载,不能群发 ///// </summary> /////public string CheckState { get; set; } ///// <summary> ///// 群发文章的url ///// </summary> //public string ArticleUrl { get; set; } } [XmlType(TypeName = "CopyrightCheckResult")] public class CopyrightCheckResultData { public long Count { get; set; } [XmlElement("ResultList")] /// <summary> /// 各个单图文校验结果 /// </summary> public ResultListData ResultList { get; set; } /// <summary> /// 1-未被判为转载,可以群发,2-被判为转载,可以群发,3-被判为转载,不能群发 /// </summary> public int CheckState { get; set; } } public class ResultListData { [XmlElement("item")]//这里是个重点 public List<Item> item { get; set; } } public class Item { [XmlElement("ArticleIdx")] /// <summary> /// 群发文章的序号,从1开始 /// </summary> public int ArticleIdx { get; set; } [XmlElement("UserDeclareState")] /// <summary> /// 用户声明文章的状态 /// </summary> public int UserDeclareState { get; set; } [XmlElement("AuditState")] /// <summary> /// 系统校验的状态 /// </summary> public int AuditState { get; set; } [XmlElement("OriginalArticleUrl")] /// <summary> /// 相似原创文的url /// </summary> public string OriginalArticleUrl { get; set; } [XmlElement("OriginalArticleType")] /// <summary> /// 相似原创文的类型 /// </summary> public string OriginalArticleType { get; set; } [XmlElement("CanReprint")] /// <summary> /// 是否能转载 /// </summary> public int CanReprint { get; set; } [XmlElement("NeedReplaceContent")] /// <summary> /// 是否需要替换成原创文内容 /// </summary> public long NeedReplaceContent { get; set; } [XmlElement("NeedShowReprintSource")] /// <summary> /// 是否需要注明转载来源 /// </summary> public long NeedShowReprintSource { get; set; } } public class ArticleUrlResultData { public long Count { get; set; } [XmlElement("ResultList")] public ResultListNode ResultList { get; set; } } public class ResultListNode { [XmlElement("item")] public List<ResultListItem> item { get; set; } } public class ResultListItem { [XmlAttribute] /// <summary> /// 群发文章的序号,从1开始 /// </summary> public long ArticleIdx { get; set; } [XmlAttribute] /// <summary> /// 群发文章的url /// </summary> public string ArticleUrl { get; set; } }
xml 数据如下
<xml> <ToUserName><![CDATA[gh_7]]></ToUserName> <FromUserName><![CDATA[oU9K7]]></FromUserName> <CreateTime>1576291902</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[MASSSENDJOBFINISH]]></Event> <MsgID>314748</MsgID> <Status><![CDATA[err(30003)]]></Status> <TotalCount>0</TotalCount> <FilterCount>0</FilterCount> <SentCount>0</SentCount> <ErrorCount>0</ErrorCount> <CopyrightCheckResult> <Count>1</Count> <ResultList> <item>
<!--这种数据结构时 item 应该标记为结点
[XmlElement("item")]
public List<Item> item { get; set; }--> <ArticleIdx>1</ArticleIdx> <UserDeclareState>0</UserDeclareState> <AuditState>2</AuditState> <OriginalArticleUrl><![CDATA[http://mp.weixin.qq.com/s?__biz=MzU5Nzk1MDgwNA==#rd]]></OriginalArticleUrl> <OriginalArticleType>1</OriginalArticleType> <CanReprint>1</CanReprint> <NeedReplaceContent>1</NeedReplaceContent> <NeedShowReprintSource>1</NeedShowReprintSource> </item>
<!-- 这种数据结构时 logger 应该标记为
[XmlArray("item")]
public List<logger> item { get; set; }
<logger type="file" name="Filelogger">
-->
</ResultList> <CheckState>2</CheckState> </CopyrightCheckResult> <ArticleUrlResult> <Count>0</Count> <ResultList></ResultList> </ArticleUrlResult> </xml>
/// <summary> /// 反序列化 /// </summary> /// <param name="type"></param> /// <param name="xml"></param> /// <returns></returns> public static T Deserialize<T>(Stream stream) { XmlSerializer xmldes = new XmlSerializer(typeof(T)); return (T)xmldes.Deserialize(stream); } //使用 FileStream fs = new FileStream(path, FileMode.Open); var data = EntityHelper.Deserialize<ResponseMassSendJobFinish>(fs);
结果如图:
标签:log version data 系统 openid eof gid mil attribute
原文地址:https://www.cnblogs.com/Mr-lin66/p/12040384.html