private void button1_Click(object sender, EventArgs e)
        {
            if (this.txtNodeID.Text.Length <= 0)
            {
                MessageBox.Show("请填写有效的节点ID!", "信息提示");
                return;
            }
            if (this.txtMaxTemp.Value < this.txtMinTemp.Value)
            {
                MessageBox.Show("最高温度小于最低温度!", "信息提示");
                return;
            }
            if (this.txtMaxHumunity.Value < this.txtMinHumunity.Value)
            {
                MessageBox.Show("最大湿度小于最小温度!", "信息提示");
                return;
            }

            ZigbeeNode zn = new ZigbeeNode(this.txtNodeID.Text,
                                           this.txtLocation.Text,
                                           this.txtMaxTemp.Value.ToString(), this.txtMinTemp.Value.ToString(),
                                           this.txtMaxHumunity.Value.ToString(), this.txtMinHumunity.Value.ToString());
            string jsonString = string.Empty;

            jsonString = JSON.Instance.ToJSON(zn);
            HttpWebConnect helper = new HttpWebConnect();

            helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_addZigbeeNodeInfo);

            string url = RestUrl.addZigbeeNode;

            helper.TryPostData(url, jsonString);
        }
        void helper_RequestCompleted_getZigbeeNode(object o)
        {
            deleControlInvoke dele = delegate(object ou)
            {
                string strZigbeeNode = (string)ou;
                Debug.WriteLine(
                    string.Format("Form1.helper_RequestCompleted_getZigbeeNode-> response = {0}"
                                  , strZigbeeNode));
                ZigbeeNode u2 = fastJSON.JSON.Instance.ToObject <ZigbeeNode>(strZigbeeNode);
                if (u2.state == "ok")
                {
                    txtNodeID.Text      = u2.node_id;
                    txtLocation.Text    = u2.location;
                    txtMaxTemp.Text     = u2.max_temp;
                    txtMinTemp.Text     = u2.min_temp;
                    txtMaxHumunity.Text = u2.max_humi;
                    txtMinHumunity.Text = u2.min_humi;
                }
                else
                {
                }
            };

            this.Invoke(dele, o);
        }
        void helper_RequestCompleted_addLedInfo(object o)
        {
            deleControlInvoke dele = delegate(object ou)
            {
                string strUser = (string)ou;
                Debug.WriteLine(
                    string.Format("Form1.helper_RequestCompleted_getProduct-> response = {0}"
                                  , strUser));
                ZigbeeNode u2 = fastJSON.JSON.Instance.ToObject <ZigbeeNode>(strUser);
                if (u2.state == "ok")
                {
                    MessageBox.Show("更新成功!");
                    //groupBox1.Enabled = false;
                    ControlStatus();
                    ClearControls();
                    refreshDGVProductDetail();
                }
                else
                {
                    MessageBox.Show("更新失败!");
                }
            };

            this.Invoke(dele, o);
        }
        void helper_RequestCompleted_getProduct(object o)
        {
            deleControlInvoke dele = delegate(object ou)
            {
                string strUser = (string)ou;
                Debug.WriteLine(
                    string.Format("Form1.helper_RequestCompleted_getProduct-> response = {0}"
                                  , strUser));
                ZigbeeNode u2 = fastJSON.JSON.Instance.ToObject <ZigbeeNode>(strUser);
                if (u2.state == "ok")
                {
                    MessageBox.Show("更新成功!");
                    //groupBox1.Enabled = false;
                    ControlStatus();
                    ClearControls();
                    //  pictureBox1.Image = Image.FromFile(path2 + PicturePath + u2.userPic);
                    //  pictureBox1.Image = Image.FromFile(u2.userPic);
                }
                else
                {
                    MessageBox.Show("更新失败!");
                }
            };

            this.Invoke(dele, o);


            //updateUserForm uuf = new updateUserForm();

            //uuf.ShowDialog();
        }
        void helper_RequestCompleted_getInfo(object o)
        {
            deleControlInvoke dele = delegate(object ou)
            {
                string strUser = (string)ou;
                Debug.WriteLine(
                    string.Format("Form1.helper_RequestCompleted_getProduct-> response = {0}"
                                  , strUser));
                ZigbeeNode u2 = fastJSON.JSON.Instance.ToObject <ZigbeeNode>(strUser);
                if (u2.state == "ok")
                {
                    textBox2.Text = u2.node_id;
                    textBox3.Text = u2.location;
                    textBox4.Text = u2.max_temp;
                    textBox5.Text = u2.min_temp;
                    textBox7.Text = u2.max_humi;
                    textBox8.Text = u2.min_humi;
                }
                else
                {
                }
            };

            this.Invoke(dele, o);
        }
Esempio n. 6
0
        void helper_RequestCompleted_addLedInfo(object o)

        {
            deleControlInvoke dele = delegate(object ou)
            {
                string strUser = (string)ou;
                Debug.WriteLine(
                    string.Format("Form1.helper_RequestCompleted_getProduct-> response = {0}"
                                  , strUser));
                ZigbeeNode u2 = fastJSON.JSON.Instance.ToObject <ZigbeeNode>(strUser);
                if (u2.state == "ok")
                {
                    frmControler f = (frmControler)this.Tag;
                    f.LoadAllZigbeeNodes();

                    MessageBox.Show("更新成功!");
                }
                else
                {
                    MessageBox.Show("更新失败!");
                }
            };

            this.Invoke(dele, o);
        }
