Ejemplo n.º 1
0
        void helper_RequestCompleted(object o)
        {
            deleControlInvoke dele = delegate(object otag)
            {
                try
                {
                    tagID tag = (tagID)fastJSON.JSON.Instance.ToObject((string)otag, typeof(tagID));
                    this.lblStatus.Text = "发送标签 " + tag.tag + " 成功" + "  " + tag.startTime;
                    Debug.WriteLine("helper_RequestCompleted -> " + this.lblStatus.Text);

                    this.appendLog(this.lblStatus.Text);
                }
                catch (System.Exception ex)
                {
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        void helper_RequestCompleted_addzigbeeInfo(object o)
        {
            deleControlInvoke dele = delegate(object ou)
            {
                string strUser = (string)ou;
                Debug.WriteLine(
                    string.Format("Form1.helper_RequestCompleted_getProduct-> response = {0}"
                                  , strUser));
                zigbeeInfo u2 = fastJSON.JSON.Instance.ToObject <zigbeeInfo>(strUser);
                if (u2.state == "ok")
                {
                    Debug.WriteLine("OK");
                }
                else
                {
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 4
0
        void helper_RequestCompleted_getProduct(object o)
        {
            deleControlInvoke dele = delegate(object op)
            {
                string  strProduct = (string)op;
                Product p          = fastJSON.JSON.Instance.ToObject <Product>(strProduct);
                if (p.state == "ok")
                {
                    DataTable dt = null;
                    dt = (DataTable)dgvProductInfo.DataSource;
                    dt.Rows.Add(new object[] {
                        p.productID,
                        p.productName,
                        p.produceDate,
                        p.productCategory,
                        p.descript
                    });
                    foreach (DataGridViewRow vr in this.dgvProductInfo.Rows)
                    {
                        DataGridViewCell cepc = (DataGridViewCell)vr.Cells[1];
                        if (((string)cepc.Value) == p.productID)
                        {
                            DataGridViewCheckBoxCell cbc = (DataGridViewCheckBoxCell)vr.Cells[0];

                            cbc.Value = LightStatus.Unknown;
                            int ncrtMore = int.Parse(this.lblMore.Text);
                            this.lblMore.Text = (ncrtMore + 1).ToString();
                            break;
                        }
                    }
                }
                else
                {
                    Debug.WriteLine(
                        string.Format("frmInventory.helper_RequestCompleted_getProduct  ->  = {0}"
                                      , "获取产品信息失败!"));
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 5
0
        void helper_RequestCompleted_getProductInfoForInventoryList(object o)
        {
            deleControlInvoke dele = delegate(object oProductList)
            {
                string strProduct = (string)oProductList;
                object olist      = fastJSON.JSON.Instance.ToObjectListDic(strProduct);
                this.listView1.Items.Clear();
                ArrayList array = (ArrayList)olist;
                for (int i = 0; i < array.Count; i++)
                {
                    Dictionary <string, object> dicTemp = (Dictionary <string, object>)array[i];
                    Product p = Product.createInstance(dicTemp);
                    System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem();
                    listViewItem1.Text = p.productID;
                    listViewItem1.SubItems.Add(p.productName);
                    this.listView1.Items.Add(listViewItem1);
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 6
0
        void helper_RequestCompleted_getScanTags(object o)
        {
            string            strTags = (string)o;
            object            olist   = fastJSON.JSON.Instance.ToObjectList(strTags, typeof(List <tagID>), typeof(tagID));
            deleControlInvoke dele    = delegate(object ol)
            {
                List <tagID> tagList = (List <tagID>)ol;
                if (tagList.Count > 0)
                {
                    tagID t = tagList[tagList.Count - 1];
                    this.__lastTagTimeStamp = t.startTime;
                    for (int i = 0; i < tagList.Count; i++)
                    {
                        tagID temp = tagList[i];
                        LinkEPCToProduct(temp.tag);
                    }
                }
            };

            this.Invoke(dele, olist);
        }
Ejemplo n.º 7
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));
                CommandInfo u2 = fastJSON.JSON.Instance.ToObject <CommandInfo>(strUser);
                if (u2.state == "ok")
                {
                    MessageBox.Show("更新成功!");
                }
                else
                {
                    MessageBox.Show("更新失败!");
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        void helper_RequestCompleted_add_category(object o)
        {
            string strres = (string)o;

            Debug.WriteLine(
                string.Format("helper_RequestCompleted_get_syc_list  ->  = {0}"
                              , strres));
            try
            {
                ProductCategory p = (ProductCategory)fastJSON.JSON.Instance.ToObject(strres, typeof(ProductCategory));
                if (p.state == "ok")
                {
                    deleControlInvoke dele = delegate
                    {
                        this.lblStatus.Text = "添加成功";
                    };
                    this.Invoke(dele, o);
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Ejemplo n.º 10
0
        void helper_RequestCompleted_get_category_list(object o)
        {
            string strres = (string)o;

            Debug.WriteLine(
                string.Format("helper_RequestCompleted_get_syc_list  ->  = {0}"
                              , strres));
            object            olist = fastJSON.JSON.Instance.ToObjectList(strres, typeof(List <ProductCategory>), typeof(ProductCategory));
            deleControlInvoke dele  = delegate(object ol)
            {
                List <ProductCategory> resList = (List <ProductCategory>)ol;
                if (resList.Count > 0)
                {
                    for (int i = 0; i < resList.Count; i++)
                    {
                        this.listBox1.Items.Add(resList[i].category_id + "    " + resList[i].category_name);
                        this.categoryList.Add(resList[i]);
                    }
                }
            };

            this.Invoke(dele, olist);
        }
Ejemplo n.º 11
0
        void helper_RequestCompleted_delete(object o)
        {
            string strProduct = (string)o;

            Debug.WriteLine(
                string.Format("frmProductManageAdd.helper_RequestCompleted_delete-> response = {0}"
                              , strProduct));
            Product           u2   = fastJSON.JSON.Instance.ToObject <Product>(strProduct);
            deleControlInvoke dele = delegate(object op)
            {
                Product p = (Product)op;
                if (p.state == "ok")
                {
                    MessageBox.Show("删除产品信息成功!");
                    this.refreshDGV();
                }
                else
                {
                    MessageBox.Show("删除产品信息出错!");
                }
            };

            this.Invoke(dele, u2);
        }
Ejemplo n.º 12
0
        void helper_RequestCompleted_getScanTags(object o)
        {
            string strTags = (string)o;

            Debug.WriteLine(
                string.Format("frmInventory.helper_RequestCompleted_getScanTags  ->  = {0}"
                              , strTags));
            object            olist = fastJSON.JSON.Instance.ToObjectList(strTags, typeof(List <tagID>), typeof(tagID));
            deleControlInvoke dele  = delegate(object ol)
            {
                List <tagID> tagList = (List <tagID>)ol;
                if (tagList.Count > 0)
                {
                    tagID t = tagList[tagList.Count - 1];
                    for (int i = 0; i < tagList.Count; i++)
                    {
                        tagID temp = tagList[i];
                        LinkEPCToProduct(temp.tag);
                    }
                }
            };

            this.Invoke(dele, olist);
        }
Ejemplo n.º 13
0
        //通过网络读取到命令后,对命令进行解析
        void __httpHelper_RequestCompleted_getCommand(object o)
        {
            deleControlInvoke dele = delegate(object oc)
            {
                string cmds = (string)oc;
                if (cmds == "timeout")
                {
                    Debug.WriteLine(
                        string.Format("frmMain.__httpHelper_RequestCompleted_getCommand  ->  = {0}"
                                      , cmds));
                    this.setup_to_get_command(null, null);
                    return;
                }
                if (this.bRunning == false)
                {
                    return;
                }
                Debug.WriteLine(
                    string.Format("frmMain.__httpHelper_RequestCompleted_getCommand  ->  = {0}"
                                  , cmds));
                int index = cmds.IndexOf("[");
                if (index >= 0)
                {
                    cmds = cmds.Substring(index);
                }
                else
                {
                    return;
                }
                //this.appendLog(cmds);
                // return;
                object olist = fastJSON.JSON.Instance.ToObjectList(cmds, typeof(List <CommandInfo>), typeof(CommandInfo));
                foreach (CommandInfo c in (List <CommandInfo>)olist)
                {
                    if (string.Compare(this.lastUpdateTimeStamp, c.timeStamp, true) < 0)//如果命令的时间较晚
                    {
                        this.lastUpdateTimeStamp = c.timeStamp;
                    }
                    switch (c.name)
                    {
                    case "tts":
                        Debug.WriteLine(
                            string.Format("frmMain.获取到tts发布信息,内容为  -> tts = {0}   {1}"
                                          , c.info, c.timeStamp));

                        this.appendLog(string.Format("获取到tts发布信息,内容为 {0} {1}", c.info, c.timeStamp));
                        if (this.ckbtts.Checked)
                        {
                            bool bAlreadyExist = false;
                            Manualstate.WaitOne();
                            Manualstate.Reset();

                            string strSelect = string.Format("type = '{0}' and info = '{1}' and time = '{2}'",
                                                             c.name, c.info, c.timeStamp);
                            DataRow[] rows = __dtCommandInfo.Select(strSelect);
                            if (rows.Length > 0)    //说明
                            {
                                bAlreadyExist = true;
                            }
                            else
                            {
                                Debug.WriteLine("添加新行到表中 " + strSelect);
                                __dtCommandInfo.Rows.Add(new object[] {
                                    c.name, c.info, c.ledIP, c.timeStamp, "new"
                                });
                            }

                            Manualstate.Set();

                            if (bAlreadyExist == false)
                            {
                                _synth_SpeakCompleted(null, null);
                            }
                        }

                        break;

                    case "led":
                        //发现新的led信息,需要发送到相应的led屏上
                        Debug.WriteLine(
                            string.Format("frmMain.__httpHelper_RequestCompleted_getCommand  -> led = {0}    {1}  {2}"
                                          , c.ledIP, c.info, c.timeStamp));
                        c.ledIP = "172.16.13.99";
                        this.appendLog(string.Format("获取到led发布信息,ip为 {0}   内容为 {1}  {2}", c.ledIP, c.info, c.timeStamp));
                        if (this.ckbled.Checked)
                        {
                            try
                            {
                                this.sendMsgToLED(c.ledIP, c.info);
                            }
                            catch (System.Exception ex)
                            {
                                appendLog("发送到LED屏时发生异常:" + ex.Message);
                            }
                        }

                        break;
                    }
                }
                this.setup_to_get_command(null, null);
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 14
0
        void handle_event()
        {
            IntelligentEvent evt = MiddleWareCore.get_a_event();

            if (evt != null)
            {
                deleControlInvoke dele = delegate(object o)
                {
                    IntelligentEvent p              = (IntelligentEvent)o;
                    string           epcID          = p.epcID;
                    string           remoteDeviceID = p.remoteDeviceID;
                    string           check_time     = p.time_stamp;
                    string           studentName    = string.Empty;
                    string           question_value = p.questionValue;
                    DataRow[]        rows           = null;
                    DataRow[]        rowsMap        = null;
                    int totalCount = this.studentInfoTable.Rows.Count;

                    rows    = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                    rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
                    if (rows.Length > 0 && rowsMap.Length > 0)//有该用户资料和设备资料
                    {
                        string answer     = question_value;
                        int    groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString());
                        studentName = (string)rows[0]["NAME"];
                        Carbinet _carbinet = this.groups[groupIndex];

                        //if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0)
                        //{
                        //    _carbinet.setDocText(remoteDeviceID, studentName);

                        //}
                        //else
                        //{
                        if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0)
                        {
                            //这里要处理一下同一个学生用不一个设备发送答案的情况
                            DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + epcID + "'");
                            int       groupIndex2      = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString());
                            Carbinet  _carbinet2       = this.groups[groupIndex2];
                            _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], (Image)global::Carbinet.Properties.Resources.grey);
                            _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], "");
                            rowsForDuplicate[0]["studenID"] = "";
                        }
                        //}

                        _carbinet.setDocText(remoteDeviceID, studentName);

                        rowsMap[0]["studenID"] = epcID;


                        if (answer == "A")
                        {
                            rows[0]["answer"] = "A";
                            // _carbinet.setDocBGColor(data.equipmentID, this.clrA);
                            _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.grey);
                        }
                        if (answer == "B")
                        {
                            _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.blue);
                            rows[0]["answer"] = "B";
                        }
                        if (answer == "C")
                        {
                            rows[0]["answer"] = "C";
                            _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.yellow);
                            //_carbinet.setDocBGColor(data.equipmentID, this.clrC);
                        }
                        if (answer == "D")
                        {
                            rows[0]["answer"] = "D";
                            _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.orange);
                            //_carbinet.setDocBGColor(data.equipmentID, this.clrD);
                        }
                        if (answer == "E")
                        {
                            rows[0]["answer"] = "E";
                            _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.purple);
                        }

                        DataRow[] rowsA = this.studentInfoTable.Select("answer = 'A'");
                        DataRow[] rowsB = this.studentInfoTable.Select("answer = 'B'");
                        DataRow[] rowsC = this.studentInfoTable.Select("answer = 'C'");
                        DataRow[] rowsD = this.studentInfoTable.Select("answer = 'D'");
                        DataRow[] rowsE = this.studentInfoTable.Select("answer = 'E'");
                        int       iA    = rowsA.Length;
                        int       iB    = rowsB.Length;
                        int       iC    = rowsC.Length;
                        int       iD    = rowsD.Length;
                        int       iE    = rowsE.Length;
                        //int iUnknown = totalCount - iA - iB - iC - iD - iE;
                        m_panelDrawing.Values = new decimal[] { iA, iB, iC, iD, iE };
                        string strA = "", strB = "", strC = "", strD = "", strUnknown = "", strE = "";

                        //if (iUnknown > 0)
                        //{
                        //    strUnknown = (iUnknown * 100 / totalCount).ToString() + "%";
                        //}
                        if (iA > 0)
                        {
                            strA = (iA * 100 / totalCount).ToString() + "%";
                        }
                        if (iB > 0)
                        {
                            strB = (iB * 100 / totalCount).ToString() + "%";
                        }
                        if (iC > 0)
                        {
                            strC = (iC * 100 / totalCount).ToString() + "%";
                        }
                        if (iD > 0)
                        {
                            strD = (iD * 100 / totalCount).ToString() + "%";
                        }
                        if (iE > 0)
                        {
                            strD = (iE * 100 / totalCount).ToString() + "%";
                        }
                        m_panelDrawing.Texts = new string[] { strA, strB, strC, strD, strE };
                    }
                };

                this.Invoke(dele, evt);
            }
        }
Ejemplo n.º 15
0
        void handle_event()
        {
            IntelligentEvent evt = MiddleWareCore.get_a_event();

            if (evt != null)
            {
                deleControlInvoke dele = delegate(object o)
                {
                    IntelligentEvent p              = (IntelligentEvent)o;
                    string           epcID          = p.epcID;
                    string           remoteDeviceID = p.remoteDeviceID;
                    string           check_time     = p.time_stamp;
                    string           studentName    = string.Empty;
                    DataRow[]        rows           = null;

                    bool bRefresh_ui = false;
                    if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0)//重复考勤
                    {
                        //考勤数据不需要更新,但是显示页面需要更新
                        rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                        if (rows.Length > 0)
                        {
                            rows[0]["status"]    = "1";
                            rows[0]["checkTime"] = check_time;
                            studentName          = (string)rows[0]["NAME"];
                        }

                        rows = this.mapConfigsTable.Select("studenID = '" + epcID + "'");
                        if (rows.Length > 0)
                        {
                            //此时需要将之前设为考勤状态的位置变回未考勤状态
                            int      groupIndex = int.Parse(rows[0]["IGROUP"].ToString());
                            Carbinet _carbinet  = this.groups[groupIndex];
                            _carbinet.setDocBGImage((string)rows[0]["EQUIPEMNTID"], (Image)global::Carbinet.Properties.Resources.grey);
                            _carbinet.setDocText((string)rows[0]["EQUIPEMNTID"], "");
                            rows[0]["studenID"] = "";
                        }
                        bRefresh_ui = true;
                    }
                    if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0)//第一次考勤
                    {
                        //处理该事件需要更新学生考勤数据和显示页面

                        //更新考勤信息
                        //rows = this.checkTable.Select("equipmentID = '" + data.equipmentID + "'");
                        //根据接收到的信息,首先将学生出勤状态置为 1,之后将控件的显示状态改为绿色
                        if (string.Compare(this.dtStart, check_time) <= 0)
                        {
                            rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                            if (rows.Length > 0)
                            {
                                rows[0]["status"]    = "1";
                                rows[0]["checkTime"] = check_time;
                                studentName          = (string)rows[0]["NAME"];
                            }
                            bRefresh_ui = true;
                        }
                    }
                    if (bRefresh_ui == true)
                    {
                        rows = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
                        if (rows.Length > 0)
                        {
                            rows[0]["studenID"] = epcID;
                            int groupIndex = int.Parse(rows[0]["IGROUP"].ToString());
                            //界面展示
                            Carbinet _carbinet = this.groups[groupIndex];
                            //_carbinet.setDocBGColor(data.equipmentID, Color.Green);
                            _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.orange);
                            _carbinet.setDocText(remoteDeviceID, studentName);

                            // 查找考勤与未考勤的学生的数量,显示在饼图上
                            rows = this.studentInfoTable.Select("status = '1'");
                            int checkedCount   = rows.Length;
                            int uncheckedCount = this.studentInfoTable.Rows.Count - checkedCount;
                            Debug.WriteLine(
                                string.Format("Form1.updateStatus  -> checked = {0} unchecked = {1}"
                                              , checkedCount, uncheckedCount));
                            //m_panelDrawing.Values = new decimal[] { uncheckedCount, checkedCount };
                            string strchecked = "", strUnchecked = "";
                            if (checkedCount > 0)
                            {
                                strchecked = (checkedCount / (checkedCount + uncheckedCount)).ToString() + "%";
                            }
                            if (uncheckedCount > 0)
                            {
                                strUnchecked = (uncheckedCount / (checkedCount + uncheckedCount)).ToString() + "%";
                            }
                        }
                    }
                };

                this.Invoke(dele, evt);
            }
        }
