public static AbstractRequest GetRequestEntity(XDocument doc) { RequestMsgType msgType = MsgTypeHelper.GetMsgType(doc); AbstractRequest entity = null; switch (msgType) { case RequestMsgType.Text: entity = new TextRequest(); break; case RequestMsgType.Image: entity = new ImageRequest(); break; case RequestMsgType.Voice: entity = new VoiceRequest(); break; case RequestMsgType.Video: entity = new VideoRequest(); break; case RequestMsgType.Location: entity = new LocationRequest(); break; case RequestMsgType.Link: entity = new LinkRequest(); break; case RequestMsgType.Event: switch (EventTypeHelper.GetEventType(doc)) { case RequestEventType.Subscribe: entity = new SubscribeEventRequest(); goto Label_00D7; case RequestEventType.UnSubscribe: entity = new UnSubscribeEventRequest(); goto Label_00D7; case RequestEventType.Scan: entity = new ScanEventRequest(); goto Label_00D7; case RequestEventType.Location: entity = new LocationEventRequest(); goto Label_00D7; case RequestEventType.Click: entity = new ClickEventRequest(); goto Label_00D7; case RequestEventType.MASSSENDJOBFINISH: entity = new MassendJobFinishEventRequest(); goto Label_00D7; } throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException(); } Label_00D7: EntityHelper.FillEntityWithXml <AbstractRequest>(entity, doc); Regex regex = new Regex(@"<MsgID>(?<url>\d+)</MsgID>"); if (entity.MsgId == 0L) { Match match = Regex.Match(doc.Root.ToString(), @"<MsgID>(?<msgid>\d+)</MsgID>", RegexOptions.IgnoreCase); if (match.Success) { entity.MsgId = long.Parse(match.Groups["msgid"].Value); entity.CreateTime = DateTime.Now; } } return(entity); }
public static AbstractRequest GetRequestEntity(XDocument doc) { RequestMsgType msgType = MsgTypeHelper.GetMsgType(doc); AbstractRequest textRequest = null; switch (msgType) { case RequestMsgType.Text: { textRequest = new TextRequest(); break; } case RequestMsgType.Image: { textRequest = new ImageRequest(); break; } case RequestMsgType.Voice: { textRequest = new VoiceRequest(); break; } case RequestMsgType.Video: { textRequest = new VideoRequest(); break; } case RequestMsgType.Location: { textRequest = new LocationRequest(); break; } case RequestMsgType.Link: { textRequest = new LinkRequest(); break; } case RequestMsgType.Event: { switch (EventTypeHelper.GetEventType(doc)) { case RequestEventType.Subscribe: { textRequest = new SubscribeEventRequest(); break; } case RequestEventType.UnSubscribe: { textRequest = new UnSubscribeEventRequest(); break; } case RequestEventType.Scan: { textRequest = new ScanEventRequest(); break; } case RequestEventType.Location: { textRequest = new LocationEventRequest(); break; } case RequestEventType.Click: { textRequest = new ClickEventRequest(); break; } default: { throw new ArgumentOutOfRangeException(); } } break; } default: { throw new ArgumentOutOfRangeException(); } } EntityHelper.FillEntityWithXml <AbstractRequest>(textRequest, doc); return(textRequest); throw new ArgumentOutOfRangeException(); }
public static AbstractRequest GetRequestEntity(XDocument doc) { RequestMsgType msgType = MsgTypeHelper.GetMsgType(doc); AbstractRequest entity = null; switch (msgType) { case RequestMsgType.Text: entity = new TextRequest(); break; case RequestMsgType.Image: entity = new ImageRequest(); break; case RequestMsgType.Voice: entity = new VoiceRequest(); break; case RequestMsgType.Video: entity = new VideoRequest(); break; case RequestMsgType.Location: entity = new LocationRequest(); break; case RequestMsgType.Link: entity = new LinkRequest(); break; case RequestMsgType.Event: switch (EventTypeHelper.GetEventType(doc)) { case RequestEventType.Subscribe: entity = new SubscribeEventRequest(); goto Label_00C5; case RequestEventType.UnSubscribe: entity = new UnSubscribeEventRequest(); goto Label_00C5; case RequestEventType.Scan: entity = new ScanEventRequest(); goto Label_00C5; case RequestEventType.Location: entity = new LocationEventRequest(); goto Label_00C5; case RequestEventType.Click: entity = new ClickEventRequest(); goto Label_00C5; } throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException(); } Label_00C5: EntityHelper.FillEntityWithXml <AbstractRequest>(entity, doc); return(entity); }
public static AbstractRequest GetRequestEntity(XDocument doc) { RequestMsgType msgType = MsgTypeHelper.GetMsgType(doc); AbstractRequest entity = null; // System.IO.File.AppendAllText(@"E:\home\LocalUser\580442\www\humowang\api\type.txt", "msgType:" + msgType + "\r\n"); switch (msgType) { case RequestMsgType.Text: { entity = new TextRequest(); break; } case RequestMsgType.Image: { entity = new ImageRequest(); break; } case RequestMsgType.Voice: { entity = new VoiceRequest(); break; } case RequestMsgType.Video: { entity = new VideoRequest(); break; } case RequestMsgType.Location: { entity = new LocationRequest(); break; } case RequestMsgType.Link: { entity = new LinkRequest(); break; } case RequestMsgType.Event: { switch (EventTypeHelper.GetEventType(doc)) { case RequestEventType.Subscribe: { entity = new SubscribeEventRequest(); //goto Label_00C5; break; } case RequestEventType.UnSubscribe: { entity = new UnSubscribeEventRequest(); //goto Label_00C5; break; } case RequestEventType.Scan: { entity = new ScanEventRequest(); // goto Label_00C5; break; } case RequestEventType.Location: { entity = new LocationEventRequest(); // goto Label_00C5; break; } case RequestEventType.Click: { entity = new ClickEventRequest(); // goto Label_00C5; break; } case RequestEventType.VIEW: { entity = new ViewEventRequest(); break; } default: { throw new ArgumentOutOfRangeException(); // break; } } break; } default: { throw new ArgumentOutOfRangeException(); } } //Label_00C5: EntityHelper.FillEntityWithXml <AbstractRequest>(entity, doc); return(entity); }
public static AbstractRequest GetRequestEntity(XDocument doc) { AbstractRequest abstractRequest; switch (MsgTypeHelper.GetMsgType(doc)) { case RequestMsgType.Text: abstractRequest = new TextRequest(); break; case RequestMsgType.Image: abstractRequest = new ImageRequest(); break; case RequestMsgType.Voice: abstractRequest = new VoiceRequest(); break; case RequestMsgType.Video: abstractRequest = new VideoRequest(); break; case RequestMsgType.Location: abstractRequest = new LocationRequest(); break; case RequestMsgType.Link: abstractRequest = new LinkRequest(); break; case RequestMsgType.Event: switch (EventTypeHelper.GetEventType(doc)) { case RequestEventType.Subscribe: abstractRequest = new SubscribeEventRequest(); break; case RequestEventType.UnSubscribe: abstractRequest = new UnSubscribeEventRequest(); break; case RequestEventType.Scan: abstractRequest = new ScanEventRequest(); break; case RequestEventType.Location: abstractRequest = new LocationEventRequest(); break; case RequestEventType.Click: abstractRequest = new ClickEventRequest(); break; case RequestEventType.MASSSENDJOBFINISH: abstractRequest = new MassendJobFinishEventRequest(); break; default: throw new ArgumentOutOfRangeException(); } break; default: throw new ArgumentOutOfRangeException(); } EntityHelper.FillEntityWithXml <AbstractRequest>(abstractRequest, doc); Regex regex = new Regex("<MsgID>(?<url>\\d+)</MsgID>"); if (abstractRequest.MsgId == 0L) { Match match = Regex.Match(doc.Root.ToString(), "<MsgID>(?<msgid>\\d+)</MsgID>", RegexOptions.IgnoreCase); if (match.Success) { abstractRequest.MsgId = long.Parse(match.Groups["msgid"].Value); abstractRequest.CreateTime = DateTime.Now; } } return(abstractRequest); }
public static AbstractRequest GetRequestEntity(XDocument doc) { RequestMsgType msgType = MsgTypeHelper.GetMsgType(doc); AbstractRequest entity = null; switch (msgType) { case RequestMsgType.Text: entity = new TextRequest(); break; case RequestMsgType.Image: entity = new ImageRequest(); break; case RequestMsgType.Voice: entity = new VoiceRequest(); break; case RequestMsgType.Video: entity = new VideoRequest(); break; case RequestMsgType.Location: entity = new LocationRequest(); break; case RequestMsgType.Link: entity = new LinkRequest(); break; case RequestMsgType.Event: //switch (EventTypeHelper.GetEventType(doc)) switch (doc.Root.Element("Event").Value.ToUpper()) { //case RequestEventType.Subscribe: case "SUBSCRIBE"://订阅(关注) entity = new SubscribeEventRequest(); goto Label_00D1; //case RequestEventType.UnSubscribe: case "UNSUBSCRIBE"://取消订阅(关注) entity = new UnSubscribeEventRequest(); goto Label_00D1; //case RequestEventType.Scan: case "SCAN"://二维码扫描 entity = new ScanEventRequest(); goto Label_00D1; //case RequestEventType.Location: case "LOCATION"://地理位置 entity = new LocationEventRequest(); goto Label_00D1; //case RequestEventType.Click: case "CLICK"://菜单点击 entity = new ClickEventRequest(); goto Label_00D1; //case RequestEventType.MASSSENDJOBFINISH: case "MASSSENDJOBFINISH": entity = new MassendJobFinishEventRequest(); goto Label_00D1; case "VIEW": entity = new ViewEventRequest(); goto Label_00D1; //default://其他意外类型(也可以选择抛出异常) // entity = new AbstractRequest(); // goto Label_00D1; } throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException(); } Label_00D1: //EntityHelper.FillEntityWithXml<AbstractRequest>(entity, doc); //修改无法解析完整数据 2017.7.4 EntityHelper.FillEntityWithXml(entity, doc); new Regex(@"<MsgID>(?<url>\d+)</MsgID>"); if (entity.MsgId == 0L) { Match match = Regex.Match(doc.Root.ToString(), @"<MsgID>(?<msgid>\d+)</MsgID>", RegexOptions.IgnoreCase); if (match.Success) { entity.MsgId = long.Parse(match.Groups["msgid"].Value); entity.CreateTime = DateTime.Now; } } return entity; }