Пример #1
0
 protected void But_delete_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Request.QueryString["id"]))
     {
         int id = Convert.ToInt32(Request.QueryString["id"]);
         if (!string.IsNullOrEmpty(Session["OpenIdE"].ToString()))
         {
             string openId     = Convert.ToString(Session["OpenIdE"]);
             string xingeToken = QrChildManager.GetXingeToken(openId);//得到token
             string DeviceId   = QrChildManager.GetDeviceId(xingeToken);
             if (AlarmClocksLogic.deleteAlarm(id))
             {
                 JObject content_json = new JObject();
                 content_json.Add("flag", 1);
                 content_json.Add("Id", id);
                 JObject ms_json = new JObject();
                 ms_json.Add("Title", "推送消息");
                 ms_json.Add("Type", 13);
                 ms_json.Add("OpenId", openId);
                 ms_json.Add("Content", content_json);
                 Response.Write(" <script type=\"text/javascript\"> alert(\"删除成功!\");</script>");
                 Response.Write(" <script type=\"text/javascript\"> window.location.href =\" AlarmClock.aspx\";</script>");
                 Message ms = new Message("幼儿伴侣", ms_json.ToString());
                 JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                 string  returnStr = XinGePush.PushMsg(xingeToken, jsonSerializer.Serialize(ms));
                 JObject json      = JObject.Parse(returnStr);
                 returnStr = json["ret_code"].ToString();
             }
         }
     }
 }
Пример #2
0
 public void tuisong()
 {
     JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
     string  js        = "{\"Title\":\"推送消息\",\"Type\":11,\"OpenId\":\"" + "o_w1Kwx_7GW6CcebDZ0uSDgQv5NU" + "\",\"Content\":\"" + "你好!" + "\"}";
     Message ms        = new Message("e家亲幼儿伴侣", js);
     string  returnStr = XinGePush.PushMsg("94af7b317b9c6e5f461a9873de5ba1ee7f3f1996", jsonSerializer.Serialize(ms));
 }
Пример #3
0
 public void DelDevice(string deviceId)
 {
     if (Context.Session["OpenId"] != null)
     {
         string OpenId     = Context.Session["OpenId"].ToString();
         string xingeToken = QrChildManager.GetXingeToken(OpenId);
         QrChildManager.DelDervice(OpenId, deviceId);
         string  js = "{\"Title\":\"推送消息\",\"Type\":7,\"OpenId\":\"" + OpenId + "\",\"Content\":\"\"}";
         Message ms = new Message("e家亲幼儿伴侣", js);
         XinGePush.PushMsg(xingeToken, jsonSerializer.Serialize(ms));
         Write("true");
     }
 }
Пример #4
0
 public void WeChildPushMsg(string msg, string post)
 {
     if (Context.Session["OpenId"] != null)
     {
         //string openId = FromUserName.InnerText;
         //string xingeToken = QrChildManager.GetXingeToken(openId);
         string OpenId      = Context.Session["OpenId"].ToString();
         string xingeOpenId = QrChildManager.GetXingeOpenId(OpenId);
         string xingeToken  = QrChildManager.GetToken(OpenId);
         if (xingeOpenId != null && xingeOpenId != "")
         {
             int       id = Convert.ToInt32(msg);
             Video     vi = ve.Video.FirstOrDefault(q => q.Id == id);
             VideoType vt = ve.VideoType.FirstOrDefault(q => q.Id == vi.Tid);
             string    js = "{\"video_id\":" + id + ",\"video_name\":\"" + vi.Title + "\",\"position\":" + post + ",\"type_id\":" + vi.Tid + ",\"type_title\":\"" + vt.Title + "\",\"type_cover\":\"" + vt.Cover + "\"}";
             js = "{\"Title\":\"幼儿伴侣推送\",\"Type\":5,\"Content\":" + js + "}";
             Messages ms        = new Messages("幼儿伴侣", js);
             string   returnStr = XinGePush.PushMsg(xingeToken, jsonSerializer.Serialize(ms));
             JObject  json      = JObject.Parse(returnStr);
             returnStr = json["ret_code"].ToString();
             //Write("推送成功!");
             if (returnStr == "0")
             {
                 new ChildPartner().SetMsgChild(xingeOpenId, "【" + vt.Title + "-" + vi.Title + "】推送成功!/:sun");
                 Write("推送成功!");
             }
             else
             {
                 Write("推送失败!" + returnStr);
             }
         }
         else
         {
             Write("您没绑定设备");
         }
     }
     else
     {
         Write("您还没有登陆,推送失败");
     }
 }
Пример #5
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("你不是管理员,没有权限删除成员!");
         }
     }
 }