Ejemplo n.º 16
0
        //通过网络读取到命令后,对命令进行解析
        void __httpHelper_RequestCompleted_getCommand(object o)
        {
            deleControlInvoke dele = delegate(object oc)
            {
                string cmds = (string)oc;
                Debug.WriteLine(
                    string.Format("frmMain.__httpHelper_RequestCompleted_getCommand  ->  = {0}"
                                  , cmds));
                int index = cmds.IndexOf("[");
                if (index >= 0)
                {
                    cmds = cmds.Substring(index);
                }
                else
                {
                    return;
                }
                //this.appendLog(cmds);
                // return;
                object olist = fastJSON.JSON.Instance.ToObjectList(cmds, typeof(List <CommandInfo>), typeof(CommandInfo));
                foreach (CommandInfo c in (List <CommandInfo>)olist)
                {
                    if (string.Compare(this.lastUpdateTimeStamp, c.startTime, true) < 0)//如果命令的时间较晚
                    {
                        this.lastUpdateTimeStamp = c.startTime;
                    }
                    switch (c.commandName)
                    {
                    case "tts":
                        Debug.WriteLine(
                            string.Format("frmMain.获取到tts发布信息,内容为  -> tts = {0}   {1}"
                                          , c.info, c.startTime));

                        this.appendLog(string.Format("获取到tts发布信息,内容为 {0} {1}", c.info, c.startTime));
                        bool bAlreadyExist = false;
                        Manualstate.WaitOne();
                        Manualstate.Reset();

                        string strSelect = string.Format("type = '{0}' and info = '{1}' and time = '{2}'",
                                                         c.commandName, c.info, c.startTime);
                        DataRow[] rows = __dtCommandInfo.Select(strSelect);
                        if (rows.Length > 0)    //说明
                        {
                            bAlreadyExist = true;
                        }
                        else
                        {
                            Debug.WriteLine("添加新行到表中 " + strSelect);
                            __dtCommandInfo.Rows.Add(new object[] {
                                c.commandName, c.info, c.ledIP, c.startTime, "new"
                            });
                        }
                        //foreach (CommandInfo ci in listToSpeak)
                        //{
                        //    if (ci.info == c.info && c.startTime == ci.startTime)
                        //    {
                        //        bAlreadyExist = true;
                        //        break;
                        //    }
                        //}
                        //if (bAlreadyExist == false)
                        //{
                        //    this.listToSpeak.Add(c);
                        //}
                        Manualstate.Set();

                        //_synth.SpeakAsync(c.info);
                        if (bAlreadyExist == false)
                        {
                            _synth_SpeakCompleted(null, null);
                        }
                        break;

                    case "led":
                        //发现新的led信息,需要发送到相应的led屏上
                        Debug.WriteLine(
                            string.Format("frmMain.__httpHelper_RequestCompleted_getCommand  -> led = {0}    {1}  {2}"
                                          , c.ledIP, c.info, c.startTime));
                        this.appendLog(string.Format("获取到led发布信息,ip为 {0}   内容为 {1}  {2}", c.ledIP, c.info, c.startTime));
                        try
                        {
                            this.sendMsgToLED(c.ledIP, c.info);
                        }
                        catch (System.Exception ex)
                        {
                            appendLog("发送到LED屏时发生异常:" + ex.Message);
                        }
                        break;
                    }
                }
                #region old code
                //object olist = fastJSON.JSON.Instance.ToObjectList(cmds, typeof(List<LedInfo>), typeof(LedInfo));
                //foreach (LedInfo c in (List<LedInfo>)olist)
                //{
                //    if (string.Compare(this.lastUpdateTimeStamp, c.startTime, true) < 0)//如果命令的时间较晚
                //    {
                //        this.lastUpdateTimeStamp = c.startTime;
                //    }
                //    //发现新的led信息,需要发送到相应的led屏上
                //    Debug.WriteLine(
                //        string.Format("frmMain.__httpHelper_RequestCompleted_getCommand  ->  = {0}    {1}"
                //        , c.ledIP, c.info));
                //    this.appendLog(string.Format("获取到led发布信息,ip为 {0}   内容为 {1}", c.ledIP, c.info));

                //    this.sendMsgToLED(c.ledIP, c.info);
                //}
                #endregion
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 17
0
        void handle_event()
        {
            IntelligentEvent evt = MiddleWareCore.get_a_event();

            if (evt != null)
            {
                deleControlInvoke dele = delegate(object o)
                {
                    IntelligentEvent p              = (IntelligentEvent)o;
                    string           epcID          = p.epcID;
                    string           remoteDeviceID = p.remoteDeviceID;
                    string           check_time     = p.time_stamp;
                    string           studentName    = string.Empty;
                    string           question_value = p.questionValue;
                    DataRow[]        rows           = null;
                    DataRow[]        rowsMap        = null;
                    DataRow[]        rowsUnknown    = null;
                    int totalCount = this.studentInfoTable.Rows.Count;

                    //如果只是重复发送,不需要做什么
                    if (p.event_unit_list.IndexOf(IntelligentEventUnit.repeat_epc) >= 0)
                    {
                        //如果重复发送之外,还改变了设备的ID
                        if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0)
                        {
                            rows    = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                            rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
                            if (rows.Length > 0 && rowsMap.Length > 0)
                            {
                                string answer     = question_value;
                                int    groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString());
                                studentName = (string)rows[0]["NAME"];

                                Carbinet _carbinet = this.groups[groupIndex];
                                _carbinet.setDocText(remoteDeviceID, studentName);

                                //这里要处理一下同一个学生用不一个设备发送答案的情况
                                // 根据就是每一次客户端发送信息时,服务端都要把发送过来的标签和设备重新绑定一次
                                // 如果之前绑定过并且和现在的不同,则说明该标签之前用别的设备发送过信息
                                DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + epcID + "'");
                                if (rowsForDuplicate.Length > 0)//说明已经有过对应,将原来设置的回答状态和学生姓名从座位上去掉
                                {
                                    //if (((string)rowsForDuplicate[0]["EQUIPEMNTID"]) != remoteDeviceID)//根据设备和根据学号找的记录不一样,肯定有重复
                                    {
                                        int      groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString());
                                        Carbinet _carbinet2  = this.groups[groupIndex2];
                                        _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], imgNormal);
                                        _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], "");
                                        rowsForDuplicate[0]["studenID"] = "";
                                    }
                                }

                                rowsMap[0]["studenID"] = epcID;                       //这里把设备和标签绑定到一起
                                _carbinet.setDocBGImage(remoteDeviceID, imgAnswered);
                                _carbinet.setDocText(remoteDeviceID, question_value); //在座位上显示答案
                            }
                        }
                        //如果重复发送之外,还改变了问题的答案
                        if (p.event_unit_list.IndexOf(IntelligentEventUnit.change_answer) >= 0)
                        {
                            rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                            if (rows.Length > 0)
                            {
                                rows[0]["answer"] = question_value;
                            }
                            //更新答题记录
                            rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = {1}", epcID, current_question_id));
                            if (rows.Length > 0)
                            {
                                rows[0]["answer"] = question_value;
                            }
                            else
                            {
                                dtQuestion_answer_record.Rows.Add(new object[3] {
                                    epcID, current_question_id, question_value
                                });
                            }
                        }
                    }
                    else
                    if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0)
                    {
                        //处理该事件需要更新数据和显示页面
                        rows    = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                        rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
                        if (rows.Length > 0 && rowsMap.Length > 0)
                        {
                            string answer     = question_value;
                            int    groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString());
                            studentName = (string)rows[0]["NAME"];

                            Carbinet _carbinet = this.groups[groupIndex];
                            //_carbinet.setDocText(remoteDeviceID, studentName);//在座位上显示学生名字
                            _carbinet.setDocText(remoteDeviceID, question_value); //在座位上显示答案

                            rowsMap[0]["studenID"] = epcID;                       //这里把设备和标签绑定到一起
                            _carbinet.setDocBGImage(remoteDeviceID, imgAnswered);
                            rows[0]["answer"] = question_value;

                            /*
                             * if (answer == "A")
                             * {
                             *  rows[0]["answer"] = "A";
                             *  // _carbinet.setDocBGColor(data.equipmentID, this.clrA);
                             *  //_carbinet.setDocBGImage(data.equipmentID, imgA);
                             * }
                             * if (answer == "B")
                             * {
                             *  //_carbinet.setDocBGImage(data.equipmentID, imgB);
                             *  rows[0]["answer"] = "B";
                             * }
                             * if (answer == "C")
                             * {
                             *  rows[0]["answer"] = "C";
                             *  //_carbinet.setDocBGImage(data.equipmentID, imgC);
                             *  //_carbinet.setDocBGColor(data.equipmentID, this.clrC);
                             * }
                             * if (answer == "D")
                             * {
                             *  rows[0]["answer"] = "D";
                             *  //_carbinet.setDocBGImage(data.equipmentID, imgD);
                             *  //_carbinet.setDocBGColor(data.equipmentID, this.clrD);
                             * }
                             * //*/
                            //设置饼图
                            rowsUnknown = this.studentInfoTable.Select("answer = ''");
                            int    iUnknown    = rowsUnknown.Length;
                            int    iAnswered   = totalCount - iUnknown;
                            string strUnknown  = iUnknown.ToString();
                            string strAnswered = iAnswered.ToString();
                            m_panelDrawing.Values = new decimal[] { iUnknown, iAnswered };
                            m_panelDrawing.Texts  = new string[] { iUnknown.ToString(), iAnswered.ToString() };
                        }

                        //更新答题记录
                        rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = '{1}'", epcID, current_question_id));
                        if (rows.Length > 0)
                        {
                            rows[0]["answer"] = question_value;
                        }
                        else
                        {
                            dtQuestion_answer_record.Rows.Add(new object[3] {
                                epcID, current_question_id, question_value
                            });
                        }
                    }
                    //switch (p.name)
                    //{
                    //    case IntelligentEvent.class_question_repeat_answer:
                    //        //考勤数据和显示页面都不需要更新,
                    //        break;
                    //    case IntelligentEvent.class_question_new_answer:
                    //        //处理该事件需要更新数据和显示页面
                    //        rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                    //        rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
                    //        if (rows.Length > 0 && rowsMap.Length > 0)
                    //        {
                    //            string answer = question_value;
                    //            int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString());
                    //            studentName = (string)rows[0]["NAME"];

                    //            Carbinet _carbinet = this.groups[groupIndex];
                    //            _carbinet.setDocText(remoteDeviceID, studentName);

                    //            rowsMap[0]["studenID"] = epcID;//这里把设备和标签绑定到一起
                    //            _carbinet.setDocBGImage(remoteDeviceID, imgAnswered);
                    //            ///*
                    //            if (answer == "A")
                    //            {
                    //                rows[0]["answer"] = "A";
                    //                // _carbinet.setDocBGColor(data.equipmentID, this.clrA);
                    //                //_carbinet.setDocBGImage(data.equipmentID, imgA);
                    //            }
                    //            if (answer == "B")
                    //            {
                    //                //_carbinet.setDocBGImage(data.equipmentID, imgB);
                    //                rows[0]["answer"] = "B";
                    //            }
                    //            if (answer == "C")
                    //            {
                    //                rows[0]["answer"] = "C";
                    //                //_carbinet.setDocBGImage(data.equipmentID, imgC);
                    //                //_carbinet.setDocBGColor(data.equipmentID, this.clrC);
                    //            }
                    //            if (answer == "D")
                    //            {
                    //                rows[0]["answer"] = "D";
                    //                //_carbinet.setDocBGImage(data.equipmentID, imgD);
                    //                //_carbinet.setDocBGColor(data.equipmentID, this.clrD);
                    //            }
                    //            //*/
                    //            //设置饼图
                    //            rowsUnknown = this.studentInfoTable.Select("answer = ''");
                    //            int iUnknown = rowsUnknown.Length;
                    //            int iAnswered = totalCount - iUnknown;
                    //            string strUnknown = iUnknown.ToString();
                    //            string strAnswered = iAnswered.ToString();
                    //            m_panelDrawing.Values = new decimal[] { iUnknown, iAnswered };
                    //            m_panelDrawing.Texts = new string[] { iUnknown.ToString(), iAnswered.ToString() };

                    //        }

                    //        //更新答题记录
                    //        rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = '{1}'", epcID, current_question_id));
                    //        if (rows.Length > 0)
                    //        {
                    //            rows[0]["answer"] = question_value;
                    //        }
                    //        else
                    //        {
                    //            dtQuestion_answer_record.Rows.Add(new object[3] { epcID, current_question_id, question_value });
                    //        }
                    //        break;
                    //    case IntelligentEvent.class_question_repeat_answer_on_another_device:
                    //        //数据不需要更新,但是显示页面需要更新
                    //        rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                    //        rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
                    //        if (rows.Length > 0 && rowsMap.Length > 0)
                    //        {
                    //            string answer = question_value;
                    //            int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString());
                    //            studentName = (string)rows[0]["NAME"];

                    //            Carbinet _carbinet = this.groups[groupIndex];
                    //            _carbinet.setDocText(remoteDeviceID, studentName);

                    //            //这里要处理一下同一个学生用不一个设备发送答案的情况
                    //            // 根据就是每一次客户端发送信息时,服务端都要把发送过来的标签和设备重新绑定一次
                    //            // 如果之前绑定过并且和现在的不同,则说明该标签之前用别的设备发送过信息
                    //            DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + epcID + "'");
                    //            if (rowsForDuplicate.Length > 0)//说明已经有过对应
                    //            {
                    //                //if (((string)rowsForDuplicate[0]["EQUIPEMNTID"]) != remoteDeviceID)//根据设备和根据学号找的记录不一样,肯定有重复
                    //                {
                    //                    int groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString());
                    //                    Carbinet _carbinet2 = this.groups[groupIndex2];
                    //                    _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], imgNormal);
                    //                    _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], "");
                    //                    rowsForDuplicate[0]["studenID"] = "";
                    //                }
                    //            }

                    //            rowsMap[0]["studenID"] = epcID;//这里把设备和标签绑定到一起
                    //            _carbinet.setDocBGImage(remoteDeviceID, imgAnswered);

                    //        }
                    //        break;
                    //    case IntelligentEvent.class_question_change_answer:
                    //        rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                    //        if (rows.Length > 0)
                    //        {
                    //            string answer = question_value;

                    //            ///*
                    //            if (answer == "A")
                    //            {
                    //                rows[0]["answer"] = "A";
                    //            }
                    //            if (answer == "B")
                    //            {
                    //                rows[0]["answer"] = "B";
                    //            }
                    //            if (answer == "C")
                    //            {
                    //                rows[0]["answer"] = "C";
                    //            }
                    //            if (answer == "D")
                    //            {
                    //                rows[0]["answer"] = "D";
                    //            }

                    //        }
                    //        //更新答题记录
                    //        rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = {1}", epcID, current_question_id));
                    //        if (rows.Length > 0)
                    //        {
                    //            rows[0]["answer"] = question_value;
                    //        }
                    //        else
                    //        {
                    //            dtQuestion_answer_record.Rows.Add(new object[3] { epcID, current_question_id, question_value });
                    //        }
                    //        break;
                    //    case IntelligentEvent.class_question_change_answer_on_another_device:
                    //        rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                    //        rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
                    //        if (rows.Length > 0 && rowsMap.Length > 0)
                    //        {
                    //            string answer = question_value;
                    //            int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString());
                    //            studentName = (string)rows[0]["NAME"];

                    //            Carbinet _carbinet = this.groups[groupIndex];
                    //            _carbinet.setDocText(remoteDeviceID, studentName);

                    //            //这里要处理一下同一个学生用不一个设备发送答案的情况
                    //            // 根据就是每一次客户端发送信息时,服务端都要把发送过来的标签和设备重新绑定一次
                    //            // 如果之前绑定过并且和现在的不同,则说明该标签之前用别的设备发送过信息
                    //            DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + epcID + "'");
                    //            if (rowsForDuplicate.Length > 0)//说明已经有过对应
                    //            {
                    //                int groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString());
                    //                Carbinet _carbinet2 = this.groups[groupIndex2];
                    //                _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], imgNormal);
                    //                _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], "");
                    //                rowsForDuplicate[0]["studenID"] = "";
                    //            }


                    //            rowsMap[0]["studenID"] = epcID;//这里把设备和标签绑定到一起
                    //            _carbinet.setDocBGImage(remoteDeviceID, imgAnswered);

                    //            if (answer == "A")
                    //            {
                    //                rows[0]["answer"] = "A";
                    //            }
                    //            if (answer == "B")
                    //            {
                    //                rows[0]["answer"] = "B";
                    //            }
                    //            if (answer == "C")
                    //            {
                    //                rows[0]["answer"] = "C";
                    //            }
                    //            if (answer == "D")
                    //            {
                    //                rows[0]["answer"] = "D";
                    //            }

                    //        }
                    //        //更新答题记录
                    //        rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = {1}", epcID, current_question_id));
                    //        if (rows.Length > 0)
                    //        {
                    //            rows[0]["answer"] = question_value;
                    //        }
                    //        else
                    //        {
                    //            dtQuestion_answer_record.Rows.Add(new object[3] { epcID, current_question_id, question_value });
                    //        }
                    //        break;
                    //}
                };

                this.Invoke(dele, evt);
            }
        }
