/// <summary> /// 消息类型分发器 /// </summary> /// <param name="element">消息实体</param> /// <returns></returns> private RequestMessage GetRequestMessageByElement(XElement element) { Dictionary <string, object> bugobj = new Dictionary <string, object>(); RequestMessage requestMessage = null; try { bugobj.Add("element", element); bugobj.Add("MsgType", element.Element("MsgType").Value); MsgType msgType = (MsgType)Enum.Parse(typeof(MsgType), element.Element("MsgType").Value, true); switch (msgType) { case MsgType.Text: requestMessage = new RequestTextMessage(element); break; case MsgType.Video: // requestMessage = new RequestVoiceMessage(element); break; case MsgType.Voice: requestMessage = new RequestVoiceMessage(element); break; case MsgType.Image: // return new RequestImageMessage(element); break; case MsgType.Link: // return new RequestLinkMessage(element); break; case MsgType.Location: // return new RequestLocationMessage(element); break; case MsgType.Event: requestMessage = GetEventRequestMessage(element); break; //default: // throw new ArgumentException("msgType is error"); } } catch (Exception ex) { this.Log(ex); } finally { TxtLogHelper.WriteDebugLog(bugobj); } return(requestMessage); }
/// <summary> /// 消息类型分发器 /// </summary> /// <param name="element">消息实体</param> /// <returns></returns> private RequestMessage GetRequestMessageByElement(XElement element) { Dictionary<string, object> bugobj = new Dictionary<string, object>(); RequestMessage requestMessage = null; try { bugobj.Add("element", element); bugobj.Add("MsgType", element.Element("MsgType").Value); MsgType msgType = (MsgType)Enum.Parse(typeof(MsgType), element.Element("MsgType").Value, true); switch (msgType) { case MsgType.Text: requestMessage = new RequestTextMessage(element); break; case MsgType.Video: // requestMessage = new RequestVoiceMessage(element); break; case MsgType.Voice: requestMessage = new RequestVoiceMessage(element); break; case MsgType.Image: // return new RequestImageMessage(element); break; case MsgType.Link: // return new RequestLinkMessage(element); break; case MsgType.Location: // return new RequestLocationMessage(element); break; case MsgType.Event: requestMessage = GetEventRequestMessage(element); break; //default: // throw new ArgumentException("msgType is error"); } } catch (Exception ex) { this.Log(ex); } finally { TxtLogHelper.WriteDebugLog(bugobj); } return requestMessage; }