Exemplo n.º 1
0
        public void SendImageMessage(string user, XmlNode TSubResultNode)
        {
            string           str_AccessToken = TokenBiz.GetAccessToken(str_corpid, str_corpsecret);
            SendImageRequest str             = new SendImageRequest();

            str.agentid = Agentid;
            str.safe    = "0";
            str.touser  = user;
            SendImageRequest.Text image = new SendImageRequest.Text();
            str.msgtype = TSubResultNode.SelectSingleNode("msgtype").InnerText;

            string         picPath          = HttpContext.Current.Request.PhysicalApplicationPath + TSubResultNode.SelectSingleNode("imagePath").InnerText;
            UploadResponse media_UpLoadInfo = MediaBiz.CreateInstance().Upload(picPath, str_AccessToken, EnumMediaType.image);

            if (media_UpLoadInfo != null)
            {
                image.media_id = media_UpLoadInfo.media_id;
            }

            str.image = image;

            messageBiz.Send <SendImageRequest>(str);

            if (!string.IsNullOrEmpty(TSubResultNode.SelectSingleNode("content").InnerText))
            {
                SendSingleMessage(user, TSubResultNode);
            }
        }
Exemplo n.º 2
0
        private void SendNewsMessage(string user, ResponseInfo <WeChatAnswerList> JsonResullt)
        {
            BotService.WebService1SoapClient BotService = new BotService.WebService1SoapClient();

            string          str_AccessToken = TokenBiz.GetAccessToken(str_corpid, str_corpsecret);
            SendNewsRequest str             = new SendNewsRequest();

            str.agentid = Agentid;
            str.touser  = user;
            str.msgtype = "news";
            SendNewsRequest.newsRequest news = new SendNewsRequest.newsRequest();
            news.articles = new List <SendNewsRequest.articles>();

            if (!string.IsNullOrEmpty(JsonResullt.responseInfo._title))
            {
                SendNewsRequest.articles article = new SendNewsRequest.articles();
                article.title       = JsonResullt.responseInfo._title;
                article.description = JsonResullt.responseInfo._description;
                article.url         = JsonResullt.responseInfo._url;
                if (!string.IsNullOrEmpty(JsonResullt.responseInfo._picurl))
                {
                    article.picurl = JsonResullt.responseInfo._picurl;
                }

                news.articles.Add(article);
                str.news = news;
                messageBiz.Send <SendNewsRequest>(str);
            }
            else
            {
                var          booksResult     = BotService.GetBooksList(JsonResullt.responseInfo._actionsid.ToString());
                List <Books> booksListResult = JsonHelper.JsonDeserialize <List <Books> >(booksResult);
                if (booksListResult.Any())
                {
                    booksListResult.ForEach(x =>
                    {
                        SendNewsRequest.articles article = new SendNewsRequest.articles();
                        article.title       = x._name;
                        article.description = x._description;
                        article.url         = x._url;
                        if (!string.IsNullOrEmpty(x._picurl))
                        {
                            article.picurl = x._picurl;
                        }
                        news.articles.Add(article);
                    });

                    str.news = news;
                    messageBiz.Send <SendNewsRequest>(str);
                }
                else
                {
                    SendSingleMessage(user, "Sorry,we haven't that kinds of books .");
                }
            }
        }
Exemplo n.º 3
0
        public void SendNewsMessage(string user, XmlNode TSubResultNode)
        {
            string          str_AccessToken = TokenBiz.GetAccessToken(str_corpid, str_corpsecret);
            SendNewsRequest str             = new SendNewsRequest();

            str.agentid = Agentid;
            str.touser  = user;
            str.msgtype = TSubResultNode.SelectSingleNode("msgtype").InnerText;
            SendNewsRequest.newsRequest news = new SendNewsRequest.newsRequest();
            news.articles = new List <SendNewsRequest.articles>();
            SendNewsRequest.articles article = new SendNewsRequest.articles();
            article.title       = TSubResultNode.SelectSingleNode("title").InnerText;
            article.description = TSubResultNode.SelectSingleNode("description").InnerText;
            article.url         = TSubResultNode.SelectSingleNode("url").InnerText;
            article.picurl      = TSubResultNode.SelectSingleNode("picurl").InnerText;
            news.articles.Add(article);
            str.news = news;

            messageBiz.Send <SendNewsRequest>(str);
        }
Exemplo n.º 4
0
        private void SendMpMessage(string user, ResponseInfo <WeChatAnswerList> JsonResullt)
        {
            SendMPNewsRequest _SendMPNewsRequest = new SendMPNewsRequest();
            mpnews            _Mpnews            = new mpnews();

            _Mpnews.articles = new List <articles>();
            string str_AccessToken = TokenBiz.GetAccessToken(str_corpid, str_corpsecret);

            //string filePath = HttpContext.Current.Request.PhysicalApplicationPath + TSubResultNode.SelectSingleNode("content").InnerText;
            //string content = File.ReadAllText(filePath);

            _SendMPNewsRequest.touser  = user;
            _SendMPNewsRequest.msgtype = "mpnews";
            _SendMPNewsRequest.agentid = Agentid;
            _SendMPNewsRequest.safe    = "0";


            if (!_Mpnews.articles.Any())//只要一条就可以了
            {
                articles article = new articles();
                string   picPath = HttpContext.Current.Request.PhysicalApplicationPath + "LusiResult/Banner/" + JsonResullt.responseInfo._banner;
                _SendLog.WriteLog(picPath);
                UploadResponse media_UpLoadInfo = MediaBiz.CreateInstance().Upload(picPath, str_AccessToken, EnumMediaType.image);
                if (media_UpLoadInfo != null)
                {
                    article.title          = JsonResullt.responseInfo._title;
                    article.thumb_media_id = media_UpLoadInfo.media_id;
                    //article.author = "RR Donnelley";
                    article.show_cover_pic = "0";
                    article.digest         = JsonResullt.responseInfo._digest;
                    _Mpnews.articles.Add(article);
                }
            }

            _Mpnews.articles.ForEach(x => x.content = JsonResullt.responseInfo._content);
            _SendMPNewsRequest.mpnews = _Mpnews;
            messageBiz.Send <SendMPNewsRequest>(_SendMPNewsRequest);
        }