Ejemplo n.º 18
0
        void helper_RequestCompleted_getproducingProduct(object o)
        {
            deleControlInvoke dele = delegate(object oProductList)
            {
                string strProduct = (string)oProductList;
                object olist      = fastJSON.JSON.Instance.ToObjectList(strProduct, typeof(List <Product>), typeof(Product));


                System.Data.DataTable dt = null;
                if (this.dv1.DataSource == null)
                {
                    dt = new System.Data.DataTable();
                    dt.Columns.Add("产品编码", typeof(string));
                    dt.Columns.Add("产品名称", typeof(string));
                    dt.Columns.Add("产品类型", typeof(string));
                    dt.Columns.Add("产品规格", typeof(string));
                    dt.Columns.Add("生产状态", typeof(string));
                    dt.Columns.Add("完成时间", typeof(string));
                    dt.Columns.Add("生产批次", typeof(string));
                    dt.Columns.Add("生产车间", typeof(string));
                    dt.Columns.Add("生产负责人", typeof(string));
                    dt.Columns.Add("联系方式", typeof(string));
                    dt.Columns.Add("生产温度", typeof(string));
                    dt.Columns.Add("生产湿度", typeof(string));
                    dt.Columns.Add("备注", typeof(string));
                }
                else
                {
                    dt = (System.Data.DataTable)dv1.DataSource;
                }
                dt.Rows.Clear();
                foreach (Product p in (List <Product>)olist)
                {
                    dt.Rows.Add(new object[]
                    {
                        p.Pro_code, p.Pro_Name, p.Pro_Leibie, p.Pro_Gui, p.Pro_state, p.finishTime, p.Pro_Pici, p.Pro_Chej, p.Pro_Person, p.Contact, p.Pro_Tempre, p.Pro_Wet, p.Remark
                    });
                }
                dv1.DataSource = dt;

                this.dv1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
                int headerW  = this.dv1.RowHeadersWidth;
                int columnsW = 0;
                DataGridViewColumnCollection columns = this.dv1.Columns;
                columns[0].Width = 100;
                for (int i = 0; i < columns.Count; i++)
                {
                    columnsW += columns[i].Width;
                }
                if (columnsW + headerW < this.dv1.Width)
                {
                    int leftTotalWidht       = this.dv1.Width - columnsW - headerW;
                    int eachColumnAddedWidth = leftTotalWidht / (columns.Count - 1);
                    for (int i = 1; i < columns.Count; i++)
                    {
                        columns[i].Width += eachColumnAddedWidth;
                    }
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 19
0
        void StaticSerialPort_evtParseReceivedData_frmSelect(ProtocolHelper helper)
        {
            deleControlInvoke dele = delegate(object o)
            {
                ProtocolHelper p          = (ProtocolHelper)o;
                DataRow[]      rows       = null;
                DataRow[]      rowsMap    = null;
                int            totalCount = this.studentInfoTable.Rows.Count;
                //                int totalCount = this.infoTable.Rows.Count;
                //rows = this.infoTable.Select("equipmentID = '" + data.equipmentID + "'");
                rows    = this.studentInfoTable.Select("STUDENTID = '" + p.epcID + "'");
                rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + p.remoteDeviceID + "'");
                string studentName = string.Empty;
                if (rows.Length > 0 && rowsMap.Length > 0)
                {
                    string answer     = p.questionValue;
                    int    groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString());
                    studentName = (string)rows[0]["NAME"];

                    Carbinet _carbinet = this.groups[groupIndex];
                    _carbinet.setDocText(p.remoteDeviceID, studentName);

                    //这里要处理一下同一个学生用不一个设备发送答案的情况
                    DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + p.epcID + "'");
                    if (rowsForDuplicate.Length > 0)                                          //说明已经有过对应
                    {
                        if (((string)rowsForDuplicate[0]["EQUIPEMNTID"]) != p.remoteDeviceID) //根据设备和根据学号找的记录不一样,肯定有重复
                        {
                            int      groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString());
                            Carbinet _carbinet2  = this.groups[groupIndex2];
                            _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], (Image)global::Carbinet.Properties.Resources.grey);
                            _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], "");
                            rowsForDuplicate[0]["studenID"] = "";
                        }
                    }


                    rowsMap[0]["studenID"] = p.epcID;


                    if (answer == "A")
                    {
                        rows[0]["answer"] = "A";
                        // _carbinet.setDocBGColor(data.equipmentID, this.clrA);
                        _carbinet.setDocBGImage(p.remoteDeviceID, (Image)global::Carbinet.Properties.Resources.yellow);
                    }
                    if (answer == "B")
                    {
                        _carbinet.setDocBGImage(p.remoteDeviceID, (Image)global::Carbinet.Properties.Resources.orange);
                        rows[0]["answer"] = "B";
                    }
                    if (answer == "C")
                    {
                        rows[0]["answer"] = "C";
                        _carbinet.setDocBGImage(p.remoteDeviceID, (Image)global::Carbinet.Properties.Resources.blue);
                        //_carbinet.setDocBGColor(data.equipmentID, this.clrC);
                    }
                    if (answer == "D")
                    {
                        rows[0]["answer"] = "D";
                        _carbinet.setDocBGImage(p.remoteDeviceID, (Image)global::Carbinet.Properties.Resources.purple);
                        //_carbinet.setDocBGColor(data.equipmentID, this.clrD);
                    }

                    DataRow[] rowsA    = this.studentInfoTable.Select("answer = 'A'");
                    DataRow[] rowsB    = this.studentInfoTable.Select("answer = 'B'");
                    DataRow[] rowsC    = this.studentInfoTable.Select("answer = 'C'");
                    DataRow[] rowsD    = this.studentInfoTable.Select("answer = 'D'");
                    int       iA       = rowsA.Length;
                    int       iB       = rowsB.Length;
                    int       iC       = rowsC.Length;
                    int       iD       = rowsD.Length;
                    int       iUnknown = totalCount - iA - iB - iC - iD;
                    m_panelDrawing.Values = new decimal[] { iUnknown, iA, iB, iC, iD };
                    string strA = "", strB = "", strC = "", strD = "", strUnknown = "";

                    if (iUnknown > 0)
                    {
                        strUnknown = (iUnknown * 100 / totalCount).ToString() + "%";
                    }
                    if (iA > 0)
                    {
                        strA = (iA * 100 / totalCount).ToString() + "%";
                    }
                    if (iB > 0)
                    {
                        strB = (iB * 100 / totalCount).ToString() + "%";
                    }
                    if (iC > 0)
                    {
                        strC = (iC * 100 / totalCount).ToString() + "%";
                    }
                    if (iD > 0)
                    {
                        strD = (iD * 100 / totalCount).ToString() + "%";
                    }
                    m_panelDrawing.Texts = new string[] { strUnknown, strA, strB, strC, strD };
                }
            };

            this.Invoke(dele, helper);
        }
