示例#1
0
        /// <summary>
        /// 获取请求消息和实体之间的映射结果
        /// </summary>
        /// <param name="requestMsgType"></param>
        /// <returns></returns>
        public override IRequestMessageBase GetRequestEntityMappingResult(RequestMsgType requestMsgType, XDocument doc = null)
        {
            RequestMessageBase requestMessage;

            switch (requestMsgType)
            {
            case RequestMsgType.Text:
                requestMessage = new RequestMessageText();
                break;

            case RequestMsgType.Image:
                requestMessage = new RequestMessageImage();
                break;

            case RequestMsgType.MiniProgramPage:    //小程序页面
                requestMessage = new RequestMessageMiniProgramPage();
                break;

            case RequestMsgType.NeuChar:
                requestMessage = new RequestMessageNeuChar();
                break;

            case RequestMsgType.Event:
                //判断Event类型
                switch (doc.Root.Element("Event").Value.ToUpper())
                {
                case "USER_ENTER_TEMPSESSION":        //进入客服会话
                    requestMessage = new RequestMessageEvent_UserEnterTempSession();
                    break;

                case "WEAPP_AUDIT_SUCCESS":         //小程序审核成功
                    requestMessage = new RequestMessageEvent_WeAppAuditSuccess();
                    break;

                case "WEAPP_AUDIT_FAIL":         //小程序审核失败
                    requestMessage = new RequestMessageEvent_WeAppAuditFail();
                    break;

                case "WEAPP_AUDIT_DELAY":         //小程序审核延后
                    requestMessage = new RequestMessageEvent_WeAppAuditDelay();
                    break;

                case "WXA_NICKNAME_AUDIT":         //名称审核结果
                    requestMessage = new RequestMessageEvent_NicknameAudit();
                    break;

                default:        //其他意外类型(也可以选择抛出异常)
                    requestMessage = new RequestMessageEventBase();
                    break;
                }
                break;

            default:
                throw new UnknownRequestMsgTypeException(string.Format("MsgType:{0} 在RequestMessageFactory中没有对应的处理程序!", requestMsgType), new ArgumentOutOfRangeException());    //为了能够对类型变动最大程度容错(如微信目前还可以对公众账号suscribe等未知类型,但API没有开放),建议在使用的时候catch这个异常
            }
            return(requestMessage);
        }
示例#2
0
 /// <summary>
 /// 小程序审核延后通知
 /// </summary>
 /// <param name="requestMessage"></param>
 /// <returns></returns>
 public virtual async Task <IResponseMessageBase> OnEvent_WeAppAuditDelayRequestAsync(RequestMessageEvent_WeAppAuditDelay requestMessage)
 {
     return(DefaultResponseMessage(requestMessage));
 }
示例#3
0
 /// <summary>
 /// 小程序审核延后通知
 /// </summary>
 /// <param name="requestMessage"></param>
 /// <returns></returns>
 public virtual IResponseMessageBase OnEvent_WeAppAuditDelayRequest(RequestMessageEvent_WeAppAuditDelay requestMessage)
 {
     return(DefaultResponseMessage(requestMessage));
 }
示例#4
0
 /// <summary>
 /// 小程序审核延后通知
 /// </summary>
 /// <param name="requestMessage"></param>
 /// <returns></returns>
 public virtual async Task <IResponseMessageBase> OnEvent_WeAppAuditDelayRequestAsync(RequestMessageEvent_WeAppAuditDelay requestMessage)
 {
     return(await DefaultAsyncMethod(requestMessage, () => OnEvent_WeAppAuditDelayRequest(requestMessage)).ConfigureAwait(false));
 }