/// <summary>
        /// 处理请求消息
        /// </summary>
        /// <returns>处理结果</returns>
        public ResponseMessage HandlerRequestMessage()
        {
            Dictionary<string, object> bugobj = new Dictionary<string, object>();
            ResponseTextMessage responseTextMessage = null;
            var request = new RequestQREventMessage(this.message.Element);
            try
            {
                if (request != null)
                {
                    // 处理扫描带参数的二维码消息处理器
                    //  bugobj.Add("处理扫描带参数的二维码消息处理器", request);
                }
                responseTextMessage = new ResponseTextMessage(request)
                {
                    Content = subScribeMsg,
                };
            }
            catch (Exception ex)
            {
                TxtLogHelper.WriteLog_Day(new TxtLogInfoObject()
                {
                    LogType = EnumLogType.Error,
                    LogMessage = string.Format("错误信息{0};堆栈信息{1}", ex.Message, ex.StackTrace),
                });
            }
            finally
            {
                TxtLogHelper.WriteDebugLog(bugobj);
            }

            return responseTextMessage;
        }
Example #2
0
        /// <summary>
        /// 事件消息解析器
        /// </summary>
        /// <param name="element">消息实体</param>
        /// <returns></returns>
        private RequestMessage GetEventRequestMessage(XElement element)
        {
            Dictionary<string, object> bugobj = new Dictionary<string, object>();
            RequestMessage requestMessage = null;
            try
            {
                if (element == null)
                {
                    return null;
                }
                var eventType = (Event)Enum.Parse(typeof(Event), element.Element("Event").Value, true);
                bugobj.Add("eventType", eventType);
                bugobj.Add("element", element);
                switch (eventType)
                {
                    case Event.Unsubscribe:
                        return new RequestEventMessage(element);
                    case Event.Location:
                        //  return new RequestLocationEventMessage(element);
                        break;
                    case Event.Click:
                        requestMessage = new RequestClickEventMessage(element);
                        break;
                    case Event.Scan:
                        requestMessage = new RequestQREventMessage(element);
                        break;
                    case Event.Subscribe:
                        requestMessage = GetSubscribeRequestMessageForQR(element);
                        break;
                    case Event.View:
                        requestMessage = new RequestViewEventMessage(element);
                        break;
                    //default:
                    //    throw new ArgumentException("event type is error");
                }
            }
            catch (Exception ex)
            {
                this.Log(ex);
            }
            finally
            {
                TxtLogHelper.WriteDebugLog(bugobj);
                TxtLogHelper.WriteLog_Hour(new TxtLogInfoObject()
                {
                    LogMessage = "消息实体",
                    LogObject = requestMessage,
                    LogType = EnumLogType.Other
                });
            }

            return requestMessage;
        }