Ejemplo n.º 20
0
        void helper_RequestCompleted_disposeList(object o)
        {
            //if (this.InvokeRequired)
            //{
            //    this.Invoke(new deleControlInvoke(updateDatagrid), o);
            //}
            deleControlInvoke dele = delegate(object oProductList)
            {
                string strProduct = (string)oProductList;
                Debug.WriteLine(
                    string.Format("frmProductManage.helper_RequestCompleted_disposeList  -> response = {0}"
                                  , strProduct));
                Product   u2    = fastJSON.JSON.Instance.ToObject <Product>(strProduct);
                object    olist = fastJSON.JSON.Instance.ToObjectList(strProduct, typeof(List <Product>), typeof(Product));
                DataTable dt    = null;
                if (this.dataGridView1.DataSource == null)
                {
                    dt = new DataTable();
                    dt.Columns.Add("产品编号", typeof(string));
                    dt.Columns.Add("产品名称", typeof(string));
                    dt.Columns.Add("生产日期", typeof(string));
                    dt.Columns.Add("产品类别", typeof(string));
                    dt.Columns.Add("产品备注信息", typeof(string));
                }
                else
                {
                    dt = (DataTable)dataGridView1.DataSource;
                }
                dt.Rows.Clear();
                foreach (Product c in (List <Product>)olist)
                {
                    dt.Rows.Add(new object[] {
                        c.productID, c.productName, c.produceDate, c.productCategory, c.descript
                    });
                    Debug.WriteLine(c.productID + "      " + c.produceDate);
                }
                this.dataGridView1.DataSource = dt;

                this.dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
                int headerW  = this.dataGridView1.RowHeadersWidth;
                int columnsW = 0;
                DataGridViewColumnCollection columns = this.dataGridView1.Columns;
                if (columns.Count > 0)
                {
                    for (int i = 0; i < columns.Count; i++)
                    {
                        columnsW += columns[i].Width;
                    }
                    if (columnsW + headerW < this.dataGridView1.Width)
                    {
                        int leftTotalWidht       = this.dataGridView1.Width - columnsW - headerW;
                        int eachColumnAddedWidth = leftTotalWidht / (columns.Count);
                        for (int i = 0; i < columns.Count; i++)
                        {
                            columns[i].Width += eachColumnAddedWidth;
                        }
                    }
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 21
0
        private void handle_event()
        {
            IntelligentEvent evt = MiddleWareCore.get_a_event();

            if (evt != null)
            {
                deleControlInvoke dele = delegate(object o)
                {
                    IntelligentEvent p              = (IntelligentEvent)o;
                    string           epcID          = p.epcID;
                    string           remoteDeviceID = p.remoteDeviceID;
                    string           question_value = p.questionValue;
                    int totalCount = MemoryTable.studentInfoTable.Rows.Count;

                    Person            person = MemoryTable.getPersonByEpc(epcID);
                    equipmentPosition ep     = MemoryTable.getEquipmentConfigMapInfoByDeviceID(remoteDeviceID);
                    //如果只是重复发送,不需要做什么
                    if (p.event_unit_list.IndexOf(IntelligentEventUnit.repeat_epc) >= 0)
                    {
                        //如果重复发送之外,还改变了设备的ID
                        if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0)
                        {
                            if (person != null && ep != null)
                            {
                                int groupIndex = ep.group;

                                equipmentPosition ep_old = MemoryTable.getEquipmentInfoByEpc(epcID);
                                Program.frmClassRoom.changeChairState(ep_old.group, ep_old.formatedPosition(), DocumentFileState.InitialState);
                                Program.frmClassRoom.changeChairState(ep_old.group, ep_old.formatedPosition(), "");
                                MemoryTable.clearEquipmentAndStudentCombining(epcID);

                                Program.frmClassRoom.changeChairState(groupIndex, ep.formatedPosition(), person.name);
                                MemoryTable.setEquipmentInfoCombineStudentID(ep, person.epc);

                                Program.frmClassRoom.changeChairState(groupIndex, ep.formatedPosition(), DocumentFileState.Green);
                            }
                        }
                        //如果重复发送之外,还改变了问题的答案,按照设计,这里不需要更改饼图
                        if (p.event_unit_list.IndexOf(IntelligentEventUnit.change_answer) >= 0)
                        {
                            this.refreshAnswerRecord(person, question_value);
                        }
                    }
                    else
                    if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0)
                    {
                        //处理该事件需要更新数据和显示页面
                        if (person != null && ep != null)
                        {
                            MemoryTable.setEquipmentInfoCombineStudentID(ep, epcID);
                            Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), DocumentFileState.Green);
                            Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), person.name);
                        }

                        this.refreshAnswerRecord(person, question_value);
                        this.refreshPie();
                    }
                };

                this.Invoke(dele, evt);
            }
        }
