Beispiel #1
0
        /// <summary>
        ///同步按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSyn_Click(object sender, EventArgs e)
        {
            string err = "";

            Model.wx_userweixin weixin = GetWeiXinCode();
            WeiXinCRMComm       wcr    = new WeiXinCRMComm();
            string accessToken         = wcr.getAccessToken(weixin.id, out err);

            if (err != "")
            {
                return;
            }
            BLL.wx_crm_users uBll = new BLL.wx_crm_users();


            //更新时间,作为一个标记
            DateTime updateTime = DateTime.Now;

            try
            {
                string ret = SysPersonFun(0, weixin.id, accessToken, "", updateTime);
                //查找此次为同步到的,则为已经跑路的
                IList <Model.wx_crm_users> userlist = uBll.GetModelList("updateDate<'" + updateTime.ToString() + "'");
                if (userlist != null && userlist.Count > 0)
                {
                    for (int i = 0; i < userlist.Count; i++)
                    {
                        userlist[i].uStatus = 2;
                        uBll.Update(userlist[i]);
                    }
                }

                JscriptMsg(ret, "user_list.aspx", "Success");
            }
            catch (Exception ex)
            {
                lblInfo.Text = ex.Message;
            }
        }
Beispiel #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;
        }
Beispiel #3
0
        private void RptBind(string _strWhere, string _orderby)
        {
            this.page = MXRequest.GetQueryInt("page", 1);
            if (this.group_id > 0)
            {
                this.ddlGroupId.SelectedValue = this.group_id.ToString();
            }
            if (this.status.Trim().Length > 0)
            {
                this.ddlstatus.SelectedValue = this.status.ToString();
            }

            this.txtKeywords.Text = this.keywords;


            BLL.wx_crm_users bll = new BLL.wx_crm_users();
            DataSet          ds  = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    dr = ds.Tables[0].Rows[i];
                    dr["subscribe_time"] = MyCommFun.GetTime(dr["subscribe_time"].ToString()).ToString();
                }
            }
            this.rptList.DataSource = ds;
            this.rptList.DataBind();

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

            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Beispiel #4
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);
            }
        }