Exemplo n.º 1
0
        private void ShowInfo()
        {
            Model.wx_userweixin weixin  = GetWeiXinCode();     //当前微信用户
            Model.wx_crm_users  cuModel = cuBll.GetModel(uid); //当前粉丝
            int     wid    = weixin.id;
            string  openid = cuModel.openid;
            DataSet ds     = rcBll.GetList(this.pageSize, this.page, " id>0 " + CombSqlTxt(this.keywords, wid, openid), "createDate desc,id asc", out totalCount);

            this.rptList.DataSource = ds;
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("talk.aspx", "keywords={0}&page={1}&id={2}",
                                              this.keywords, "__id__", uid.ToString());

            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Exemplo n.º 2
0
        private void ShowInfo(int _id)
        {
            BLL.wx_crm_users   uBll = new BLL.wx_crm_users();
            Model.wx_crm_users user = uBll.GetModel(_id);

            BLL.wx_crm_group   gBll  = new BLL.wx_crm_group();
            Model.wx_crm_group group = gBll.GetModel(user.groupId.Value);

            BLL.wx_crm_users_tag   tBll      = new BLL.wx_crm_users_tag();
            Model.wx_userweixin    weixin    = GetWeiXinCode();
            Model.wx_crm_users_tag tagEntity = tBll.GetModelByWidAndOpenid(weixin.id, user.openid);



            lblnickname.Text  = user.nickname;
            imgPhoto.ImageUrl = user.headimgurl;

            lblSex.Text = GetUserSex(int.Parse(user.sex));

            lblArea.Text           = user.country + " " + user.province + " " + user.city;
            lblsubscribe_time.Text = MyCommFun.GetTime(user.subscribe_time).ToString();

            prov = user.province;


            if (group != null)
            {
                lblGroupName.Text = group.name;
            }

            if (tagEntity != null)
            {
                hidtagId.Value = tagEntity.id.ToString();
                txtTag.Text    = tagEntity.tag;
            }

            hidWid.Value    = user.wid.ToString();
            hidOpenid.Value = user.openid;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 同步一个用户信息,如果库里存在,则修改,不存在,则新增
        /// </summary>
        /// <param name="userDetail"></param>
        private int InsertUserInfo(int wid, string accessToken, List <string> openidStr, DateTime updateTime)
        {
            int totCount = 0;

            //   将数据插入到数据库里
            BLL.wx_crm_users   uBll    = new BLL.wx_crm_users();
            Model.wx_crm_users uEntity = new Model.wx_crm_users();
            try
            {
                UserInfoJson userDetail = new UserInfoJson();
                for (int i = 0; i < openidStr.Count; i++)
                {
                    userDetail = Senparc.Weixin.MP.AdvancedAPIs.User.Info(accessToken, openidStr[i]);
                    uEntity    = uBll.GetModel(wid, openidStr[i]);
                    bool isAdd = true;
                    if (uEntity == null)
                    {
                        isAdd   = true;
                        uEntity = new Model.wx_crm_users();
                    }
                    else
                    {
                        isAdd = false;
                    }
                    uEntity.wid            = wid;
                    uEntity.openid         = openidStr[i];
                    uEntity.nickname       = userDetail.nickname;
                    uEntity.sex            = userDetail.sex.ToString();
                    uEntity.city           = userDetail.city;
                    uEntity.country        = userDetail.country;
                    uEntity.province       = userDetail.province;
                    uEntity.language       = userDetail.language;
                    uEntity.headimgurl     = userDetail.headimgurl;
                    uEntity.subscribe_time = userDetail.subscribe_time.ToString();

                    uEntity.updateDate = updateTime;
                    uEntity.uStatus    = 1;

                    //查询分组号
                    GetGroupIdResult gid = Groups.GetId(accessToken, openidStr[i]);
                    uEntity.groupId = gid.groupid;

                    if (isAdd)
                    {
                        //新增
                        uEntity.createDate = DateTime.Now;
                        int succ = uBll.Add(uEntity);
                        if (succ > 0)
                        {
                            totCount++;
                        }
                    }
                    else
                    {
                        //修改
                        bool succ = uBll.Update(uEntity);
                        if (succ)
                        {
                            totCount++;
                        }
                    }
                }
                return(totCount);
            }
            catch (Exception ex)
            {
                throw new Exception("用户信息同步失败!" + ex.Message);
            }
        }
Exemplo n.º 4
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;
            }
        }