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); }
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; }
/// <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); } }