예제 #1
0
        //消息异步群发接口,所有关注用户都能够收到
        public static string TotalSend(string biz_content)
        {
            AlipayMobilePublicMessageTotalSendRequest pushRequst = new AlipayMobilePublicMessageTotalSendRequest();

            pushRequst.BizContent = biz_content;

            //Response.Output.WriteLine(biz_content);
            // Response.End();

            Dictionary <string, string> paramsDict = (Dictionary <string, string>)pushRequst.GetParameters();
            IAopClient client = new DefaultAopClient(Config.serverUrl, Config.appId, Config.merchant_private_key);
            AlipayMobilePublicMessageTotalSendResponse pushResponse = client.Execute(pushRequst);

            return(pushResponse.Body);
        }
예제 #2
0
파일: SendAllEdit.cs 프로젝트: zwkjgs/XKD
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!base.IsPostBack)
            {
                if (this.type == "getarticleinfo")
                {
                    base.Response.ContentType = "application/json";
                    string s   = "{\"type\":\"0\",\"tips\":\"操作失败\"}";
                    int    num = Globals.RequestFormNum("articleid");
                    if (num > 0)
                    {
                        ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(num);
                        if (articleInfo != null)
                        {
                            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                            switch (articleInfo.ArticleType)
                            {
                            case ArticleType.News:
                                s = string.Concat(new object[]
                                {
                                    "{\"type\":\"1\",\"articletype\":",
                                    (int)articleInfo.ArticleType,
                                    ",\"title\":\"",
                                    this.String2Json(articleInfo.Title),
                                    "\",\"date\":\"",
                                    this.String2Json(articleInfo.PubTime.ToString("M月d日")),
                                    "\",\"imgurl\":\"",
                                    this.String2Json(articleInfo.ImageUrl),
                                    "\",\"memo\":\"",
                                    this.String2Json(articleInfo.Memo),
                                    "\"}"
                                });
                                goto IL_30E;

                            case ArticleType.List:
                            {
                                System.Collections.Generic.IList <ArticleItemsInfo> itemsInfo = articleInfo.ItemsInfo;
                                foreach (ArticleItemsInfo current in itemsInfo)
                                {
                                    stringBuilder.Append(string.Concat(new string[]
                                        {
                                            "{\"title\":\"",
                                            this.String2Json(current.Title),
                                            "\",\"imgurl\":\"",
                                            this.String2Json(current.ImageUrl),
                                            "\"},"
                                        }));
                                }
                                s = string.Concat(new object[]
                                    {
                                        "{\"type\":\"1\",\"articletype\":",
                                        (int)articleInfo.ArticleType,
                                        ",\"title\":\"",
                                        this.String2Json(articleInfo.Title),
                                        "\",\"date\":\"",
                                        this.String2Json(articleInfo.PubTime.ToString("M月d日")),
                                        "\",\"imgurl\":\"",
                                        this.String2Json(articleInfo.ImageUrl),
                                        "\",\"items\":[",
                                        stringBuilder.ToString().Trim(new char[]
                                        {
                                            ','
                                        }),
                                        "]}"
                                    });
                                goto IL_30E;
                            }
                            }
                            s = string.Concat(new object[]
                            {
                                "{\"type\":\"1\",\"articletype\":",
                                (int)articleInfo.ArticleType,
                                ",\"title\":\"",
                                this.String2Json(articleInfo.Title),
                                "\",\"date\":\"",
                                this.String2Json(articleInfo.PubTime.ToString("M月d日")),
                                "\",\"imgurl\":\"",
                                this.String2Json(articleInfo.ImageUrl),
                                "\",\"memo\":\"",
                                this.String2Json(articleInfo.Content),
                                "\"}"
                            });
                        }
                    }
IL_30E:
                    base.Response.Write(s);
                    base.Response.End();
                    return;
                }
                if (this.type == "postdata")
                {
                    base.Response.ContentType = "application/json";
                    this.sendID = Globals.RequestFormNum("sendid");
                    int    num2         = Globals.RequestFormNum("sendtype");
                    int    num3         = Globals.RequestFormNum("msgtype");
                    int    articleid    = Globals.RequestFormNum("articleid");
                    string title        = Globals.RequestFormStr("title");
                    string content      = Globals.RequestFormStr("content");
                    int    isoldarticle = Globals.RequestFormNum("isoldarticle");
                    string text         = this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, true);
                    string s2;
                    if (string.IsNullOrEmpty(text))
                    {
                        MessageType messageType = (MessageType)num3;
                        string      arg_3DF_0   = string.Empty;
                        Articles    Articles    = new Articles();
                        Articles.msgType = "text";
                        string storeUrl = Globals.HostPath(System.Web.HttpContext.Current.Request.Url);
                        if (messageType == MessageType.List || messageType == MessageType.News)
                        {
                            this.sendID = Globals.ToNum(this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, false));
                            ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(articleid);
                            if (articleInfo2 == null)
                            {
                                s2 = "{\"type\":\"0\",\"tips\":\"素材不存在了\"}";
                                base.Response.Write(s2);
                                base.Response.End();
                            }
                            Articles = this.GetAlipayArticlesFromArticleInfo(articleInfo2, storeUrl);
                        }
                        else
                        {
                            this.sendID   = Globals.ToNum(this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, false));
                            Articles.text = new MessageText
                            {
                                content = Globals.StripHtmlXmlTags(content)
                            };
                        }
                        SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                        if (AlipayFuwuConfig.appId.Length < 15)
                        {
                            AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, base.Server.MapPath("~/"), "GBK");
                        }
                        if (num2 == 1)
                        {
                            AlipayMobilePublicMessageTotalSendResponse alipayMobilePublicMessageTotalSendResponse = AliOHHelper.TotalSend(Articles);
                            if (!alipayMobilePublicMessageTotalSendResponse.IsError && alipayMobilePublicMessageTotalSendResponse.Code == "200")
                            {
                                s2 = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}";
                                string msgid = "";
                                if (!string.IsNullOrEmpty(alipayMobilePublicMessageTotalSendResponse.Data) && alipayMobilePublicMessageTotalSendResponse.Data.Length > 50)
                                {
                                    msgid = alipayMobilePublicMessageTotalSendResponse.Data.Substring(0, 49);
                                }
                                int alypayUserNum = WeiXinHelper.getAlypayUserNum();
                                WeiXinHelper.UpdateMsgId(this.sendID, msgid, 1, alypayUserNum, alypayUserNum, "");
                            }
                            else
                            {
                                s2 = "{\"type\":\"0\",\"tips\":\"" + alipayMobilePublicMessageTotalSendResponse.Msg + "\"}";
                                WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, alipayMobilePublicMessageTotalSendResponse.Body);
                            }
                        }
                        else
                        {
                            System.Collections.Generic.List <string> sendList = new System.Collections.Generic.List <string>();
                            System.Data.DataTable rencentAliOpenID            = WeiXinHelper.GetRencentAliOpenID();
                            if (rencentAliOpenID != null)
                            {
                                for (int i = 0; i < rencentAliOpenID.Rows.Count; i++)
                                {
                                    sendList.Add(rencentAliOpenID.Rows[i][0].ToString());
                                }
                            }
                            if (sendList.Count > 0)
                            {
                                WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, sendList.Count, "");
                                new System.Threading.Thread(() =>
                                {
                                    try
                                    {
                                        bool flag = false;
                                        foreach (string current3 in sendList)
                                        {
                                            if (current3.Length > 16)
                                            {
                                                Articles.toUserId = current3;
                                                AlipayMobilePublicMessageCustomSendResponse alipayMobilePublicMessageCustomSendResponse = AliOHHelper.CustomSend(Articles);
                                                if (alipayMobilePublicMessageCustomSendResponse != null && alipayMobilePublicMessageCustomSendResponse.IsError)
                                                {
                                                    AliOHHelper.log(alipayMobilePublicMessageCustomSendResponse.Body);
                                                }
                                                else
                                                {
                                                    flag = true;
                                                    WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1);
                                                }
                                                System.Threading.Thread.Sleep(10);
                                            }
                                        }
                                        if (flag)
                                        {
                                            WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1);
                                        }
                                        else
                                        {
                                            WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2);
                                        }
                                        System.Threading.Thread.Sleep(10);
                                    }
                                    catch (System.Exception ex)
                                    {
                                        AliOHHelper.log(ex.Message.ToString());
                                    }
                                }).Start();
                                s2 = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}";
                            }
                            else
                            {
                                s2 = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}";
                            }
                        }
                    }
                    else
                    {
                        s2 = "{\"type\":\"0\",\"tips\":\"" + text + "\"}";
                    }
                    base.Response.Write(s2);
                    base.Response.End();
                    return;
                }
                if (this.sendID > 0)
                {
                    this.hdfSendID.Value = this.sendID.ToString();
                    SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID);
                    if (sendAllInfo != null)
                    {
                        MessageType messageType2 = sendAllInfo.MessageType;
                        this.hdfMessageType.Value = ((int)sendAllInfo.MessageType).ToString();
                        int articleID = sendAllInfo.ArticleID;
                        this.hdfArticleID.Value = articleID.ToString();
                        this.txtTitle.Text      = sendAllInfo.Title;
                        switch (messageType2)
                        {
                        case MessageType.Text:
                            this.fkContent.Text = sendAllInfo.Content;
                            break;

                        case MessageType.News:
                            if (articleID <= 0)
                            {
                                this.hdfIsOldArticle.Value = "1";
                                NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                                if (newsReplyInfo != null && newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count != 0)
                                {
                                    this.htmlInfo = string.Concat(new string[]
                                    {
                                        "<div class=\"mate-inner\"><h3 id=\"singelTitle\">",
                                        newsReplyInfo.NewsMsg[0].Title,
                                        "</h3><span>",
                                        newsReplyInfo.LastEditDate.ToString("M月d日"),
                                        "</span><div class=\"mate-img\"><img id=\"img1\" src=\"",
                                        newsReplyInfo.NewsMsg[0].PicUrl,
                                        "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">",
                                        newsReplyInfo.NewsMsg[0].Description,
                                        "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">&gt;</em></div></div>"
                                    });
                                }
                            }
                            break;

                        case MessageType.List:
                            if (articleID <= 0)
                            {
                                this.hdfIsOldArticle.Value = "1";
                                NewsReplyInfo newsReplyInfo2 = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                                if (newsReplyInfo2 != null)
                                {
                                    System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder();
                                    if (newsReplyInfo2.NewsMsg != null && newsReplyInfo2.NewsMsg.Count > 0)
                                    {
                                        int num4 = 0;
                                        foreach (NewsMsgInfo current2 in newsReplyInfo2.NewsMsg)
                                        {
                                            num4++;
                                            if (num4 == 1)
                                            {
                                                stringBuilder2.Append(string.Concat(new string[]
                                                {
                                                    "<div class=\"mate-inner top\">                 <div class=\"mate-img\" >                     <img id=\"img1\" src=\"",
                                                    current2.PicUrl,
                                                    "\" class=\"img-responsive\">                     <div class=\"title\" id=\"title1\">",
                                                    current2.Title,
                                                    "</div>                 </div>             </div>"
                                                }));
                                            }
                                            else
                                            {
                                                stringBuilder2.Append(string.Concat(new string[]
                                                {
                                                    "             <div class=\"mate-inner\">                 <div class=\"child-mate\">                     <div class=\"child-mate-title clearfix\">                         <div class=\"title\">",
                                                    current2.Title,
                                                    "</div>                         <div class=\"img\">                             <img src=\"",
                                                    current2.PicUrl,
                                                    "\" class=\"img-responsive\">                         </div>                     </div>                 </div>             </div>"
                                                }));
                                            }
                                        }
                                        this.htmlInfo = stringBuilder2.ToString();
                                    }
                                }
                            }
                            break;
                        }
                    }
                    else
                    {
                        base.Response.Redirect("sendalllist.aspx");
                        base.Response.End();
                    }
                }
                else if (this.LocalArticleID > 0)
                {
                    ArticleInfo articleInfo3 = ArticleHelper.GetArticleInfo(this.LocalArticleID);
                    if (articleInfo3 != null)
                    {
                        this.hdfArticleID.Value   = this.LocalArticleID.ToString();
                        this.hdfMessageType.Value = ((int)articleInfo3.ArticleType).ToString();
                    }
                }
                if (string.IsNullOrEmpty(this.htmlInfo))
                {
                    this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>";
                }
                this.litInfo.Text = this.htmlInfo;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }
            if (this.type == "getarticleinfo")
            {
                this.Response.ContentType = "application/json";
                string s         = "{\"type\":\"0\",\"tips\":\"操作失败\"}";
                int    articleid = Globals.RequestFormNum("articleid");
                if (articleid > 0)
                {
                    ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(articleid);
                    if (articleInfo != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        switch (articleInfo.ArticleType)
                        {
                        case ArticleType.News:
                            s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"memo\":\"" + this.String2Json(articleInfo.Memo) + "\"}";
                            break;

                        case ArticleType.List:
                            foreach (ArticleItemsInfo articleItemsInfo in (IEnumerable <ArticleItemsInfo>)articleInfo.ItemsInfo)
                            {
                                stringBuilder.Append("{\"title\":\"" + this.String2Json(articleItemsInfo.Title) + "\",\"imgurl\":\"" + this.String2Json(articleItemsInfo.ImageUrl) + "\"},");
                            }
                            s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"items\":[" + ((object)stringBuilder).ToString().Trim(',') + "]}";
                            break;

                        default:
                            s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"memo\":\"" + this.String2Json(articleInfo.Content) + "\"}";
                            break;
                        }
                    }
                }
                this.Response.Write(s);
                this.Response.End();
            }
            else if (this.type == "postdata")
            {
                this.Response.ContentType = "application/json";
                this.sendID = Globals.RequestFormNum("sendid");
                int    num          = Globals.RequestFormNum("sendtype");
                int    msgType      = Globals.RequestFormNum("msgtype");
                int    articleid    = Globals.RequestFormNum("articleid");
                string title        = Globals.RequestFormStr("title");
                string content      = Globals.RequestFormStr("content");
                int    isoldarticle = Globals.RequestFormNum("isoldarticle");
                string str1         = this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, true);
                string s;
                if (string.IsNullOrEmpty(str1))
                {
                    MessageType messageType = (MessageType)msgType;
                    string      str2        = string.Empty;
                    Articles    Articles    = new Articles();
                    Articles.msgType = "text";
                    string storeUrl = Globals.HostPath(HttpContext.Current.Request.Url);
                    if (messageType == MessageType.List || messageType == MessageType.News)
                    {
                        this.sendID = Globals.ToNum((object)this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, false));
                        ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(articleid);
                        if (articleInfo == null)
                        {
                            this.Response.Write("{\"type\":\"0\",\"tips\":\"素材不存在了\"}");
                            this.Response.End();
                        }
                        Articles = this.GetAlipayArticlesFromArticleInfo(articleInfo, storeUrl);
                    }
                    else
                    {
                        this.sendID   = Globals.ToNum((object)this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, false));
                        Articles.text = new MessageText()
                        {
                            content = Globals.StripHtmlXmlTags(content)
                        };
                    }
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                    if (AlipayFuwuConfig.appId.Length < 15)
                    {
                        AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, this.Server.MapPath("~/"), "GBK");
                    }
                    if (num == 1)
                    {
                        AlipayMobilePublicMessageTotalSendResponse totalSendResponse = AliOHHelper.TotalSend(Articles);
                        if (!totalSendResponse.IsError && totalSendResponse.Code == "200")
                        {
                            s = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}";
                            string msgid = "";
                            if (!string.IsNullOrEmpty(totalSendResponse.Data) && totalSendResponse.Data.Length > 50)
                            {
                                msgid = totalSendResponse.Data.Substring(0, 49);
                            }
                            int alypayUserNum = WeiXinHelper.getAlypayUserNum();
                            WeiXinHelper.UpdateMsgId(this.sendID, msgid, 1, alypayUserNum, alypayUserNum, "");
                        }
                        else
                        {
                            s = "{\"type\":\"0\",\"tips\":\"" + totalSendResponse.Msg + "\"}";
                            WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, totalSendResponse.Body);
                        }
                    }
                    else
                    {
                        List <string> sendList         = new List <string>();
                        DataTable     rencentAliOpenId = WeiXinHelper.GetRencentAliOpenID();
                        if (rencentAliOpenId != null)
                        {
                            for (int index = 0; index < rencentAliOpenId.Rows.Count; ++index)
                            {
                                sendList.Add(rencentAliOpenId.Rows[index][0].ToString());
                            }
                        }
                        if (sendList.Count > 0)
                        {
                            WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, sendList.Count, "");
                            new Thread((ThreadStart)(() =>
                            {
                                try
                                {
                                    bool flag = false;
                                    foreach (string str in sendList)
                                    {
                                        if (str.Length > 16)
                                        {
                                            Articles.toUserId = str;
                                            AlipayMobilePublicMessageCustomSendResponse customSendResponse = AliOHHelper.CustomSend(Articles);
                                            if (customSendResponse != null && customSendResponse.IsError)
                                            {
                                                AliOHHelper.log(customSendResponse.Body);
                                            }
                                            else
                                            {
                                                flag = true;
                                                WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1);
                                            }
                                            Thread.Sleep(10);
                                        }
                                    }
                                    if (flag)
                                    {
                                        WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1);
                                    }
                                    else
                                    {
                                        WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2);
                                    }
                                    Thread.Sleep(10);
                                }
                                catch (Exception ex)
                                {
                                    AliOHHelper.log(((object)ex.Message).ToString());
                                }
                            })).Start();
                            s = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}";
                        }
                        else
                        {
                            s = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}";
                        }
                    }
                }
                else
                {
                    s = "{\"type\":\"0\",\"tips\":\"" + str1 + "\"}";
                }
                this.Response.Write(s);
                this.Response.End();
            }
            else
            {
                if (this.sendID > 0)
                {
                    this.hdfSendID.Value = this.sendID.ToString();
                    SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID);
                    if (sendAllInfo != null)
                    {
                        MessageType messageType = sendAllInfo.MessageType;
                        this.hdfMessageType.Value = ((int)sendAllInfo.MessageType).ToString();
                        int articleId = sendAllInfo.ArticleID;
                        this.hdfArticleID.Value = articleId.ToString();
                        this.txtTitle.Text      = sendAllInfo.Title;
                        switch (messageType)
                        {
                        case MessageType.Text:
                            this.fkContent.Text = sendAllInfo.Content;
                            break;

                        case MessageType.News:
                            if (articleId <= 0)
                            {
                                this.hdfIsOldArticle.Value = "1";
                                NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                                if (newsReplyInfo != null && newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count != 0)
                                {
                                    this.htmlInfo = "<div class=\"mate-inner\"><h3 id=\"singelTitle\">" + newsReplyInfo.NewsMsg[0].Title + "</h3><span>" + newsReplyInfo.LastEditDate.ToString("M月d日") + "</span><div class=\"mate-img\"><img id=\"img1\" src=\"" + newsReplyInfo.NewsMsg[0].PicUrl + "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">" + newsReplyInfo.NewsMsg[0].Description + "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">&gt;</em></div></div>";
                                    break;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }

                        case MessageType.List:
                            if (articleId <= 0)
                            {
                                this.hdfIsOldArticle.Value = "1";
                                NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                                if (newsReplyInfo != null)
                                {
                                    StringBuilder stringBuilder = new StringBuilder();
                                    if (newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count > 0)
                                    {
                                        int num = 0;
                                        foreach (NewsMsgInfo newsMsgInfo in (IEnumerable <NewsMsgInfo>)newsReplyInfo.NewsMsg)
                                        {
                                            ++num;
                                            if (num == 1)
                                            {
                                                stringBuilder.Append("<div class=\"mate-inner top\">                 <div class=\"mate-img\" >                     <img id=\"img1\" src=\"" + newsMsgInfo.PicUrl + "\" class=\"img-responsive\">                     <div class=\"title\" id=\"title1\">" + newsMsgInfo.Title + "</div>                 </div>             </div>");
                                            }
                                            else
                                            {
                                                stringBuilder.Append("             <div class=\"mate-inner\">                 <div class=\"child-mate\">                     <div class=\"child-mate-title clearfix\">                         <div class=\"title\">" + newsMsgInfo.Title + "</div>                         <div class=\"img\">                             <img src=\"" + newsMsgInfo.PicUrl + "\" class=\"img-responsive\">                         </div>                     </div>                 </div>             </div>");
                                            }
                                        }
                                        this.htmlInfo = ((object)stringBuilder).ToString();
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        this.Response.Redirect("sendalllist.aspx");
                        this.Response.End();
                    }
                }
                else if (this.LocalArticleID > 0)
                {
                    ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(this.LocalArticleID);
                    if (articleInfo != null)
                    {
                        this.hdfArticleID.Value   = this.LocalArticleID.ToString();
                        this.hdfMessageType.Value = ((int)articleInfo.ArticleType).ToString();
                    }
                }
                if (string.IsNullOrEmpty(this.htmlInfo))
                {
                    this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>";
                }
                this.litInfo.Text = this.htmlInfo;
            }
        }
예제 #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!base.IsPostBack)
            {
                if (this.type == "getarticleinfo")
                {
                    base.Response.ContentType = "application/json";
                    string str1 = "{\"type\":\"0\",\"tips\":\"操作失败\"}";
                    int    num  = Globals.RequestFormNum("articleid");
                    if (num > 0)
                    {
                        ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(num);
                        if (articleInfo != null)
                        {
                            StringBuilder stringBuilder = new StringBuilder();
                            switch (articleInfo.ArticleType)
                            {
                            case ArticleType.News:
                            {
                                object[] articleType = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null };
                                DateTime pubTime     = articleInfo.PubTime;
                                articleType[5]  = this.String2Json(pubTime.ToString("M月d日"));
                                articleType[6]  = "\",\"imgurl\":\"";
                                articleType[7]  = this.String2Json(articleInfo.ImageUrl);
                                articleType[8]  = "\",\"memo\":\"";
                                articleType[9]  = this.String2Json(articleInfo.Memo);
                                articleType[10] = "\"}";
                                str1            = string.Concat(articleType);
                                break;
                            }

                            case ArticleType.Text | ArticleType.News:
                            {
                                object[] objArray = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null };
                                DateTime dateTime = articleInfo.PubTime;
                                objArray[5]  = this.String2Json(dateTime.ToString("M月d日"));
                                objArray[6]  = "\",\"imgurl\":\"";
                                objArray[7]  = this.String2Json(articleInfo.ImageUrl);
                                objArray[8]  = "\",\"memo\":\"";
                                objArray[9]  = this.String2Json(articleInfo.Content);
                                objArray[10] = "\"}";
                                str1         = string.Concat(objArray);
                                break;
                            }

                            case ArticleType.List:
                            {
                                foreach (ArticleItemsInfo itemsInfo in articleInfo.ItemsInfo)
                                {
                                    string[] strArrays = new string[] { "{\"title\":\"", this.String2Json(itemsInfo.Title), "\",\"imgurl\":\"", this.String2Json(itemsInfo.ImageUrl), "\"}," };
                                    stringBuilder.Append(string.Concat(strArrays));
                                }
                                object[] articleType1 = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null };
                                DateTime pubTime1     = articleInfo.PubTime;
                                articleType1[5] = this.String2Json(pubTime1.ToString("M月d日"));
                                articleType1[6] = "\",\"imgurl\":\"";
                                articleType1[7] = this.String2Json(articleInfo.ImageUrl);
                                articleType1[8] = "\",\"items\":[";
                                string str2     = stringBuilder.ToString();
                                char[] chrArray = new char[] { ',' };
                                articleType1[9]  = str2.Trim(chrArray);
                                articleType1[10] = "]}";
                                str1             = string.Concat(articleType1);
                                break;
                            }

                            default:
                            {
                                goto case ArticleType.Text | ArticleType.News;
                            }
                            }
                        }
                    }
                    base.Response.Write(str1);
                    base.Response.End();
                    return;
                }
                if (this.type == "postdata")
                {
                    base.Response.ContentType = "application/json";
                    string str3 = "{\"type\":\"1\",\"tips\":\"操作成功\"}";
                    this.sendID = Globals.RequestFormNum("sendid");
                    int    num1 = Globals.RequestFormNum("sendtype");
                    int    num2 = Globals.RequestFormNum("msgtype");
                    int    num3 = Globals.RequestFormNum("articleid");
                    string str4 = Globals.RequestFormStr("title");
                    string str5 = Globals.RequestFormStr("content");
                    int    num4 = Globals.RequestFormNum("isoldarticle");
                    string str6 = this.SavePostData(num2, num3, str4, str5, num4, this.sendID, true);
                    if (!string.IsNullOrEmpty(str6))
                    {
                        str3 = string.Concat("{\"type\":\"0\",\"tips\":\"", str6, "\"}");
                    }
                    else
                    {
                        MessageType messageType = (MessageType)num2;
                        string      empty       = string.Empty;
                        Articles    article     = new Articles()
                        {
                            msgType = "text"
                        };
                        string str7 = Globals.HostPath(HttpContext.Current.Request.Url);
                        if (messageType == MessageType.List || messageType == MessageType.News)
                        {
                            this.sendID = Globals.ToNum(this.SavePostData(num2, num3, str4, str5, num4, this.sendID, false));
                            ArticleInfo articleInfo1 = ArticleHelper.GetArticleInfo(num3);
                            if (articleInfo1 == null)
                            {
                                str3 = "{\"type\":\"0\",\"tips\":\"素材不存在了\"}";
                                base.Response.Write(str3);
                                base.Response.End();
                            }
                            article = this.GetAlipayArticlesFromArticleInfo(articleInfo1, str7);
                        }
                        else
                        {
                            this.sendID = Globals.ToNum(this.SavePostData(num2, num3, str4, str5, num4, this.sendID, false));
                            Articles    article1    = article;
                            MessageText messageText = new MessageText()
                            {
                                content = Globals.StripHtmlXmlTags(str5)
                            };
                            article1.text = messageText;
                        }
                        SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                        if (AlipayFuwuConfig.appId.Length < 15)
                        {
                            AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, base.Server.MapPath("~/"), "GBK");
                        }
                        if (num1 != 1)
                        {
                            List <string> strs             = new List <string>();
                            DataTable     rencentAliOpenID = WeiXinHelper.GetRencentAliOpenID();
                            if (rencentAliOpenID != null)
                            {
                                for (int i = 0; i < rencentAliOpenID.Rows.Count; i++)
                                {
                                    strs.Add(rencentAliOpenID.Rows[i][0].ToString());
                                }
                            }
                            if (strs.Count <= 0)
                            {
                                str3 = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}";
                            }
                            else
                            {
                                WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, strs.Count, "");
                                (new Thread(() =>
                                {
                                    try
                                    {
                                        bool flag = false;
                                        foreach (string str in strs)
                                        {
                                            if (str.Length <= 16)
                                            {
                                                continue;
                                            }
                                            article.toUserId = str;
                                            AlipayMobilePublicMessageCustomSendResponse alipayMobilePublicMessageCustomSendResponse = AliOHHelper.CustomSend(article);
                                            if (alipayMobilePublicMessageCustomSendResponse == null || !alipayMobilePublicMessageCustomSendResponse.IsError)
                                            {
                                                flag = true;
                                                WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1);
                                            }
                                            else
                                            {
                                                AliOHHelper.log(alipayMobilePublicMessageCustomSendResponse.Body);
                                            }
                                            Thread.Sleep(10);
                                        }
                                        if (!flag)
                                        {
                                            WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2);
                                        }
                                        else
                                        {
                                            WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1);
                                        }
                                        Thread.Sleep(10);
                                    }
                                    catch (Exception exception)
                                    {
                                        AliOHHelper.log(exception.Message.ToString());
                                    }
                                })).Start();
                                str3 = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}";
                            }
                        }
                        else
                        {
                            AlipayMobilePublicMessageTotalSendResponse alipayMobilePublicMessageTotalSendResponse = AliOHHelper.TotalSend(article);
                            if (alipayMobilePublicMessageTotalSendResponse.IsError || !(alipayMobilePublicMessageTotalSendResponse.Code == "200"))
                            {
                                str3 = string.Concat("{\"type\":\"0\",\"tips\":\"", alipayMobilePublicMessageTotalSendResponse.Msg, "\"}");
                                WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, alipayMobilePublicMessageTotalSendResponse.Body);
                            }
                            else
                            {
                                str3 = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}";
                                string str8 = "";
                                if (!string.IsNullOrEmpty(alipayMobilePublicMessageTotalSendResponse.Data) && alipayMobilePublicMessageTotalSendResponse.Data.Length > 50)
                                {
                                    str8 = alipayMobilePublicMessageTotalSendResponse.Data.Substring(0, 49);
                                }
                                int alypayUserNum = WeiXinHelper.getAlypayUserNum();
                                WeiXinHelper.UpdateMsgId(this.sendID, str8, 1, alypayUserNum, alypayUserNum, "");
                            }
                        }
                    }
                    base.Response.Write(str3);
                    base.Response.End();
                    return;
                }
                if (this.sendID > 0)
                {
                    this.hdfSendID.Value = this.sendID.ToString();
                    SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID);
                    if (sendAllInfo == null)
                    {
                        base.Response.Redirect("sendalllist.aspx");
                        base.Response.End();
                    }
                    else
                    {
                        MessageType messageType1 = sendAllInfo.MessageType;
                        this.hdfMessageType.Value = sendAllInfo.MessageType.ToString();
                        int articleID = sendAllInfo.ArticleID;
                        this.hdfArticleID.Value = articleID.ToString();
                        this.txtTitle.Text      = sendAllInfo.Title;
                        switch (messageType1)
                        {
                        case MessageType.Text:
                        {
                            this.fkContent.Text = sendAllInfo.Content;
                            break;
                        }

                        case MessageType.News:
                        {
                            if (articleID > 0)
                            {
                                break;
                            }
                            this.hdfIsOldArticle.Value = "1";
                            NewsReplyInfo reply = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                            if (reply == null || reply.NewsMsg == null || reply.NewsMsg.Count == 0)
                            {
                                break;
                            }
                            string[] title = new string[] { "<div class=\"mate-inner\"><h3 id=\"singelTitle\">", reply.NewsMsg[0].Title, "</h3><span>", null, null, null, null, null, null };
                            title[3]      = reply.LastEditDate.ToString("M月d日");
                            title[4]      = "</span><div class=\"mate-img\"><img id=\"img1\" src=\"";
                            title[5]      = reply.NewsMsg[0].PicUrl;
                            title[6]      = "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">";
                            title[7]      = reply.NewsMsg[0].Description;
                            title[8]      = "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">&gt;</em></div></div>";
                            this.htmlInfo = string.Concat(title);
                            break;
                        }

                        case MessageType.List:
                        {
                            if (articleID > 0)
                            {
                                break;
                            }
                            this.hdfIsOldArticle.Value = "1";
                            NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                            if (newsReplyInfo == null)
                            {
                                break;
                            }
                            StringBuilder stringBuilder1 = new StringBuilder();
                            if (newsReplyInfo.NewsMsg == null || newsReplyInfo.NewsMsg.Count <= 0)
                            {
                                break;
                            }
                            int num5 = 0;
                            foreach (NewsMsgInfo newsMsg in newsReplyInfo.NewsMsg)
                            {
                                num5++;
                                if (num5 != 1)
                                {
                                    string[] title1 = new string[] { "             <div class=\"mate-inner\">                 <div class=\"child-mate\">                     <div class=\"child-mate-title clearfix\">                         <div class=\"title\">", newsMsg.Title, "</div>                         <div class=\"img\">                             <img src=\"", newsMsg.PicUrl, "\" class=\"img-responsive\">                         </div>                     </div>                 </div>             </div>" };
                                    stringBuilder1.Append(string.Concat(title1));
                                }
                                else
                                {
                                    string[] picUrl = new string[] { "<div class=\"mate-inner top\">                 <div class=\"mate-img\" >                     <img id=\"img1\" src=\"", newsMsg.PicUrl, "\" class=\"img-responsive\">                     <div class=\"title\" id=\"title1\">", newsMsg.Title, "</div>                 </div>             </div>" };
                                    stringBuilder1.Append(string.Concat(picUrl));
                                }
                            }
                            this.htmlInfo = stringBuilder1.ToString();
                            break;
                        }
                        }
                    }
                }
                else if (this.LocalArticleID > 0)
                {
                    ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(this.LocalArticleID);
                    if (articleInfo2 != null)
                    {
                        this.hdfArticleID.Value   = this.LocalArticleID.ToString();
                        this.hdfMessageType.Value = articleInfo2.ArticleType.ToString();
                    }
                }
                if (string.IsNullOrEmpty(this.htmlInfo))
                {
                    this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>";
                }
                this.litInfo.Text = this.htmlInfo;
            }
        }