Пример #6
0
        /// <summary>
        /// 添加闹钟
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void But_xiugai_Click(object sender, EventArgs e)
        {
            //还有一个闹钟类型要添加
            string time    = Request.Form.Get("RTime");  //提醒时间
            string content = this.Text_Content.Text;     //提醒名称
            string Repeat  = Request.Form.Get("Repeat"); //是否重复

            int[] weekDay = new int[7];
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected == true)
                {
                    weekDay[i] = 1;
                }
            }
            string weekStr = "";

            for (int i = 0; i < weekDay.Length; i++)
            {
                if (weekDay[i] == 1)
                {
                    weekStr += "1";
                }
                else
                {
                    weekStr += "0";
                }
                weekStr += ",";
            }
            weekStr.Remove(weekStr.Length - 1);
            //获取字符串长度
            int length = weekStr.Length;

            //截取除最后一位的前面所有字符
            weekStr = weekStr.Substring(0, length - 1);
            string Frequency  = Request["count"];                     //拿到重复次数
            string Interval   = Request.Form.Get("interval");         //拿到闹钟间隔
            string openId     = Convert.ToString(Session["openId"]);
            string xingeToken = QrChildManager.GetXingeToken(openId); //得到token

            if (xingeToken != "" && xingeToken != null)
            {
                //string DeviceId ="b84c0210ec00";
                string DeviceId = QrChildManager.GetDeviceId(xingeToken);//根据得到的token拿到用户表的DeviceId
                if (time != null && time != "" && content != null && content != "" && Repeat != null && Repeat != "" && Frequency != null && Frequency != "" && Interval != null && Interval != "")
                {
                    string sql = string.Format("insert AlarmClock (ClockTime,DeviceId,[Content],[Repeat],RepeatDate,Frequency,Interval) values ('{0}','{1}','{2}','{3}','{4}','{5}','{5}')", time, DeviceId, content, Repeat, weekStr, Frequency, Interval);
                    SqlHelper.ExecuteNonQuery(sql);
                    ClientScript.RegisterStartupScript(this.GetType(), "幼儿伴侣提醒您!", "<script>alert('添加成功!'); location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0e7b25b6f1553eea&redirect_uri=http://v.icoxtech.com/AlarmClock.aspx?response_type=code&scope=snsapi_base&state=1#wechat_redirect';</script>");
                    JObject  content_json = new JObject();
                    string[] dts          = time.Split(':');
                    string   hour         = dts[0];
                    string   mitner       = dts[1];
                    content_json.Add("flag", 3);
                    content_json.Add("hour", hour);
                    content_json.Add("mitner", mitner);
                    content_json.Add("content", content);
                    content_json.Add("Repeat", Repeat);
                    content_json.Add("weekStr", weekStr);
                    content_json.Add("Frequency", Frequency);
                    content_json.Add("Interval", Interval);
                    content_json.Add("DeviceId", DeviceId);
                    //string js = "{\"Title\":\"推送消息\",\"Type\":13,\"OpenId\":\"" + openId + "\",\"Content\":" + content_json.ToString() + "}";
                    //Message ms = new Message("幼儿伴侣", js);
                    //string returnStr = XinGePush.PushMsg(xingeToken, jsonSerializer.Serialize(ms));
                    ////string returnStr = XinGePush.PushMsg(xingeToken, JsonConvert.SerializeObject(ms));
                    //JObject json = JObject.Parse(returnStr);
                    //returnStr = json["ret_code"].ToString();
                    //Response.Write(returnStr);

                    JObject ms_json = new JObject();
                    ms_json.Add("Title", "推送消息");
                    ms_json.Add("Type", 13);
                    ms_json.Add("OpenId", openId);
                    ms_json.Add("Content", content_json);//string content_str = "{\"flag\":\"" + 3 + "\",\"hour\":" + hour + ",\"mitner\":\"" + mitner + "\",\"content\":\"" + content + "\",\"YesandNo\":\"" + YesandNo + ",\"weekStr\":\"" + weekStr + "\",\"Frequency\":\"" + Frequency + "\",\"Interval\":\"" + Interval + "\",\"DeviceId\":\"" + DeviceId + "\"}";
                    //string js = "{\"Title\":\"推送消息\",\"Type\":13,\"OpenId\":\"" + openId + "\",\"Content\":\"" + content_str + "\"}";
                    Message ms         = new Message("e家亲幼儿伴侣", ms_json.ToString());
                    string  returnStr  = XinGePush.PushMsg(xingeToken, jsonSerializer.Serialize(ms));
                    JObject json       = JObject.Parse(returnStr);
                    string  returnCode = json["ret_code"].ToString();
                    if (returnCode == "0")
                    {
                        //Response.Write(returnStr + ", xingeToken = " + xingeToken + ", js = " + ms_json.ToString());
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "幼儿伴侣提醒您!", "<script>alert('请填写完整信息!')</script>");
                    return;
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "幼儿伴侣提醒您!", "<script>alert('请先绑定设备!')</script>");
                return;
            }
        }
