Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
        public string GetChildToken()
        {
            /*WeChildToken wct = null;
             * Application.Lock();
             * if (Application["ChildToken"] != null) {
             *  wct = Application["ChildToken"] as WeChildToken;
             *  if (wct != null && (DateTime.Now.Subtract(wct.CreateTime)).TotalSeconds < wct.Expires - 200) {
             *      return wct.ChildToken;
             *  }
             * }
             * Dictionary<string, object> dic = WeChildChatHelper.GetBabyToken();
             * wct = new WeChildToken(dic["access_token"] + "", Convert.ToInt32(dic["expires_in"] + ""));
             * Application["ChildToken"] = wct;
             * Application.UnLock();
             * return wct.ChildToken;*/
            Device_user du = new Device_user();

            return(du.SelectToken());
        }
Ejemplo n.º 5
0
        public void GetEwm()
        {
            if (Context.Session["OpenId"] != null)
            {
                string OpenId   = Context.Session["OpenId"].ToString();
                string deviceId = QrChildManager.GetChildDeviceId(OpenId);
                string token    = QrChildManager.Get_xingeToken(deviceId);

                /*Dictionary<string, string> dic = new Dictionary<string, string>();
                 * dic.Add("deviceId", deviceId);
                 * dic.Add("token", token);  xiiuagiasdasdadsdadasd
                 * Write(JsonConvert.SerializeObject(dic));*/
                Device_user du       = new Device_user();
                Byte[]      imgBytes = QrChildManager.getQrUrl(deviceId, token, du.SelectToken());
                WriteLog("GetEwm END:" + imgBytes.Length);
                Context.Response.Clear();
                Context.Response.ContentType = "image/jpg";
                Context.Response.BinaryWrite(imgBytes);
                Context.Response.End();
            }
        }
Ejemplo n.º 6
0
 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("你不是管理员,没有权限删除成员!");
         }
     }
 }
Ejemplo n.º 7
0
 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("你不是管理员,没有权限删除成员!");
         }
     }
 }