public ActionResult UpdateUserInfo(string ids) { string[] idsArr = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (idsArr != null && idsArr.Length > 0) { Guid[] gids = TypeConverter.StrsToGuids(idsArr); IList <MpUser> mpusers = MpUserService.GetALL(p => gids.Contains(p.Id)); string token = GetAccessToken(); if (mpusers != null && mpusers.Count > 0 && !string.IsNullOrEmpty(token)) { foreach (MpUser currUser in mpusers) { try { UserInfoJson info = Senparc.Weixin.MP.AdvancedAPIs.User.Info(token, currUser.OpenID); if (info != null) { currUser.City = info.city; currUser.Country = info.country; currUser.HeadImgUrl = info.headimgurl; currUser.Language = info.language; currUser.NickName = info.nickname; currUser.Province = info.province; currUser.Sex = info.sex; currUser.SubscribeDate = DateTimeHelper.GetDateTimeFromXml(info.subscribe_time); MpUserService.Update(currUser); } } catch (Exception e) { Log4NetImpl.Write("AysnUser失败:" + e.Message); } } } } return(JsonMessage(true, "同步资料成功")); }
public ActionResult Index() { ViewBag.ListMpUser = _mpUserService.GetALL(); return(View()); }