예제 #1
0
 public AbstractResponse GetResponse(ReplyInfo reply, string openId)
 {
     if (reply.MessageType == MessageType.Text)
     {
         TextReplyInfo info = reply as TextReplyInfo;
         TextResponse response = new TextResponse {
             CreateTime = DateTime.Now,
             Content = info.Text
         };
         if (reply.Keys == "登录")
         {
             string str = string.Format("http://{0}/Vshop/Login.aspx?SessionId={1}", HttpContext.Current.Request.Url.Host, openId);
             response.Content = response.Content.Replace("$login$", string.Format("<a href=\"{0}\">一键登录</a>", str));
         }
         return response;
     }
     NewsResponse response2 = new NewsResponse {
         CreateTime = DateTime.Now,
         Articles = new List<Article>()
     };
     foreach (NewsMsgInfo info2 in (reply as NewsReplyInfo).NewsMsg)
     {
         Article item = new Article {
             Description = info2.Description,
             PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, info2.PicUrl),
             Title = info2.Title,
             Url = string.IsNullOrEmpty(info2.Url) ? string.Format("http://{0}/Vshop/ImageTextDetails.aspx?messageId={1}", HttpContext.Current.Request.Url.Host, info2.Id) : info2.Url
         };
         response2.Articles.Add(item);
     }
     return response2;
 }
