コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BLL.wx_crm_fodder cfBll = new BLL.wx_crm_fodder();
            int fid = MXRequest.GetQueryInt("id");

            if (!IsPostBack)
            {
                Model.wx_crm_fodder cfModel = cfBll.GetModel(fid);
                this.lblTitle.Text   = cfModel.title;
                this.imgPic.ImageUrl = cfModel.picurl;
                this.lblContent.Text = cfModel.scContent;
            }
        }
コード例 #2
0
        protected void btnSendout_Click(object sender, EventArgs e)
        {
            BLL.wx_crm_fodder   cfBll   = new BLL.wx_crm_fodder();
            Model.wx_userweixin weixin  = GetWeiXinCode();     //当前微信用户
            Model.wx_crm_users  cuModel = cuBll.GetModel(uid); //当前粉丝
            string error       = "";
            string accessToken = WeiXinCRMComm.getAccessToken(weixin.id, out error);

            Model.wx_response_BaseData rc = new Model.wx_response_BaseData();
            try
            {
                rc.createDate = DateTime.Now;
                rc.wid        = weixin.id;
                rc.flag       = 1;
                rc.rType      = "客服回复";
                rc.wx_openid  = cuModel.openid;//当前粉丝的openid

                if (rblResponseType.SelectedItem.Value == "0")
                {  //纯文本
                    //规则
                    if (this.txtContent.Text.Trim().Length == 0)
                    {
                        JscriptMsg("内容不能为空", "back", "Error");
                        return;
                    }
                    //添加内容
                    rc.reponseContent = txtContent.Text.Trim();
                    rc.responseType   = "text";
                    SendText(accessToken, cuModel.openid, txtContent.Text.Trim());
                }
                else if (rblResponseType.SelectedItem.Value == "1")
                {
                    #region 图文的信息回复
                    //图文
                    //判断图片来自服务器或公网
                    string imgurl = this.txtImgUrl.Text;
                    if (imgurl.IndexOf("http") < 0)
                    {
                        imgurl = MyCommFun.getWebSite() + imgurl;
                    }
                    //发送图文
                    List <Article> artList = new List <Article>
                    {
                        new Article()
                        {
                            Url         = this.txtUrl.Text,
                            PicUrl      = imgurl,
                            Title       = this.txtTitle.Text,
                            Description = this.txtNewsContent.Value
                        },
                    };
                    SendNews(accessToken, cuModel.openid, artList);
                    //添加内容
                    Model.wx_crm_fodder cfModel = new Model.wx_crm_fodder
                    {
                        scContent  = this.txtNewsContent.Value,
                        title      = this.txtTitle.Text,
                        picurl     = imgurl,
                        url        = this.txtUrl.Text,
                        createDate = DateTime.Now
                    };
                    int res = cfBll.Add(cfModel);

                    Dictionary <string, string> jsonDict = new Dictionary <string, string>();
                    jsonDict.Add("title", this.txtTitle.Text);
                    jsonDict.Add("scContent", this.txtNewsContent.Value);
                    jsonDict.Add("picurl", imgurl);
                    jsonDict.Add("url", this.txtUrl.Text);
                    jsonDict.Add("createDate", this.txtUrl.Text);

                    rc.reponseContent = this.txtTitle.Text + "";
                    rc.responseType   = "news";

                    #endregion
                }
                else if (rblResponseType.SelectedItem.Value == "2")
                {  //语音
                    if (this.txtMusicTitle.Text.Trim().Length == 0)
                    {
                        JscriptMsg("音乐不能为空", "back", "Error");
                        return;
                    }
                    if (this.txtMusicFile.Text.Trim().Length == 0)
                    {
                        JscriptMsg("音乐链接不能为空", "back", "Error");
                        return;
                    }

                    //添加内容
                    rc.responseType = "voice";
                    rc.remark       = txtMusicRemark.Text;
                    SendVoice(accessToken, cuModel.openid, "Media_Id");
                }
                rcBll.Add(rc);

                //AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "编辑" + ruleName); //记录日志
                JscriptMsg("发送信息成功!", "talk.aspx?keywords=" + this.keywords + "&id=" + uid, "Success");
            }
            catch (Exception)
            {
                JscriptMsg("发送信息失败!", "talk.aspx?keywords=" + this.keywords + "&id=" + uid, "Error");
                return;
            }
        }