public void Get_UserInformation(string deviceId, string token) { VideoEntities ve = DBContextFactory.GetDbContext(); Device_user du = new Device_user(); List <WeChatUser> wlist = ve.WeChatUser.Where(x => x.DeviceId == deviceId).ToList(); if (wlist.Count == 0) { HttpContext.Current.Response.Write("null"); return; } foreach (var item in wlist) { item.Token = token; ve.SaveChanges(); } Dictionary <string, List <Dictionary <string, string> > > dic2 = new Dictionary <string, List <Dictionary <string, string> > >(); List <Dictionary <string, string> > list2 = new List <Dictionary <string, string> >(); foreach (var item in wlist) { Dictionary <string, string> dic3 = new Dictionary <string, string>(); dic3.Add("openid", item.OpenId); dic3.Add("lang", "zh_CN"); list2.Add(dic3); } dic2.Add("user_list", list2); string data2 = du.GetUserInformation2(JsonConvert.SerializeObject(dic2), GetToken()); HttpContext.Current.Response.Write(data2); }
public void EGetUsers() { if (Context.Session["OpenIdE"] != null) { string OpenId = Context.Session["OpenIdE"].ToString(); WeChatUser wcu = ve.WeChatUser.FirstOrDefault(x => x.OpenId == OpenId && x.State == true); if (wcu == null) { return; } List <WeChatUser> wcus = ve.WeChatUser.Where(x => x.DeviceId == wcu.DeviceId).OrderBy(x => x.CreateDate).ToList(); Device_user du = new Device_user(); Dictionary <string, List <Dictionary <string, string> > > dic2 = new Dictionary <string, List <Dictionary <string, string> > >(); List <Dictionary <string, string> > list2 = new List <Dictionary <string, string> >(); foreach (var item in wcus) { Dictionary <string, string> dic3 = new Dictionary <string, string>(); dic3.Add("openid", item.OpenId); dic3.Add("lang", "zh_CN"); list2.Add(dic3); } dic2.Add("user_list", list2); string data2 = du.GetUserInformation2(JsonConvert.SerializeObject(dic2), GetToken()); Write(data2); } }
public void EDelUsers(string openId) { if (Context.Session["OpenIdE"] != null) { string OpenId = Context.Session["OpenIdE"].ToString(); WeChatUser wcu = ve.WeChatUser.FirstOrDefault(x => x.OpenId == OpenId && x.State == true); List <WeChatUser> list = ve.WeChatUser.Where(x => x.DeviceId == wcu.DeviceId).OrderBy(x => x.CreateDate).ToList(); if (OpenId == list[0].OpenId) { Device_user du = new Device_user(); Dictionary <string, List <Dictionary <string, string> > > dic2 = new Dictionary <string, List <Dictionary <string, string> > >(); List <Dictionary <string, string> > list2 = new List <Dictionary <string, string> >(); foreach (var item in list) { Dictionary <string, string> dic3 = new Dictionary <string, string>(); dic3.Add("openid", item.OpenId); dic3.Add("lang", "zh_CN"); list2.Add(dic3); } dic2.Add("user_list", list2); string data2 = du.GetUserInformation2(JsonConvert.SerializeObject(dic2), GetToken()); Dictionary <string, List <Dictionary <string, object> > > list3 = JsonConvert.DeserializeObject <Dictionary <string, List <Dictionary <string, object> > > >(data2); //string[] ids = openId.Split(','); //foreach (var id in ids) { string admin = ""; string user = ""; foreach (var item in list3["user_info_list"]) { if (item["openid"].ToString() == OpenId) { admin = item["nickname"].ToString(); } if (item["openid"].ToString() == openId) { user = item["nickname"].ToString(); } } foreach (var item in list3["user_info_list"]) { string content = string.Format("成员{0}已被管理员{1}删除绑定!", user, admin); if (item["openid"].ToString() == openId) { content = string.Format("你已被管理员{0}删除绑定!", admin); } string data = "{\"touser\":\"" + item["openid"] + "\",\"msgtype\":\"text\",\"text\":{\"content\":\"" + content + "\"}}"; du.SendNews2(data, GetToken()); } WeChatUser wcu2 = ve.WeChatUser.FirstOrDefault(x => x.OpenId == openId && x.DeviceId == wcu.DeviceId); string js = "{\"Title\":\"推送消息\",\"Type\":7,\"OpenId\":\"" + openId + "\",\"Content\":\"\"}"; Message ms = new Message("e家亲", js); PushHelper.PushMsg(wcu2.Token, jsonSerializer.Serialize(ms)); ve.WeChatUser.Remove(wcu2); ve.SaveChanges(); //} Write("true"); } else { Write("你不是管理员,没有权限删除成员!"); } } }