예제 #2
0
 private AbstractResponse GetKeyResponse(string key, AbstractRequest request)
 {
     IList<ReplyInfo> replies = ReplyHelper.GetReplies(ReplyType.Topic);
     if ((replies != null) && (replies.Count > 0))
     {
         foreach (ReplyInfo info in replies)
         {
             if (info.Keys == key)
             {
                 TopicInfo topic = VShopHelper.Gettopic(info.ActivityId);
                 if (topic != null)
                 {
                     NewsResponse response = new NewsResponse {
                         CreateTime = DateTime.Now,
                         FromUserName = request.ToUserName,
                         ToUserName = request.FromUserName,
                         Articles = new List<Article>()
                     };
                     Article item = new Article {
                         Description = topic.Title,
                         PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, topic.IconUrl),
                         Title = topic.Title,
                         Url = string.Format("http://{0}/vshop/Topics.aspx?TopicId={1}", HttpContext.Current.Request.Url.Host, topic.TopicId)
                     };
                     response.Articles.Add(item);
                     return response;
                 }
             }
         }
     }
     IList<ReplyInfo> list2 = ReplyHelper.GetReplies(ReplyType.Vote);
     if ((list2 != null) && (list2.Count > 0))
     {
         foreach (ReplyInfo info3 in list2)
         {
             if (info3.Keys == key)
             {
                 VoteInfo voteById = StoreHelper.GetVoteById((long) info3.ActivityId);
                 if ((voteById != null) && voteById.IsBackup)
                 {
                     NewsResponse response2 = new NewsResponse {
                         CreateTime = DateTime.Now,
                         FromUserName = request.ToUserName,
                         ToUserName = request.FromUserName,
                         Articles = new List<Article>()
                     };
                     Article article2 = new Article {
                         Description = voteById.VoteName,
                         PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, voteById.ImageUrl),
                         Title = voteById.VoteName,
                         Url = string.Format("http://{0}/vshop/Vote.aspx?voteId={1}", HttpContext.Current.Request.Url.Host, voteById.VoteId)
                     };
                     response2.Articles.Add(article2);
                     return response2;
                 }
             }
         }
     }
     IList<ReplyInfo> list3 = ReplyHelper.GetReplies(ReplyType.Wheel);
     if ((list3 != null) && (list3.Count > 0))
     {
         foreach (ReplyInfo info5 in list3)
         {
             if (info5.Keys == key)
             {
                 LotteryActivityInfo lotteryActivityInfo = VShopHelper.GetLotteryActivityInfo(info5.ActivityId);
                 if (lotteryActivityInfo != null)
                 {
                     NewsResponse response3 = new NewsResponse {
                         CreateTime = DateTime.Now,
                         FromUserName = request.ToUserName,
                         ToUserName = request.FromUserName,
                         Articles = new List<Article>()
                     };
                     Article article3 = new Article {
                         Description = lotteryActivityInfo.ActivityDesc,
                         PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, lotteryActivityInfo.ActivityPic),
                         Title = lotteryActivityInfo.ActivityName,
                         Url = string.Format("http://{0}/vshop/BigWheel.aspx?activityId={1}", HttpContext.Current.Request.Url.Host, lotteryActivityInfo.ActivityId)
                     };
                     response3.Articles.Add(article3);
                     return response3;
                 }
             }
         }
     }
     IList<ReplyInfo> list4 = ReplyHelper.GetReplies(ReplyType.Scratch);
     if ((list4 != null) && (list4.Count > 0))
     {
         foreach (ReplyInfo info7 in list4)
         {
             if (info7.Keys == key)
             {
                 LotteryActivityInfo info8 = VShopHelper.GetLotteryActivityInfo(info7.ActivityId);
                 if (info8 != null)
                 {
                     NewsResponse response4 = new NewsResponse {
                         CreateTime = DateTime.Now,
                         FromUserName = request.ToUserName,
                         ToUserName = request.FromUserName,
                         Articles = new List<Article>()
                     };
                     Article article4 = new Article {
                         Description = info8.ActivityDesc,
                         PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, info8.ActivityPic),
                         Title = info8.ActivityName,
                         Url = string.Format("http://{0}/vshop/Scratch.aspx?activityId={1}", HttpContext.Current.Request.Url.Host, info8.ActivityId)
                     };
                     response4.Articles.Add(article4);
                     return response4;
                 }
             }
         }
     }
     IList<ReplyInfo> list5 = ReplyHelper.GetReplies(ReplyType.SmashEgg);
     if ((list5 != null) && (list5.Count > 0))
     {
         foreach (ReplyInfo info9 in list5)
         {
             if (info9.Keys == key)
             {
                 LotteryActivityInfo info10 = VShopHelper.GetLotteryActivityInfo(info9.ActivityId);
                 if (info10 != null)
                 {
                     NewsResponse response5 = new NewsResponse {
                         CreateTime = DateTime.Now,
                         FromUserName = request.ToUserName,
                         ToUserName = request.FromUserName,
                         Articles = new List<Article>()
                     };
                     Article article5 = new Article {
                         Description = info10.ActivityDesc,
                         PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, info10.ActivityPic),
                         Title = info10.ActivityName,
                         Url = string.Format("http://{0}/vshop/SmashEgg.aspx?activityId={1}", HttpContext.Current.Request.Url.Host, info10.ActivityId)
                     };
                     response5.Articles.Add(article5);
                     return response5;
                 }
             }
         }
     }
     IList<ReplyInfo> list6 = ReplyHelper.GetReplies(ReplyType.SignUp);
     if ((list6 != null) && (list6.Count > 0))
     {
         foreach (ReplyInfo info11 in list6)
         {
             if (info11.Keys == key)
             {
                 ActivityInfo activity = VShopHelper.GetActivity(info11.ActivityId);
                 if (activity != null)
                 {
                     NewsResponse response6 = new NewsResponse {
                         CreateTime = DateTime.Now,
                         FromUserName = request.ToUserName,
                         ToUserName = request.FromUserName,
                         Articles = new List<Article>()
                     };
                     Article article6 = new Article {
                         Description = activity.Description,
                         PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, activity.PicUrl),
                         Title = activity.Name,
                         Url = string.Format("http://{0}/vshop/Activity.aspx?id={1}", HttpContext.Current.Request.Url.Host, activity.ActivityId)
                     };
                     response6.Articles.Add(article6);
                     return response6;
                 }
             }
         }
     }
     IList<ReplyInfo> list7 = ReplyHelper.GetReplies(ReplyType.Ticket);
     if ((list7 != null) && (list7.Count > 0))
     {
         foreach (ReplyInfo info13 in list7)
         {
             if (info13.Keys == key)
             {
                 LotteryTicketInfo lotteryTicket = VShopHelper.GetLotteryTicket(info13.ActivityId);
                 if (lotteryTicket != null)
                 {
                     NewsResponse response7 = new NewsResponse {
                         CreateTime = DateTime.Now,
                         FromUserName = request.ToUserName,
                         ToUserName = request.FromUserName,
                         Articles = new List<Article>()
                     };
                     Article article7 = new Article {
                         Description = lotteryTicket.ActivityDesc,
                         PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, lotteryTicket.ActivityPic),
                         Title = lotteryTicket.ActivityName,
                         Url = string.Format("http://{0}/vshop/SignUp.aspx?id={1}", HttpContext.Current.Request.Url.Host, lotteryTicket.ActivityId)
                     };
                     response7.Articles.Add(article7);
                     return response7;
                 }
             }
         }
     }
     return null;
 }