Ejemplo n.º 1
0
 public static string GetName(this Enums.ResponseType response)
 {
     return(Enum.GetName(typeof(Enums.ResponseType), response));
 }
Ejemplo n.º 2
0
        public static IResponseMessage CreateFromRequestMessage(IRequestMessage requestMessage, Enums.ResponseType msgType)
        {
            IResponseMessage responseMessage = null;

            switch (msgType)
            {
            case Enums.ResponseType.Text:
                responseMessage = new ResponseMessage
                {
                };
                break;

            case Enums.ResponseType.News:
                responseMessage = new ResponseMessage
                {
                    Articles = new List <ResponseMessageInnerType.Article>()
                };
                break;

            case Enums.ResponseType.Image:
                responseMessage = new ResponseMessage
                {
                    Image = new ResponseMessageInnerType.Media()
                };
                break;

            case Enums.ResponseType.Voice:
                responseMessage = new ResponseMessage
                {
                    Voice = new ResponseMessageInnerType.Media()
                };
                break;

            case Enums.ResponseType.Video:
                responseMessage = new ResponseMessage
                {
                    Video = new ResponseMessageInnerType.Video()
                };
                break;
            }
            if (responseMessage != null)
            {
                responseMessage.MsgType      = msgType.ToString().ToLower();
                responseMessage.ToUserName   = requestMessage.FromUserName;
                responseMessage.FromUserName = requestMessage.ToUserName;
                responseMessage.CreateTime   = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds).ToString(); //使用当前最新时间
            }
            return(responseMessage);
        }