Ejemplo n.º 1
0
        public static bool AddMapConfig(equipmentPosition ep)
        {
            string equipID = ep.equipmentID;
            int    group   = ep.group;
            int    row     = ep.row;
            int    column  = ep.column;

            return(AddMapConfig(equipID, group, row, column));
        }
 public static void setEquipmentInfoCombineStudentID(equipmentPosition pos, string epc)
 {
     DataRow[] rowsMap = mapConfigsTable.Select(string.Format("IGROUP = {0} and IROW = {1} and ICOLUMN = {2}", pos.group, pos.row, pos.column));
     if (rowsMap.Length > 0)
     {
         DataRow dr = rowsMap[0];
         dr["epc"] = epc;
     }
 }
        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();
                }
            }
        }
 public static equipmentPosition getEquipmentInfoByEpc(string epc)
 {
     DataRow[] rowsMap = mapConfigsTable.Select("epc = '" + epc + "'");
     if (rowsMap.Length > 0)
     {
         DataRow           dr = rowsMap[0];
         equipmentPosition ep = new equipmentPosition((string)dr["EQUIPEMNTID"], (int)dr["IGROUP"], (int)dr["IROW"], (int)dr["ICOLUMN"]);
         return(ep);
     }
     return(null);
 }
 public static equipmentPosition getEquipmentConfigMapInfoByDeviceID(string remoteDeviceID)
 {
     DataRow[] rowsMap = mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'");
     if (rowsMap.Length > 0)
     {
         DataRow           dr = rowsMap[0];
         equipmentPosition ep = new equipmentPosition(remoteDeviceID, (int)dr["IGROUP"], (int)dr["IROW"], (int)dr["ICOLUMN"]);
         return(ep);
     }
     return(null);
 }
 public static equipmentPosition getEquipmentConfigMapInfoByPos(int group, int row, int column)
 {
     DataRow[] rowsMap = mapConfigsTable.Select(string.Format("IGROUP = {0} and IROW = {1} and ICOLUMN = {2}", group, row, column));
     if (rowsMap.Length > 0)
     {
         DataRow           dr = rowsMap[0];
         equipmentPosition ep = new equipmentPosition((string)dr["EQUIPEMNTID"], group, row, column);
         return(ep);
     }
     return(null);
 }
        public static string getEquipmentMapJson()
        {
            List <equipmentPosition> list = new List <equipmentPosition>();
            int totalCount = mapConfigsTable.Rows.Count;

            for (int i = 0; i < totalCount; i++)
            {
                DataRow           dr = mapConfigsTable.Rows[i];
                equipmentPosition ep = new equipmentPosition((string)dr["EQUIPEMNTID"], (int)dr["IGROUP"], (int)dr["IROW"], (int)dr["ICOLUMN"]);
                list.Add(ep);
            }
            return(JsonConvert.SerializeObject(list));
        }
        public static List <equipmentPosition> getAllEquipmentConfigMapInfo()
        {
            List <equipmentPosition> list = new List <equipmentPosition>();
            int count = mapConfigsTable.Rows.Count;

            for (int i = 0; i < count; i++)
            {
                DataRow           dr = mapConfigsTable.Rows[i];
                equipmentPosition ep = new equipmentPosition((string)dr["EQUIPEMNTID"], (int)dr["IGROUP"], (int)dr["IROW"], (int)dr["ICOLUMN"]);
                list.Add(ep);
            }
            return(list);
        }
Ejemplo n.º 9
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public void callback()
        {
            carbinetIndex = Program.frmClassRoom.carbinetIndex;
            floorNumber   = Program.frmClassRoom.floorNumber;
            columnNumber  = Program.frmClassRoom.columnNumber;

            this.numLocofGroup.Value  = carbinetIndex;
            this.numLocofRow.Value    = floorNumber;
            this.numLocofColumn.Value = columnNumber;
            equipmentPosition ep = MemoryTable.getEquipmentConfigMapInfoByPos(carbinetIndex, floorNumber, columnNumber);

            if (ep != null)
            {
                this.txtEquipmentID.Text = ep.equipmentID;
            }
            else
            {
                this.txtEquipmentID.Text = string.Empty;
            }
        }
Ejemplo n.º 11
0
        //设置当前题目的答题状态
        private void reset_test_status(string question_id)
        {
            DataRow[] rows = this.dtQuestion_answer_record.Select(string.Format("question_id = '{0}'", question_id));
            int       total_student_count = MemoryTable.studentInfoTable.Rows.Count;
            int       iAnswered           = rows.Length;
            int       iUnknown            = total_student_count - iAnswered;

            NotifyFormToRefreshPie(this.getValueList(iUnknown, iAnswered), true);

            MiddleWareCore.set_mode(MiddleWareMode.课堂测验);

            Program.frmClassRoom.resetClassRoomState();
            //设置教室座位  根据问题查找学生ID,然后根据ID查找位置
            for (int i = 0; i < rows.Length; i++)
            {
                string            studentID = (string)rows[i]["student_id"];
                equipmentPosition ep        = MemoryTable.getEquipmentInfoByEpc(studentID);
                Person            psn       = MemoryTable.getPersonByEpc(studentID);
                Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), DocumentFileState.Green);
                Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), psn.name);
            }
        }
