Beispiel #1
0
        /// <summary>
        ///  发送指定格式消息,根据请求消息openID
        /// </summary>
        /// <param name="request"></param>
        /// <param name="msgType"></param>
        /// <returns></returns>
        public static IResponseMessageBase GetResponseEntityFromRequest(IRequestMessageBase request, ResponseMsgType msgType)
        {
            ResponseMessageBase responseMessage = null;

            try
            {
                switch (msgType)
                {
                case ResponseMsgType.Text:
                    responseMessage = new ResponseMessageText();
                    break;

                case ResponseMsgType.Image:
                    responseMessage = new ResponseMessageImage();
                    break;

                case ResponseMsgType.Voice:
                    responseMessage = new ResponseMessageVoice();
                    break;

                case ResponseMsgType.Video:
                    responseMessage = new ResponseMessageVideo();
                    break;

                case ResponseMsgType.Music:
                    responseMessage = new ResponseMessageMusic();
                    break;

                case ResponseMsgType.News:
                    responseMessage = new ResponseMessageNews();
                    break;

                default:
                    Log.Debug("CreateResponseEntity", "找不到相应的msgType");
                    break;
                }
                responseMessage.ToUserName   = request.FromUserName;
                responseMessage.FromUserName = request.ToUserName;
                responseMessage.CreateTime   = DateTime.Now;
            }
            catch (Exception e)
            {
            }

            return(responseMessage);
        }
Beispiel #2
0
        /// <summary>
        /// 发送指定格式消息
        /// </summary>
        /// <param name="msgType"></param>
        /// <returns></returns>
        public static IResponseMessageBase CreateResponseEntity(ResponseMsgType msgType)
        {
            ResponseMessageBase responseMessage = null;

            try
            {
                //var msgType = MsgHelper.GetResponseMsgType(doc);
                switch (msgType)
                {
                case ResponseMsgType.Text:
                    responseMessage = new ResponseMessageText();
                    break;

                case ResponseMsgType.Image:
                    responseMessage = new ResponseMessageImage();
                    break;

                case ResponseMsgType.Voice:
                    responseMessage = new ResponseMessageVoice();
                    break;

                case ResponseMsgType.Video:
                    responseMessage = new ResponseMessageVideo();
                    break;

                case ResponseMsgType.Music:
                    responseMessage = new ResponseMessageMusic();
                    break;

                case ResponseMsgType.News:
                    responseMessage = new ResponseMessageNews();
                    break;

                default:
                    Log.Debug("CreateResponseEntity", "找不到相应的msgType");
                    break;
                }
            }
            catch (Exception e)
            {
            }

            return(responseMessage);
        }