public void GetUsers() { if (Context.Session["OpenId"] != null) { string OpenId = Context.Session["OpenId"].ToString();//"o_w1Kw8Uxh4dEoRDCe-HNYnyYlhY";// string deviceId = QrChildManager.GetChildDeviceId(OpenId); if (deviceId == "" || deviceId == null) { return; } DataTable dt = QrChildManager.GetOpenId(deviceId); Device_user du = new Device_user(); List <string> list = new List <string>(); foreach (DataRow row in dt.Rows) { list.Add(row["OpenId"].ToString()); } 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); dic3.Add("lang", "zh_CN"); list2.Add(dic3); } dic2.Add("user_list", list2); string data2 = du.GetUserInformation(JsonConvert.SerializeObject(dic2)); Write(data2); } }
public void Get_UserInformation(string deviceId, string token) { DataTable dt = QrChildManager.GetOpenId(deviceId); if (dt.Rows.Count == 0) { HttpContext.Current.Response.Write("null"); return; } string sql = string.Format("update ChildChatUser set Token = '{0}' where deviceId = '{1}'", token, deviceId); SqlHelper.ExecuteNonQuery(sql); List <string> list = new List <string>(); foreach (DataRow item in dt.Rows) { list.Add(item["OpenId"].ToString()); } 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); dic3.Add("lang", "zh_CN"); list2.Add(dic3); } dic2.Add("user_list", list2); string data2 = du.GetUserInformation(JsonConvert.SerializeObject(dic2)); HttpContext.Current.Response.Write(data2); }
public void DelUsers(string openId) { if (Context.Session["OpenId"] != null) { string OpenId = Context.Session["OpenId"].ToString(); string device = QrChildManager.GetChildDeviceId(OpenId); DataTable dt = QrChildManager.GetOpenId(device); if (OpenId == dt.Rows[0]["OpenId"].ToString()) { Device_user du = new Device_user(); List <string> list = new List <string>(); foreach (DataRow row in dt.Rows) { list.Add(row["OpenId"].ToString()); } 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); dic3.Add("lang", "zh_CN"); list2.Add(dic3); } dic2.Add("user_list", list2); string data2 = du.GetUserInformation(JsonConvert.SerializeObject(dic2)); Dictionary <string, List <Dictionary <string, object> > > list3 = JsonConvert.DeserializeObject <Dictionary <string, List <Dictionary <string, object> > > >(data2); 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"]) { if (user == admin) { return; } else { 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.SendNews(data); } } string xingeToken = QrChildManager.GetXingeToken(openId); QrChildManager.DeleteOpenId(openId, device); string js = "{\"Title\":\"推送消息\",\"Type\":7,\"OpenId\":\"" + openId + "\",\"Content\":\"\"}"; Message ms = new Message("e家亲幼儿伴侣", js); XinGePush.PushMsg(xingeToken, jsonSerializer.Serialize(ms)); Write("true"); } else { Write("你不是管理员,没有权限删除成员!"); } } }