Ejemplo n.º 22
0
        void helper_RequestCompleted_getProductInfoForInventoryList(object o)
        {
            deleControlInvoke dele = delegate(object oProductList)
            {
                string strProduct = (string)oProductList;
                object olist      = fastJSON.JSON.Instance.ToObjectList(strProduct, typeof(List <Product>), typeof(Product));

                DataTable dt = null;
                if (this.dgvProductInfo.DataSource == null)
                {
                    dt = new DataTable();
                    dt.Columns.Add("产品编号", typeof(string));
                    dt.Columns.Add("产品名称", typeof(string));
                    dt.Columns.Add("生产日期", typeof(string));
                    dt.Columns.Add("产品类别", typeof(string));
                    dt.Columns.Add("产品备注信息", typeof(string));
                }
                else
                {
                    dt = (DataTable)dgvProductInfo.DataSource;
                }
                dt.Rows.Clear();
                foreach (Product p in (List <Product>)olist)
                {
                    dt.Rows.Add(new object[] {
                        p.productID,
                        p.productName,
                        p.produceDate,
                        p.productCategory,
                        p.descript
                    });
                }
                dgvProductInfo.DataSource = dt;

                if (!this.dgvProductInfo.Columns.Contains("checkColumn"))
                {
                    DataGridViewCheckBoxColumn cbc = CreateCheckBoxColumn();

                    dgvProductInfo.Columns.Insert(0, cbc);
                }

                foreach (DataGridViewRow vr in this.dgvProductInfo.Rows)
                {
                    DataGridViewCheckBoxCell cbc = (DataGridViewCheckBoxCell)vr.Cells[0];

                    cbc.Value = LightStatus.TurnedOff;
                }


                this.dgvProductInfo.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
                int headerW  = this.dgvProductInfo.RowHeadersWidth;
                int columnsW = 0;
                DataGridViewColumnCollection columns = this.dgvProductInfo.Columns;
                columns[0].Width = 50;
                for (int i = 0; i < columns.Count; i++)
                {
                    columnsW += columns[i].Width;
                }
                if (columnsW + headerW < this.dgvProductInfo.Width)
                {
                    int leftTotalWidht       = this.dgvProductInfo.Width - columnsW - headerW;
                    int eachColumnAddedWidth = leftTotalWidht / (columns.Count - 1);
                    for (int i = 1; i < columns.Count; i++)
                    {
                        columns[i].Width += eachColumnAddedWidth;
                    }
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 23
0
        void LinkEPCToProduct(object o)
        {
            deleControlInvoke dele = delegate(object oEpc)
            {
                string epc = oEpc as string;
                //根据传入的id按照以下思路处理
                // 首先在当前列表中查找是否含有该id,如果有,则账物相符加1,盘亏减1
                // 如果未在列表中找到该id,说明是盘盈,需要在列表中添加该产品信息,并且盘盈加1
                DataGridViewRowCollection rows = this.dgvProductInfo.Rows;
                bool bFind = false;
                foreach (DataGridViewRow vr in rows)
                {
                    DataGridViewCell cepc = (DataGridViewCell)vr.Cells[1];
                    if (((string)cepc.Value) == epc)
                    {
                        DataGridViewCheckBoxCell cbc = (DataGridViewCheckBoxCell)vr.Cells[0];
                        if (cbc.Value == null)
                        {
                            AudioAlert.PlayAlert();
                        }
                        if ((LightStatus)cbc.Value == LightStatus.TurnedOff)
                        {
                            cbc.Value = LightStatus.TurnedOn;
                            int ncrtEqul = int.Parse(this.lblEqual.Text);
                            int ncrtLess = int.Parse(this.lblLess.Text);
                            this.lblLess.Text  = (ncrtLess - 1).ToString();
                            this.lblEqual.Text = (ncrtEqul + 1).ToString();
                        }

                        bFind = true;
                        break;
                    }
                }
                if (bFind == false)
                {
                    //获取具有该id的产品信息
                    Product        p1         = new Product(epc, string.Empty, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), string.Empty, string.Empty);
                    string         jsonString = fastJSON.JSON.Instance.ToJSON(p1);
                    HttpWebConnect helper     = new HttpWebConnect();
                    helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_getProduct);
                    string url = RestUrl.getProduct;
                    helper.TryPostData(url, jsonString);
                }
            };

            this.Invoke(dele, o);
            //DataTable dt1 = ctlInventory.GetProductInfoTable(epc);
            //if (dt1.Rows.Count > 0)
            //{
            //    //将具体的产品信息添加到详细列表里面
            //    if (this.dgvProductInfo.DataSource != null)
            //    {
            //        DataTable dt = (DataTable)this.dgvProductInfo.DataSource;

            //        //首先检查该产品是否已经扫描过
            //        bool alreadyAdded = false;
            //        foreach (DataRow dr in dt.Rows)
            //        {
            //            if (dr.ItemArray[0].ToString() == epc)
            //            {
            //                alreadyAdded = true;
            //                break;
            //            }
            //        }
            //        //如果尚未扫描过
            //        if (!alreadyAdded)
            //        {
            //            DataRow dr = dt.NewRow();
            //            dr.ItemArray = dt1.Rows[0].ItemArray;
            //            dt.Rows.Add(dr);
            //        }
            //    }
            //}
        }
Ejemplo n.º 24
0
        void helper_RequestCompleted_getPreProListToStorage(object o)
        {
            deleControlInvoke dele = delegate(object oProductList)
            {
                string strProduct = (string)oProductList;
                Debug.WriteLine(
                    string.Format("frmStorageManage.helper_RequestCompleted_disposeList  ->  = {0}"
                                  , strProduct));
                object olist = fastJSON.JSON.Instance.ToObjectList(strProduct, typeof(List <Product>), typeof(Product));

                DataTable dt = null;
                if (this.dgvNotStoragedPInfo.DataSource == null)
                {
                    dt = new DataTable();
                    dt.Columns.Add("产品编号", typeof(string));
                    dt.Columns.Add("产品名称", typeof(string));
                    dt.Columns.Add("生产日期", typeof(string));
                    dt.Columns.Add("产品类别", typeof(string));
                    dt.Columns.Add("产品备注信息", typeof(string));
                }
                else
                {
                    dt = (DataTable)dgvNotStoragedPInfo.DataSource;
                }
                dt.Rows.Clear();
                foreach (Product p in (List <Product>)olist)
                {
                    dt.Rows.Add(new object[] {
                        p.productID,
                        p.productName,
                        p.produceDate,
                        p.productCategory,
                        p.descript
                    });
                }
                dgvNotStoragedPInfo.DataSource = dt;

                if (!this.dgvNotStoragedPInfo.Columns.Contains("checkColumn"))
                {
                    DataGridViewCheckBoxColumn cc = new DataGridViewCheckBoxColumn();
                    cc.HeaderText = "";
                    cc.Name       = "checkColumn";
                    cc.Width      = 50;
                    dgvNotStoragedPInfo.Columns.Insert(0, cc);
                }

                this.dgvNotStoragedPInfo.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
                int headerW  = this.dgvNotStoragedPInfo.RowHeadersWidth;
                int columnsW = 0;
                DataGridViewColumnCollection columns = this.dgvNotStoragedPInfo.Columns;
                columns[0].Width = 50;
                for (int i = 0; i < columns.Count; i++)
                {
                    columnsW += columns[i].Width;
                }
                if (columnsW + headerW < this.dgvNotStoragedPInfo.Width)
                {
                    int leftTotalWidht       = this.dgvNotStoragedPInfo.Width - columnsW - headerW;
                    int eachColumnAddedWidth = leftTotalWidht / (columns.Count - 1);
                    for (int i = 1; i < columns.Count; i++)
                    {
                        columns[i].Width += eachColumnAddedWidth;
                    }
                }
            };

            this.Invoke(dele, o);
        }
Ejemplo n.º 25
0
        void helper_RequestCompleted_getProduct(object o)
        {
            deleControlInvoke dele = delegate(object oProduct)
            {
                string  strProduct = (string)oProduct;
                Product u2         = fastJSON.JSON.Instance.ToObject <Product>(strProduct);
                if (u2 != null && u2.state == "ok")
                {
                    Debug.WriteLine(
                        string.Format("frmTakeOutInventory.helper_RequestCompleted_getProduct  ->  = {0}"
                                      , u2.toString()));
                    //将具体的产品信息添加到详细列表里面
                    if (this.dgvDetailProductsInfo.DataSource != null)
                    {
                        DataTable dt = (DataTable)this.dgvDetailProductsInfo.DataSource;

                        //首先检查该产品是否已经扫描过
                        bool alreadyAdded = false;
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr.ItemArray[0].ToString() == u2.productID)
                            {
                                alreadyAdded = true;
                                break;
                            }
                        }
                        //如果尚未扫描过
                        if (!alreadyAdded)
                        {
                            //检查该产品在出库单中是否已经足够,数量足够的话不需要再添加
                            bool      bEnough         = false;
                            string    productName     = u2.productName;
                            DataTable dtOrder         = (DataTable)this.dgvTakenOutP.DataSource;
                            int       quantityOrdered = -1;
                            int       quantityNow     = -1;
                            DataRow   drOrderProduct  = null;
                            if (dtOrder != null && dtOrder.Rows.Count > 0)
                            {
                                foreach (DataRow dr in dtOrder.Rows)
                                {
                                    if (dr[0].ToString() == productName)
                                    {
                                        drOrderProduct = dr;
                                        break;
                                    }
                                }
                                if (drOrderProduct != null)
                                {
                                    try
                                    {
                                        quantityOrdered = int.Parse(drOrderProduct[1].ToString());
                                        quantityNow     = int.Parse(drOrderProduct[2].ToString());
                                    }
                                    catch (System.Exception ex)
                                    {
                                        MessageBox.Show("程序异常:" + ex.Message);
                                        return;
                                    }
                                    if (quantityNow > -1 && quantityOrdered > -1)
                                    {
                                        if (quantityNow >= quantityOrdered)
                                        {
                                            bEnough = true;
                                        }
                                    }
                                    if (!bEnough)
                                    {
                                        if (null != drOrderProduct)
                                        {
                                            drOrderProduct[2] = (++quantityNow).ToString();
                                        }
                                        dt.Rows.Add(new object[] {
                                            u2.productID,
                                            u2.productName,
                                            u2.produceDate,
                                            u2.productCategory,
                                            u2.descript
                                        });

                                        if (this.CheckAllOrderEnough())
                                        {
                                            this.btnStartCheck.Enabled = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            this.Invoke(dele, o);
        }
        public void NewTagMessage()
        {
            deleControlInvoke dele = delegate(object o)
            {
                List <EpcProduct> tagList = current_helper.GetCurrentProductList();
                if (tagList.Count > 0)
                {
                    foreach (EpcProduct ep in tagList)
                    {
                        Debug.WriteLine(string.Format("epc => {0}   antena => {1}", ep.tagInfo.epc, ep.tagInfo.antennaID));
                    }
                    #region 检查标签是否应该放在放在的正确的货架
                    //int count4InWrongCarbinet = 0;
                    //foreach (EpcProduct t in tagList)
                    //{
                    //    string tEpc = t.epc;
                    //    if (tEpc.Substring(16, 2) != carbinet_epc_flag)
                    //    {
                    //        count4InWrongCarbinet++;
                    //    }
                    //}
                    //if (count4InWrongCarbinet > 0)
                    //{
                    //    this.lblStatus.Text = "有不属于本货架的产品放置在本货架中,请检查!";
                    //}
                    //else
                    //{
                    //    this.lblStatus.Text = string.Empty;
                    //}
                    #endregion
                }
                else
                {
                    Debug.WriteLine("no products now!!!");
                }

                #region 首先把不再存在的标签从列表中删除
                //
                DataRow[] allRows = MemoryTable.unitTable.Select();
                for (int j = 0; j < allRows.Length; j++)
                {
                    DataRow dr    = allRows[j];
                    string  epc   = (string)dr["epc"];
                    int     floor = int.Parse(dr["floor"].ToString());
                    if (epc != null && epc.Length > 0)
                    {
                        bool bFinded = false;
                        foreach (EpcProduct ti in tagList)
                        {
                            if ((ti.tagInfo.epc == epc) && (this.getFloorByAntennaID(ti.tagInfo.antennaID) == floor))//这里的不存在应该和位置相关
                            {
                                bFinded = true;
                                break;
                            }
                        }
                        if (bFinded == false)//如果列表中不再存在这个标签,就把之前标签占据的位置的状态设为delete
                        {
                            dr["action"] = "delete";
                            MemoryTable.staticsTable.Rows.Add(new object[] { epc, "下架", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
                        }
                    }
                }
                #endregion

                #region 添加新出现的标签到显示列表中
                //
                for (int i = 0; i < tagList.Count; i++)
                {
                    EpcProduct ti  = tagList[i];
                    string     epc = ti.tagInfo.epc;
                    //if (epc.Substring(16, 2) != carbinet_epc_flag)
                    //{
                    //    continue;
                    //}
                    int anticipatedFloor = 0;
                    try
                    {
                        string strFloor = this.getAnticipatedFloorByEpc(epc);// 18,2
                        anticipatedFloor = int.Parse(strFloor);
                    }
                    catch
                    {
                    }
                    if (anticipatedFloor == 0)
                    {
                        continue;
                    }
                    int tagFloor = this.getFloorByAntennaID(ti.tagInfo.antennaID);

                    bool      bOnWrongFloor = false; //是否放置在错误的货架层上
                    DataRow[] drs           = MemoryTable.unitTable.Select("epc='" + epc + "' and floor=" + tagFloor.ToString());
                    if (drs.Length <= 0)             //说明这个标签还不存在
                    {
                        //Debug.WriteLine("antinna To floor ->  antenna = " + ti.antennaID);
                        int antenna = int.Parse(ti.tagInfo.antennaID);//todo  暂时把设备的天线和货架的层数挂钩
                        int floor   = -1;
                        switch (antenna)
                        {
                        case 1:
                            floor = 1;
                            break;

                        case 2:
                            floor = 2;
                            break;

                        case 4:
                            floor = 3;
                            break;

                        case 8:
                            floor = 4;
                            break;
                        }
                        if (floor != anticipatedFloor)
                        {
                            Debug.WriteLine(string.Format("antinna To floor ->  floor = {0}   anticipatedFloor = {1}", floor.ToString(), anticipatedFloor.ToString()));
                            bOnWrongFloor = true;//设计放产品的层和实际的层不一致
                        }
                        if (floor != -1)
                        {
                            DataRow[] emptyRows = MemoryTable.unitTable.Select("status = 'empty' and floor=" + floor.ToString());
                            if (emptyRows.Length > 0)
                            {
                                Debug.WriteLine(
                                    string.Format("Form1._timer_Tick  -> equipID = {0}"
                                                  , emptyRows[0]["id"]));
                                emptyRows[0]["epc"]    = epc;
                                emptyRows[0]["status"] = "occupied";
                                if (bOnWrongFloor == true)
                                {
                                    emptyRows[0]["action"] = "addOnWrongFloor";
                                }
                                else
                                {
                                    emptyRows[0]["action"] = "add";
                                }
                                if (epc != null && epc.Length >= 23)
                                {
                                    string type = epc.Substring(20, 2);

                                    emptyRows[0]["type"] = type;
                                }
                            }
                        }
                        MemoryTable.staticsTable.Rows.Add(new object[] { epc, "上架", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
                    }
                }

                #endregion
                #region 其它逻辑处理

                //
                // 1 搜索某类商品
                string productName = this.cmbProductName.Text;
                //            string productName = this.txtProductName.Text;
                if (productName != null && productName.Length > 0 && productName != "无")
                {
                    DataRow[] rowsProduct = MemoryTable.typeMapTable.Select("productName <>'" + productName + "'");
                    for (int j = 0; j < rowsProduct.Length; j++)
                    {
                        DataRow   dr         = rowsProduct[j];
                        string    type       = (string)dr["type"];
                        DataRow[] rowsFilter = MemoryTable.unitTable.Select("type = '" + type + "'");
                        for (int k = 0; k < rowsFilter.Length; k++)
                        {
                            DataRow drFilter = rowsFilter[k];

                            //drFilter["status"] = "empty";
                            drFilter["action"] = "delete";
                        }
                    }
                }

                #endregion


                #region 处理显示
                //
                //需要删除的
                DataRow[] rows = MemoryTable.unitTable.Select("action = 'delete'");
                if (rows.Length > 0)
                {
                    List <epcInfo> epcList = new List <epcInfo>();
                    for (int i = 0; i < rows.Length; i++)
                    {
                        string  id      = (string)rows[i]["id"];
                        string  epc     = (string)rows[i]["epc"];
                        string  type    = (string)rows[i]["type"];
                        epcInfo epcinfo = new epcInfo(epc, type);
                        epcList.Add(epcinfo);
                        if (id != null && id.Length > 0)
                        {
                            int          groupIndex = int.Parse(rows[i]["group"].ToString());
                            Carbinet     _carbinet  = this.groups[groupIndex];
                            DocumentFile df         = _carbinet.getDoc(id);
                            if (df != null)
                            {
                                df.setBackgroundImage(null);
                                df.setBorderWidth(0);
                                df.indexBase = "z" + df.columnNumber.ToString("0000");//重置为基础的排序依据
                            }
                        }

                        rows[i]["action"] = "normal";
                        rows[i]["epc"]    = "";
                        rows[i]["type"]   = "";
                        rows[i]["status"] = "empty";
                    }

                    //TODO 处于防盗模式下需要语音提醒,处于讲解模式下需要对产品进行讲解
                    if (staticClass.mode == MonitorMode.防盗模式)
                    {
                        this.SpeakAboutSomething(epcList);
                    }
                    //else
                    //    if (staticClass.mode == MonitorMode.讲解模式)
                    //    {
                    //        for (int i = 0; i < epcList.Count; i++)
                    //        {
                    //            epcInfo ei = epcList[i];
                    //            MemoryTable.staticsTable.Rows.Add(new object[] { ei.epc, "下架", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
                    //        }
                    //    }
                }
                // 需要增加的
                rows = MemoryTable.unitTable.Select("action = 'add' OR action = 'addOnWrongFloor'");
                if (rows.Length > 0)
                {
                    for (int i = 0; i < rows.Length; i++)
                    {
                        int    groupIndex    = int.Parse(rows[i]["group"].ToString());
                        string id            = (string)rows[i]["id"];
                        string epc           = (string)rows[i]["epc"];
                        string action        = (string)rows[i]["action"];
                        bool   bOnWrongFloor = false;
                        if (action == "addOnWrongFloor")
                        {
                            bOnWrongFloor = true;
                        }
                        Carbinet _carbinet = this.groups[groupIndex];
                        // 不同种类的物品设置成不同的大小
                        string type = MemoryTable.getProductTypeID(epc);

                        DataRow[] drsType = MemoryTable.typeMapTable.Select("type='" + type + "'");
                        if (drsType.Length > 0)
                        {
                            int    width  = int.Parse(drsType[0]["width"].ToString());
                            int    height = int.Parse(drsType[0]["height"].ToString());
                            string path   = (string)drsType[0]["picname"];
                            path = PublicConfig.staticClass.PicturePath + path;
                            Image newImage = null;
                            try
                            {
                                newImage = Image.FromFile(path);
                            }
                            catch (System.Exception ex)
                            {
                                Debug.WriteLine(
                                    string.Format("Form1._timer_Tick  -> loadImage error = {0}"
                                                  , ex.Message));
                            }
                            DocumentFile df = _carbinet.getDoc(id);
                            if (df != null)
                            {
                                df.setBackgroundImage(newImage);
                                if (bOnWrongFloor == true)
                                {
                                    df.setBorderWidth(5);
                                }
                                //df.setBorderWidth(0);//边框重置为0
                                df.indexBase = type;
                            }
                            //_carbinet.setDocBGImage(id, newImage);

                            _carbinet.setDocSize(id, width, height);

                            //drsType[0]["count"] = ((int)drsType[0]["count"]) + 1;
                        }
                        rows[i]["action"] = "normal";
                    }
                }

                #endregion



                #region 设置饼图

                //
                DataRow[] typeRows = MemoryTable.typeMapTable.Select();
                decimal[] decimals = new decimal[typeRows.Length];
                string[]  strs     = new string[typeRows.Length];
                Color[]   colors   = new Color[typeRows.Length];
                for (int i = 0; i < typeRows.Length; i++)
                {
                    DataRow[] RowsTemp = MemoryTable.unitTable.Select("type = '" + (string)typeRows[i]["type"] + "'");
                    decimals[i]          = RowsTemp.Length;
                    typeRows[i]["count"] = RowsTemp.Length;
                    //                decimals[i] = (int)typeRows[i]["count"];
                    strs[i] = RowsTemp.Length.ToString();
                    //                strs[i] = typeRows[i]["count"].ToString();
                    //strs[i] = typeRows[i]["productName"] + ":" + typeRows[i]["count"].ToString();
                    colors[i] = Color.FromArgb(alpha,
                                               int.Parse(typeRows[i]["red"].ToString()),
                                               int.Parse(typeRows[i]["green"].ToString()),
                                               int.Parse(typeRows[i]["blue"].ToString()));
                }
                m_panelDrawing.Values = decimals;
                m_panelDrawing.Texts  = strs;
                m_panelDrawing.Colors = colors;
                #endregion
            };

            this.Invoke(dele, new object());
        }
Ejemplo n.º 27
0
        void StaticSerialPort_evtParseReceivedData(ProtocolHelper helper)
        {
            deleControlInvoke dele = delegate(object o)
            {
                ProtocolHelper _helper = (ProtocolHelper)o;

                string epcID          = _helper.epcID;
                string remoteDeviceID = _helper.remoteDeviceID;
                //更新考勤信息
                DataRow[] rows = null;
                //rows = this.checkTable.Select("equipmentID = '" + data.equipmentID + "'");
                //根据接收到的信息,首先将学生出勤状态置为 1,之后将控件的显示状态改为绿色
                rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'");
                string studentName = string.Empty;
                if (rows.Length > 0)
                {
                    rows[0]["status"]    = "1";
                    rows[0]["checkTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    studentName          = (string)rows[0]["NAME"];
                }

                //处理多次考勤情况
                rows = this.mapConfigsTable.Select("studenID = '" + epcID + "'");
                if (rows.Length > 0)//至少第二次考勤
                {
                    //此时需要将之前设为考勤状态的位置变回未考勤状态
                    int      groupIndex = int.Parse(rows[0]["IGROUP"].ToString());
                    Carbinet _carbinet  = this.groups[groupIndex];
                    _carbinet.setDocBGImage((string)rows[0]["EQUIPEMNTID"], (Image)global::Carbinet.Properties.Resources.grey);
                    _carbinet.setDocText((string)rows[0]["EQUIPEMNTID"], "");
                    rows[0]["studenID"] = "";
                }

                //rows = this.checkTable.Select("equipmentID = '" + data.equipmentID + "'");
                rows = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
                if (rows.Length > 0)
                {
                    rows[0]["studenID"] = epcID;
                    int groupIndex = int.Parse(rows[0]["IGROUP"].ToString());
                    //界面展示
                    Carbinet _carbinet = this.groups[groupIndex];
                    //_carbinet.setDocBGColor(data.equipmentID, Color.Green);
                    _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.orange);
                    _carbinet.setDocText(remoteDeviceID, studentName);

                    rows = this.studentInfoTable.Select("status = '1'");
                    int checkedCount   = rows.Length;
                    int uncheckedCount = this.studentInfoTable.Rows.Count - checkedCount;
                    Debug.WriteLine(
                        string.Format("Form1.updateStatus  -> checked = {0} unchecked = {1}"
                                      , checkedCount, uncheckedCount));
                    m_panelDrawing.Values = new decimal[] { uncheckedCount, checkedCount };
                    string strchecked = "", strUnchecked = "";
                    if (checkedCount > 0)
                    {
                        strchecked = (checkedCount / (checkedCount + uncheckedCount)).ToString() + "%";
                    }
                    if (uncheckedCount > 0)
                    {
                        strUnchecked = (uncheckedCount / (checkedCount + uncheckedCount)).ToString() + "%";
                    }

                    m_panelDrawing.ToolTips = new string[] { "缺勤:" + uncheckedCount.ToString(),
                                                             "出勤:" + checkedCount.ToString() };
                }
            };

            this.Invoke(dele, helper);
            //throw new NotImplementedException();
        }