Example #1
0
 public override AbstractResponse OnTextRequest(TextRequest textRequest)
 {
     AbstractResponse keyResponse = this.GetKeyResponse(textRequest.Content, textRequest);
     if (keyResponse != null)
     {
         return keyResponse;
     }
     IList<ReplyInfo> replies = ReplyHelper.GetReplies(ReplyType.Keys);
     if ((replies == null) || ((replies.Count == 0) && this.IsOpenManyService()))
     {
         this.GotoManyCustomerService(textRequest);
     }
     foreach (ReplyInfo info in replies)
     {
         if ((info.MatchType == MatchType.Equal) && (info.Keys == textRequest.Content))
         {
             AbstractResponse response = this.GetResponse(info, textRequest.FromUserName);
             response.ToUserName = textRequest.FromUserName;
             response.FromUserName = textRequest.ToUserName;
             return response;
         }
         if ((info.MatchType == MatchType.Like) && info.Keys.Contains(textRequest.Content))
         {
             AbstractResponse response3 = this.GetResponse(info, textRequest.FromUserName);
             response3.ToUserName = textRequest.FromUserName;
             response3.FromUserName = textRequest.ToUserName;
             return response3;
         }
     }
     return this.DefaultResponse(textRequest);
 }
Example #2
0
 public virtual AbstractResponse OnTextRequest(TextRequest textRequest)
 {
     return this.DefaultResponse(textRequest);
 }
        public static AbstractRequest GetRequestEntity(XDocument doc)
        {
            RequestMsgType msgType = MsgTypeHelper.GetMsgType(doc);
            AbstractRequest entity = null;
            switch (msgType)
            {
                case RequestMsgType.Text:
                    entity = new TextRequest();
                    break;

                case RequestMsgType.Image:
                    entity = new ImageRequest();
                    break;

                case RequestMsgType.Voice:
                    entity = new VoiceRequest();
                    break;

                case RequestMsgType.Video:
                    entity = new VideoRequest();
                    break;

                case RequestMsgType.Location:
                    entity = new LocationRequest();
                    break;

                case RequestMsgType.Link:
                    entity = new LinkRequest();
                    break;

                case RequestMsgType.Event:
                    switch (EventTypeHelper.GetEventType(doc))
                    {
                        case RequestEventType.Subscribe:
                            entity = new SubscribeEventRequest();
                            goto Label_00C5;

                        case RequestEventType.UnSubscribe:
                            entity = new UnSubscribeEventRequest();
                            goto Label_00C5;

                        case RequestEventType.Scan:
                            entity = new ScanEventRequest();
                            goto Label_00C5;

                        case RequestEventType.Location:
                            entity = new LocationEventRequest();
                            goto Label_00C5;

                        case RequestEventType.Click:
                            entity = new ClickEventRequest();
                            goto Label_00C5;
                    }
                    throw new ArgumentOutOfRangeException();

                default:
                    throw new ArgumentOutOfRangeException();
            }
            Label_00C5:
            EntityHelper.FillEntityWithXml<AbstractRequest>(entity, doc);
            return entity;
        }