Esempio n. 7
0
        void lbNodes_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbNodes.SelectedItem != null)
            {
                string     selectedNodeID = lbNodes.SelectedItem.ToString();
                ZigbeeNode zn             = new ZigbeeNode();
                zn.node_id = selectedNodeID;
                string jsonString = string.Empty;
                jsonString = JSON.Instance.ToJSON(zn);
                HttpWebConnect helper = new HttpWebConnect();
                helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_getZigbeeNode);

                string url = RestUrl.getZigbeeNode;
                helper.TryPostData(url, jsonString);
            }
        }
        void loadZigbeeNode(string id)
        {
            ZigbeeNode zn = new ZigbeeNode();

            zn.node_id = id;
            //LedInfo c = new LedInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "192.168.0.98");
            string jsonString = string.Empty;

            jsonString = JSON.Instance.ToJSON(zn);
            HttpWebConnect helper = new HttpWebConnect();

            helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_getZigbeeNode);
            //string url = RestUrl.addCommandInfo;

            string url = RestUrl.getZigbeeNode;

            helper.TryPostData(url, jsonString);
        }
        void frmupdatewareHouse_Shown(object sender, EventArgs e)
        {
            ZigbeeNode wH = new ZigbeeNode();

            wH.node_id = getEPC;
            //LedInfo c = new LedInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "192.168.0.98");
            string jsonString = string.Empty;

            jsonString = JSON.Instance.ToJSON(wH);
            HttpWebConnect helper = new HttpWebConnect();

            helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_getInfo);
            //string url = RestUrl.addCommandInfo;

            string url = RestUrl.getwareHouse;

            helper.TryPostData(url, jsonString);
        }
Esempio n. 10
0
        void helper_RequestCompleted_getZigbeeNode(object o)
        {
            deleControlInvoke dele = delegate(object ou)
            {
                string strZigbeeNode = (string)ou;
                Debug.WriteLine(
                    string.Format("Form1.helper_RequestCompleted_getZigbeeNode-> response = {0}"
                                  , strZigbeeNode));
                ZigbeeNode zn = fastJSON.JSON.Instance.ToObject <ZigbeeNode>(strZigbeeNode);
                if (zn.state == "ok")
                {
                    this.lblNodeID.Text      = zn.node_id;
                    this.lblLocation.Text    = zn.location;
                    this.lblMaxTemp.Text     = zn.max_temp;
                    this.lblMinTemp.Text     = zn.min_temp;
                    this.lblMaxHumunity.Text = zn.max_humi;
                    this.lblMinHumunity.Text = zn.min_humi;

                    this.current_node_id = zn.node_id;
                    try
                    {
                        this.current_min_hum  = int.Parse(zn.min_humi);
                        this.current_min_temp = int.Parse(zn.min_temp);
                        this.current_max_hum  = int.Parse(zn.max_humi);
                        this.current_max_temp = int.Parse(zn.max_temp);

                        this.progressHumunity.Maximum = int.Parse(zn.max_humi);
                        this.progressHumunity.Minimum = int.Parse(zn.min_humi);
                        this.progressTemp.Maximum     = int.Parse(zn.max_temp);
                        this.progressTemp.Minimum     = int.Parse(zn.min_temp);
                    }
                    catch
                    {
                    }
                }
                else
                {
                }
            };

            this.Invoke(dele, o);
        }
Esempio n. 11
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.txtNodeID.Text.Length <= 0)
            {
                MessageBox.Show("请选择要删除的节点!", "信息提示");
                return;
            }
            ZigbeeNode zn = new ZigbeeNode();

            zn.node_id = this.txtNodeID.Text;
            string jsonString = string.Empty;

            jsonString = JSON.Instance.ToJSON(zn);
            HttpWebConnect helper = new HttpWebConnect();

            helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_deleteZigbeeNodeInfo);

            string url = RestUrl.deleteZigbeeNode;

            helper.TryPostData(url, jsonString);
        }
Esempio n. 12
0
        void helper_RequestCompleted_deleteZigbeeNodeInfo(object o)
        {
            deleControlInvoke dele = delegate(object ou)
            {
                string strZigbeeNode = (string)ou;
                Debug.WriteLine(
                    string.Format("Form1.helper_RequestCompleted_deleteZigbeeNodeInfo-> response = {0}"
                                  , strZigbeeNode));
                ZigbeeNode u2 = fastJSON.JSON.Instance.ToObject <ZigbeeNode>(strZigbeeNode);
                if (u2.state == "ok")
                {
                    MessageBox.Show("删除成功!");
                    refreshDGVProductDetail();
                }
                else
                {
                    MessageBox.Show("删除出现异常!");
                }
            };

            this.Invoke(dele, o);
        }