예제 #1
0
        private IResponseMessageBase GetResponseMessage(KeywordInfo keywordInfo, string keyword)
        {
            try
            {
                if (keywordInfo != null && !keywordInfo.IsDisabled)
                {
                    if (keywordInfo.KeywordType == EKeywordType.Text)
                    {
                        DataProviderWX.CountDAO.AddCount(publishmentSystemInfo.PublishmentSystemId, ECountType.RequestText);

                        var responseMessage = CreateResponseMessage <ResponseMessageText>();
                        responseMessage.Content = keywordInfo.Reply;
                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.News)
                    {
                        DataProviderWX.CountDAO.AddCount(publishmentSystemInfo.PublishmentSystemId, ECountType.RequestNews);

                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();

                        foreach (var resourceInfo in DataProviderWX.KeywordResourceDAO.GetResourceInfoList(keywordInfo.KeywordID))
                        {
                            var imageUrl = PageUtils.AddProtocolToUrl(PageUtility.ParseNavigationUrl(publishmentSystemInfo, resourceInfo.ImageUrl));

                            var pageUrl = string.Empty;
                            if (resourceInfo.ResourceType == EResourceType.Site)
                            {
                                if (resourceInfo.ChannelID > 0 && resourceInfo.ContentID > 0)
                                {
                                    pageUrl = PageUtilityWX.GetContentUrl(publishmentSystemInfo, resourceInfo.ChannelID, resourceInfo.ContentID, false);
                                }
                                else if (resourceInfo.ChannelID > 0)
                                {
                                    pageUrl = PageUtilityWX.GetChannelUrl(publishmentSystemInfo, resourceInfo.ChannelID);
                                }
                                else
                                {
                                    pageUrl = PageUtilityWX.GetChannelUrl(publishmentSystemInfo, publishmentSystemInfo.PublishmentSystemId);
                                }
                            }
                            else if (resourceInfo.ResourceType == EResourceType.Content)
                            {
                                pageUrl = PageUtilityWX.GetWeiXinFileUrl(publishmentSystemInfo, resourceInfo.KeywordID, resourceInfo.ResourceID);
                            }
                            else if (resourceInfo.ResourceType == EResourceType.Url)
                            {
                                pageUrl = resourceInfo.NavigationUrl;
                            }

                            responseMessage.Articles.Add(new Article()
                            {
                                Title       = resourceInfo.Title,
                                Description = MPUtils.GetSummary(resourceInfo.Summary, resourceInfo.Content),
                                PicUrl      = imageUrl,
                                Url         = pageUrl
                            });
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Coupon)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = CouponManager.Trigger(keywordInfo, keyword, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Vote)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = VoteManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Message)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = MessageManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Appointment)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = AppointmentManager.Trigger(keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Conference)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = ConferenceManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Map)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = MapManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.View360)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = View360Manager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Album)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = AlbumManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Scratch)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.Scratch, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.BigWheel)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.BigWheel, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.GoldEgg)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.GoldEgg, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Flap)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.Flap, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.YaoYao)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.YaoYao, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Search)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = SearchManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Store)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = StoreManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Collect)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = CollectManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Card)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = CardManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtils.AddLog(string.Empty, "Gexia Error", ex.StackTrace);
            }

            return(null);
        }