Пример #7
0
 /// <summary>
 /// 修改的单击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void But_xiugai_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Request.QueryString["id"]))
     {
         AlarmClocks acs = new AlarmClocks();
         acs.Id = Convert.ToInt32(Request.QueryString["id"]);
         if (Text_ClockTime.Value == "" || Text_ClockTime.Value == null)
         {
             Response.Write(" <script type=\"text/javascript\"> alert(\"请选择时间!\");</script>");
             return;
         }
         acs.ClockTime = Text_ClockTime.Value;
         string text = Convert.ToString(Drop_type.Text);
         if (text.Equals("自定义"))
         {
             if (Text_zidingyi.Text == null || Text_zidingyi.Text == "")
             {
                 acs.AlarmType = "自定义";
             }
             else
             {
                 acs.AlarmType = Text_zidingyi.Text;
             }
         }
         else
         {
             acs.AlarmType = text;
         }
         acs.Content = Text_content.Value;
         acs.Repeat  = Convert.ToString(Drop_repater.Text);
         int[] weekDay = new int[7];
         for (int i = 0; i < Chbke_Week.Items.Count; i++)
         {
             if (Chbke_Week.Items[i].Selected == true)
             {
                 weekDay[i] = 1;
             }
         }
         string weekStr = "";
         for (int i = 0; i < weekDay.Length; i++)
         {
             if (weekDay[i] == 1)
             {
                 weekStr += "1";
             }
             else
             {
                 weekStr += "0";
             }
             weekStr += ",";
         }
         weekStr.Remove(weekStr.Length - 1);
         //获取字符串长度
         int length = weekStr.Length;
         //截取除最后一位的前面所有字符
         weekStr        = weekStr.Substring(0, length - 1);
         acs.RepeatDate = weekStr;
         acs.State      = 1;
         acs.Frequency  = Convert.ToInt32(Drop_Frequency.SelectedValue);
         acs.Interval   = Convert.ToInt32(Drop_Interval.SelectedValue);
         string openId     = Convert.ToString(Session["OpenIdE"]);
         string xingeToken = QrChildManager.GetXingeToken(openId);   //得到token
         string DeviceId   = Context.Session["DeviceId"].ToString(); //根据得到的token拿到用户表的DeviceId
         if (AlarmClocksLogic.updateAlarm(acs))
         {
             string[] dts          = acs.ClockTime.Split(':');
             string   hour         = dts[0];
             string   mitner       = dts[1];
             JObject  content_json = new JObject();
             content_json.Add("flag", 2);
             content_json.Add("Id", acs.Id);
             content_json.Add("content", acs.AlarmType);
             content_json.Add("hour", hour);
             content_json.Add("mitner", mitner);
             content_json.Add("state", acs.State);
             content_json.Add("AlarmType", acs.Content);
             content_json.Add("Repeat", acs.Repeat);
             content_json.Add("weekStr", acs.RepeatDate);
             content_json.Add("Frequency", acs.Frequency);
             content_json.Add("Interval", acs.Interval);
             content_json.Add("DeviceId", DeviceId);
             JObject ms_json = new JObject();
             ms_json.Add("Title", "推送消息");
             ms_json.Add("Type", 13);
             ms_json.Add("OpenId", openId);
             ms_json.Add("Content", content_json);
             Response.Write(" <script type=\"text/javascript\"> alert(\"修改成功!\");</script>");
             Response.Write(" <script type=\"text/javascript\">  window.location.href =\" AlarmClock.aspx\"</script>");
             //string js = "{\"Title\":\"推送消息\",\"Type\":13,\"OpenId\":\"" + openId + "\",\"Content\":\"" + content_json.ToString() + "\"}";
             Message ms = new Message("幼儿伴侣", ms_json.ToString());
             JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
             string returnStr = XinGePush.PushMsg(xingeToken, jsonSerializer.Serialize(ms));
             //string returnStr = XinGePush.PushMsg(xingeToken, JsonConvert.SerializeObject(ms));
             JObject json = JObject.Parse(returnStr);
             returnStr = json["ret_code"].ToString();
         }
         else
         {
             Response.Write(" <script type=\"text/javascript\"> alert(\"修改失败!\");</script>");
             Response.Write(" <script type=\"text/javascript\"> history.go(-2);</script>");
         }
     }
     else
     //添加事件
     {
         AlarmClocks acs = new AlarmClocks();
         if (Text_ClockTime.Value == "" || Text_ClockTime.Value == null)
         {
             Response.Write(" <script type=\"text/javascript\"> alert(\"请选择时间!\");</script>");
             Response.Write(" <script type=\"text/javascript\"> history.go(-1);</script>");
             return;
         }
         acs.ClockTime = Text_ClockTime.Value;
         acs.Repeat    = Convert.ToString(Drop_repater.Text);
         string text = Convert.ToString(Drop_type.Text);
         if (text.Equals("自定义"))
         {
             if (Text_zidingyi.Text == null || Text_zidingyi.Text == "")
             {
                 acs.AlarmType = "自定义";
             }
             else
             {
                 acs.AlarmType = Text_zidingyi.Text;
             }
         }
         else
         {
             acs.AlarmType = text;
         }
         acs.Content = Text_content.Value;
         acs.State   = 1;
         int[] weekDay = new int[7];
         for (int i = 0; i < Chbke_Week.Items.Count; i++)
         {
             if (Chbke_Week.Items[i].Selected == true)
             {
                 weekDay[i] = 1;
             }
         }
         string weekStr = "";
         for (int i = 0; i < weekDay.Length; i++)
         {
             if (weekDay[i] == 1)
             {
                 weekStr += "1";
             }
             else
             {
                 weekStr += "0";
             }
             weekStr += ",";
         }
         weekStr.Remove(weekStr.Length - 1);
         //获取字符串长度
         int length = weekStr.Length;
         //截取除最后一位的前面所有字符
         weekStr        = weekStr.Substring(0, length - 1);
         acs.RepeatDate = weekStr;
         acs.Frequency  = Convert.ToInt32(Drop_Frequency.SelectedValue);
         acs.Interval   = Convert.ToInt32(Drop_Interval.SelectedValue);
         string openId     = Convert.ToString(Session["OpenIdE"]);
         string xingeToken = QrChildManager.GetXingeToken(openId);   //得到token
         string DeviceId   = Context.Session["DeviceId"].ToString(); //根据得到的token拿到用户表的DeviceId
         if (DeviceId != "" || DeviceId != null)
         {
             acs.DeviceId = DeviceId;
             int insertid = Convert.ToInt32(AlarmClocksLogic.insert_id(acs));
             if (insertid != 0)
             {
                 string[] dts          = acs.ClockTime.Split(':');
                 string   hour         = dts[0];
                 string   mitner       = dts[1];
                 JObject  content_json = new JObject();
                 content_json.Add("flag", 3);
                 content_json.Add("Id", insertid);
                 content_json.Add("hour", hour);
                 content_json.Add("content", acs.AlarmType);
                 content_json.Add("mitner", mitner);
                 content_json.Add("state", acs.State);
                 content_json.Add("AlarmType", acs.Content);
                 content_json.Add("Repeat", acs.Repeat);
                 content_json.Add("weekStr", acs.RepeatDate);
                 content_json.Add("Frequency", acs.Frequency);
                 content_json.Add("Interval", acs.Interval);
                 content_json.Add("DeviceId", DeviceId);
                 JObject ms_json = new JObject();
                 ms_json.Add("Title", "推送消息");
                 ms_json.Add("Type", 13);
                 ms_json.Add("OpenId", openId);
                 ms_json.Add("Content", content_json);
                 Response.Write(" <script type=\"text/javascript\"> alert(\"添加成功!\");</script>");
                 Response.Write(" <script type=\"text/javascript\"> window.location.href =\" AlarmClock.aspx\"</script>");
                 //string js = "{\"Title\":\"推送消息\",\"Type\":13,\"OpenId\":\"" + openId + "\",\"Content\":\"" + content_json.ToString() + "\"}";
                 Message ms = new Message("幼儿伴侣", ms_json.ToString());
                 JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                 string  returnStr = XinGePush.PushMsg(xingeToken, jsonSerializer.Serialize(ms));
                 JObject json      = JObject.Parse(returnStr);
                 returnStr = json["ret_code"].ToString();
             }
             else
             {
                 Response.Write(" <script type=\"text/javascript\"> alert(\"添加失败!\");</script>");
                 Response.Write(" <script type=\"text/javascript\"> history.go(-2);</script>");
             }
         }
         else
         {
             Response.Write(" <script type=\"text/javascript\"> alert(\"登录过期,请重新登录\");</script>");
             Response.Write(" <script type=\"text/javascript\"> history.go(-2);</script>");
         }
     }
 }