void test_实时互动1() { //接收到一个标签数据 MiddleWareCore.set_mode(MiddleWareMode.实时互动); string cmd1 = "[select,master_node,equip000001,stu000001,01,A]"; MiddleWareCore.Set_new_data(ProtocolHelper.getProtocolHelper(cmd1)); IntelligentEvent evt1 = MiddleWareCore.get_a_event(); if (evt1.epcID == "stu000001" && evt1.localDeviceID == "master_node" && evt1.remoteDeviceID == "equip000001" && evt1.questionID == "01" && evt1.questionValue == "A" && evt1.event_unit_list[0] == IntelligentEventUnit.new_epc) { Debug.WriteLine("True"); } else { Debug.WriteLine("False"); } //找到该学生的信息,包括学生姓名、位置、选择 //查找学生信息 Person person = MemoryTable.getPersonByEpc(evt1.epcID); if (person.id_num == "CE4D9397871") { Debug.WriteLine("True"); } else { Debug.WriteLine("False"); } }
private void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { IntelligentEvent IEvent = (IntelligentEvent)evt; string epcID = IEvent.epcID; string remoteDeviceID = IEvent.remoteDeviceID; string check_time = IEvent.time_stamp; string studentName = string.Empty; string question_value = IEvent.questionValue.ToUpper();; //终端发送的答案必须符合要求 A B C 或者 D if (question_value != "A" && question_value != "B" && question_value != "C" && question_value != "D") { return; } //1 更改本地信息 //2 更改饼图 //3 更改座位状态 int totalCount = MemoryTable.studentInfoTable.Rows.Count; Person person = MemoryTable.getPersonByEpc(epcID); equipmentPosition ep = MemoryTable.getEquipmentConfigMapInfoByDeviceID(remoteDeviceID); if (ep != null) { if (IEvent.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0) { ////这里要处理一下同一个学生用不一个设备发送答案的情况 equipmentPosition ep_old = MemoryTable.getEquipmentInfoByEpc(epcID); this.setChairState(ep_old, DocumentFileState.InitialState, ""); MemoryTable.clearEquipmentAndStudentCombining(epcID); } if (person != null) { studentName = person.name; this.setChairState(ep, studentName); MemoryTable.setEquipmentInfoCombineStudentID(ep, person.epc); this.setPersonAnswer(person.id_num, question_value); } DocumentFileState dfs = this.getStateByAnswer(question_value); this.setChairState(ep, dfs); this.refreshPie(); } } }
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; this.txtEpc.Text = epcID; }; this.Invoke(dele, evt); } }
void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { deleControlInvoke dele = delegate(object o) { IntelligentEvent p = (IntelligentEvent)o; string remoteDeviceID = p.remoteDeviceID; this.txtEquipmentID.Text = remoteDeviceID; }; this.Invoke(dele, evt); } }
void test_实时互动5() { //接收到一个标签数据 MiddleWareCore.set_mode(MiddleWareMode.实时互动); string cmd1 = "[select,master_node,subnode1,,01,A]"; MiddleWareCore.Set_new_data(ProtocolHelper.getProtocolHelper(cmd1)); IntelligentEvent evt1 = MiddleWareCore.get_a_event(); if (evt1 == null || evt1.name == IntelligentEvent.event_empty) { Debug.WriteLine("True"); } else { Debug.WriteLine("False"); } }
private void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { IntelligentEvent p = (IntelligentEvent)evt; string epcID = p.epcID; string remoteDeviceID = p.remoteDeviceID; string studentName = string.Empty; bool bRefresh_ui = false; Person person = MemoryTable.getPersonByEpc(epcID); equipmentPosition ep = MemoryTable.getEquipmentConfigMapInfoByDeviceID(remoteDeviceID); if (person != null && ep != null) { if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0)//重复考勤 { ////这里要处理一下同一个学生用不一个设备发送答案的情况 equipmentPosition ep_old = MemoryTable.getEquipmentInfoByEpc(epcID); this.setChairState(ep_old, DocumentFileState.InitialState, ""); MemoryTable.clearEquipmentAndStudentCombining(epcID); bRefresh_ui = true; } if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0)//第一次考勤 { //更新考勤信息 this.addStudentRecord(person.id_num, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); bRefresh_ui = true; } if (bRefresh_ui == true) { if (person != null) { studentName = person.name; this.setChairState(ep, studentName); MemoryTable.setEquipmentInfoCombineStudentID(ep, person.epc); } this.refreshPie(); } } } }
void test_实时互动3() { //标签重复 MiddleWareCore.set_mode(MiddleWareMode.实时互动); string cmd3_1 = "[select,master_node,subnode2,rfid01,01,A]"; string cmd3_2 = "[select,master_node,subnode2,rfid01,01,A]"; MiddleWareCore.Set_new_data(ProtocolHelper.getProtocolHelper(cmd3_1)); MiddleWareCore.Set_new_data(ProtocolHelper.getProtocolHelper(cmd3_2)); IntelligentEvent evt3 = MiddleWareCore.get_a_event(); if (evt3.event_unit_list.IndexOf(IntelligentEventUnit.repeat_epc) >= 0) { Debug.WriteLine("True"); } else { Debug.WriteLine("False"); } }
void test_实时互动2() { //接收到同一个标签在另一个设备上 MiddleWareCore.set_mode(MiddleWareMode.实时互动); string cmd2_1 = "[select,master_node,subnode1,rfid01,01,A]"; string cmd2_2 = "[select,master_node,subnode2,rfid01,01,A]"; MiddleWareCore.Set_new_data(ProtocolHelper.getProtocolHelper(cmd2_2)); MiddleWareCore.Set_new_data(ProtocolHelper.getProtocolHelper(cmd2_1)); IntelligentEvent evt2 = MiddleWareCore.get_a_event(); if (evt2.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0) { Debug.WriteLine("True"); } else { Debug.WriteLine("False"); } }
private void test_考勤1() { MiddleWareCore.set_mode(MiddleWareMode.考勤); string cmd1 = "[select,master_node,subnode1,rfid01,01,A]"; MiddleWareCore.Set_new_data(ProtocolHelper.getProtocolHelper(cmd1)); IntelligentEvent evt1 = MiddleWareCore.get_a_event(); if (evt1.epcID == "rfid01" && evt1.localDeviceID == "master_node" && evt1.remoteDeviceID == "subnode1" && evt1.questionID == "01" && evt1.questionValue == "A" && evt1.event_unit_list[0] == IntelligentEventUnit.new_epc) { Debug.WriteLine("True"); } else { Debug.WriteLine("False"); } }
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); } }
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); } }
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); } }
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); } }