Ejemplo n.º 12
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);
            }
        }
 private void setChairState(equipmentPosition ep, DocumentFileState dfs)
 {
     Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), dfs);
 }
 private void setChairState(equipmentPosition ep, string text)
 {
     Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), text);
 }
Ejemplo n.º 15
0
        static void OnReceiveLoginRequest(IAsyncResult ar)
        {
            //接收到客户端的登陆请求
            //请求中带有客户端输入的学生ID,本服务端需要和学生信息进行匹配,
            //首先学号查找与学号对应的卡号,然后查找卡号是否已经读取到,如果已经读取到,则广播发送登陆信息给客户端
            //如果卡号尚未读取到,则客户端可以等待,然后读取到卡号的时候会发送登陆信息
            //接收到的数据格式
            // [id,data,epc,data]  对应的正则表达式  \[id,(?<id>\w+),epc,(?<epc>\w{0,})\]   必须要求有ID存在
            try
            {
                IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0);
                EndPoint   epSender  = (EndPoint)ipeSender;

                Login_ServerSocket.EndReceiveFrom(ar, ref epSender);

                string strReceived = Encoding.UTF8.GetString(byteData);

                Array.Clear(byteData, 0, byteData.Length);
                Debug.WriteLine("OnReceiveLoginRequest => " + strReceived);

                string          strToBroadcast = string.Empty;
                Regex           regex          = new Regex(@"\[id,(?<id>\w+),epc,(?<epc>\w{0,})\]");
                MatchCollection matches        = regex.Matches(strReceived);
                foreach (Match mc in matches)
                {
                    string epc_match = mc.Groups["epc"].Value;
                    string id_match  = mc.Groups["id"].Value;
                    Debug.WriteLine(string.Format("Match => epc = {0}   student ID = {1}", epc_match, id_match));
                    //根据接收到的id查找绑定的卡号
                    Person person = MemoryTable.getPersonByID(id_match);
                    if (person != null)
                    {
                        string epc = person.epc;
                        //查找是否已经读取到卡号
                        if (epcList.Contains(epc))
                        {
                            string            equipmentID = string.Empty;
                            equipmentPosition ep          = MemoryTable.getEquipmentInfoByEpc(epc);
                            if (ep == null)
                            {
                                ep = MemoryTable.getEquipmentInfoNotUsed();
                            }
                            if (ep != null)
                            {
                                equipmentID = ep.equipmentID;
                            }
                            strToBroadcast = string.Format("[id,{0},epc,{1},equipmentID,{2}]", person.id_num, epc, equipmentID);
                            Broadcast(strToBroadcast);
                        }
                    }
                }

                //Start listening to the message send by the user
                Login_ServerSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender,
                                                    new AsyncCallback(OnReceiveLoginRequest), epSender);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("OnReceiveRFID => " + ex.Message);
            }
        }
Ejemplo n.º 16
0
        static void OnReceiveRFID(IAsyncResult ar)
        {
            try
            {
                IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0);
                EndPoint   epSender  = (EndPoint)ipeSender;

                RFID_ServerSocket.EndReceiveFrom(ar, ref epSender);

                string strReceived = Encoding.UTF8.GetString(byteData);

                Array.Clear(byteData, 0, byteData.Length);
                Debug.WriteLine("OnReceiveRFID => " + strReceived);
                //先假设接收到的都是卡号
                //查找学生信息里面有没有该卡号,如果有的话,广播卡号和学号,可以附带未使用的设备号
                //格式为 [epc,id,equipmentID]
                string epc = strReceived.Substring(0, strReceived.IndexOf("\0"));
                epcList.Add(epc);

                string strToBroadcast = string.Empty;
                Person person         = MemoryTable.getPersonByEpc(epc);
                if (person != null)
                {
                    string            equipmentID = string.Empty;
                    equipmentPosition ep          = MemoryTable.getEquipmentInfoByEpc(epc);
                    if (ep == null)
                    {
                        ep = MemoryTable.getEquipmentInfoNotUsed();
                    }
                    if (ep != null)
                    {
                        equipmentID = ep.equipmentID;
                    }
                    strToBroadcast = string.Format("[id,{0},epc,{1},equipmentID,{2}]", person.id_num, epc, equipmentID);
                    //strToBroadcast = string.Format("[id,{0},epc,{1}]", person.id_num, epc);
                    Broadcast(strToBroadcast);

                    //Regex regex = new Regex(@"\[(?<epc>\w+),(?<id>\w+)\]");
                    //MatchCollection matches = regex.Matches(strToBroadcast);
                    //foreach (Match mc in matches)
                    //{
                    //    string epc_match = mc.Groups["epc"].Value;
                    //    string id_match = mc.Groups["id"].Value;
                    //    Debug.WriteLine(string.Format("Match => epc = {0}   student ID = {1}", epc_match, id_match));
                    //}
                    //equipmentPosition ep = MemoryTable.getEquipmentInfoByEpc(epc);
                    //if (ep == null)//学生尚未绑定座位位置,为其选择一个空的位置
                    //{

                    //}
                    //else
                    //{
                    //    strToBroadcast = string.Format("[{0},{1}]", epc, person.id_num);
                    //}
                }
                //Start listening to the message send by the user
                RFID_ServerSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender,
                                                   new AsyncCallback(OnReceiveRFID), epSender);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("OnReceiveRFID => " + ex.Message);
            }
        }