Exemplo n.º 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            importData();
            MemoryTable.initializeTabes();
            frmClassRoom = new frmClassRoom();
            frmFloat     = new frmFloat();
            StaticDataPort.openDataPort(5000);       //普通的系统数据交互端口
            LoginManager.StartRFID_UDPServer(5001);  //读卡器传送数据端口
            LoginManager.StartLogin_UDPServer(5002); //登陆端口
            LoginManager.start_broadcasting_config(5000, 5002);

            Application.Run(frmFloat);

            //Application.Run(new frmTest());

            //frmMainFloat frmStart = new frmMainFloat();
            //Application.Run(frmStart);
            //frmCheckInit frmStart = new frmCheckInit();
            //frmCheckStatics frmStart = new frmCheckStatics();
            //Application.Run(frmMain);
            //Application.Run(new Form1());
            //Application.Run(new frmLogin());
            //frmCheck = new frmCheck();
            //frmTest = new frmRTTest();
            //Program.compareString();
        }
Exemplo n.º 2
0
        public static void exportData()
        {
            //教室配置
            string       roomConfig       = MemoryTable.getRoomConfigJson();
            string       strReadFilePath1 = @"./config/roomConfig.txt";
            StreamWriter srWriteFile1     = new StreamWriter(strReadFilePath1);

            srWriteFile1.Write(roomConfig);
            srWriteFile1.Close();

            //设备位置映射
            EquipmentConfigCtl.clearEquipmentMapOfDB();
            string       strReadFilePath2 = @"./config/equipmentMaps.txt";
            string       equiMap          = MemoryTable.getEquipmentMapJson();
            StreamWriter srWriteFile2     = new StreamWriter(strReadFilePath2);

            srWriteFile2.Write(equiMap);
            srWriteFile2.Close();

            //学生基本信息,客户端支持更改的只有绑定的学生卡
            string       strReadFilePath3 = @"./config/Person.txt";
            string       studentInfo      = MemoryTable.getStudentInfoJson();
            StreamWriter srWriteFile3     = new StreamWriter(strReadFilePath3);

            srWriteFile3.Write(studentInfo);
            srWriteFile3.Close();
        }
Exemplo n.º 3
0
        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");
            }
        }
Exemplo n.º 4
0
        //column数目发生变化
        private void numCountofColumn_ValueChanged(object sender, EventArgs e)
        {
            int group = this.cmbSelectedRow.SelectedIndex;

            MemoryTable.refreshGroupColumnCount(group, (int)this.numCountofColumn.Value);
            this.NotifyClassRoomToRefresh();
        }
Exemplo n.º 5
0
        DocumentFile docLink     = null;//暂存点击到的位置的链接
        public frmEquipmentConfig()
        {
            InitializeComponent();
            //this.numCountofGroup.Value = (decimal)this.ctl.getClassroomConfig(0);
            this.numCountofGroup.Value = (decimal)this.configCtl.GetGroupCount();
            //this.numCountofRow.Value = (decimal)this.ctl.getClassroomConfig(1);
            //this.numCountofColumn.Value = (decimal)this.ctl.getClassroomConfig(2);


            if (MemoryTable.isInitialized == false)
            {
                MemoryTable.initializeTabes();
            }
            this.dtRoomConfig = MemoryTable.dtRoomConfig;
            //dtRoomConfig = this.configCtl.getAllRoomConfigInfo();
            //dtRoomConfig.Columns.Add("totalColumn", typeof(int));
            //dtRoomConfig.Columns["totalColumn"].Expression = "Sum(ICOLUMN)";
            //dtRoomConfig.Columns.Add("maxGroup", typeof(int));
            //dtRoomConfig.Columns["maxGroup"].Expression = "Max(IGROUP)";


            this.Shown       += new EventHandler(frmEquipmentConfig_Shown);
            this.FormClosing += new FormClosingEventHandler(frmEquipmentConfig_FormClosing);
            this.FormClosed  += new FormClosedEventHandler(frmEquipmentConfig_FormClosed);

            MiddleWareCore.set_mode(MiddleWareMode.设备绑定);
            MiddleWareCore.event_receiver = this;
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            //更新新位置的设备绑定信息,并同步到设置页面中
            MemoryTable.setEquipmentAndPosCombining(carbinetIndex, floorNumber, columnNumber, this.txtEquipmentID.Text);
            //更新座位上的设备ID显示
            this.refreshChairEquipmentID();

            //if (this.docLink != null)
            //{
            //    if (this.txtEquipmentID.Text != null && this.txtEquipmentID.Text.Length > 0)
            //    {
            //        docLink.setText(this.txtEquipmentID.Text);

            //        // 保存到数据库中
            //        int group = (int)this.numLocofGroup.Value;
            //        int row = (int)this.numLocofRow.Value;
            //        int column = (int)this.numLocofColumn.Value;
            //        if (!this.ctl.CheckExists(group, row, column))
            //        {
            //            this.ctl.AddMapConfig(this.txtEquipmentID.Text, group, row, column);
            //        }
            //        else
            //        {
            //            this.ctl.updateMapConfig(this.txtEquipmentID.Text, group, row, column);
            //        }
            //    }
            //}
        }
Exemplo n.º 7
0
 private void button1_Click(object sender, EventArgs e)
 {
     MemoryTable.initializeTabes();
     this.test_实时互动1();
     this.test_实时互动2();
     this.test_实时互动3();
     this.test_实时互动4();
     this.test_实时互动5();
 }
 private void initialInfoTable()
 {
     //统一初始化
     if (MemoryTable.isInitialized == false)
     {
         MemoryTable.initializeTabes();
     }
     this.dtRoomConfig     = MemoryTable.dtRoomConfig;
     this.studentInfoTable = MemoryTable.studentInfoTable;
     this.mapConfigsTable  = MemoryTable.mapConfigsTable;
 }
        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();
                }
            }
        }
Exemplo n.º 10
0
        public void callback()
        {
            int                carbinetIndex = Program.frmClassRoom.carbinetIndex;
            int                floorNumber   = Program.frmClassRoom.floorNumber;
            int                columnNumber  = Program.frmClassRoom.columnNumber;
            string             epc           = MemoryTable.getPersonEpcByPosition(carbinetIndex, floorNumber, columnNumber);
            Person             p             = MemoryTable.getPersonByEpc(epc);
            frmShowStudentInfo frm           = new frmShowStudentInfo(p.id_num);

            frm.ShowDialog();
        }
Exemplo n.º 11
0
        private void refreshChairEquipmentID()
        {
            Program.frmClassRoom.resetClassRoomState();
            //有设备绑定的座位显示出绑定设备的ID
            List <equipmentPosition> list = MemoryTable.getAllEquipmentConfigMapInfo();

            foreach (equipmentPosition ep in list)
            {
                Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), ep.equipmentID);
            }
            Program.frmClassRoom.Refresh();
            //Program.frmClassRoom.Show();
        }
Exemplo n.º 12
0
        //group数量发生变化
        private void numCountofGroup_ValueChanged(object sender, EventArgs e)
        {
            int groupNumber = (int)this.numCountofGroup.Value;

            this.setCmbSelectItems(groupNumber);

            //当前只在保存配置数据,当确定上传配置信息时再保存至数据库中,再从数据库中提取信息上传
            //当group总数增大时,需要插入新数据
            //当总数减少时,则要删除值最大的一行数据
            MemoryTable.refreshGroupCount(groupNumber);
            this.NotifyClassRoomToRefresh();
            this.refreshChairEquipmentID();
        }
Exemplo n.º 13
0
        private void cmbConfigs_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strConfigName = this.cmbConfigs.Text;

            //更改数据库配置
            this.ctl.SetConfigsNotUsed(strConfigName);
            this.ctl.SetConfigsUsed(strConfigName);
            reset_current_config_table(strConfigName);
            //重新初始化教室
            MemoryTable.RefreshRoomConfigTable();
            this.dtRoomConfig = MemoryTable.dtRoomConfig;
            this.InitialClassRoom();
        }
Exemplo n.º 14
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();
                    }
                }
            }
        }
Exemplo n.º 15
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;
            }
        }
        public frmShowStudentInfo(string studendID)
        {
            InitializeComponent();
            this.lblID.Text = studendID;

            Person person = MemoryTable.getPersonByID(studendID);

            if (person != null)
            {
                this.lblName.Text  = person.name;
                this.lblClass.Text = person.bj;
                this.lblEmail.Text = person.email;
            }
            else
            {
                this.lblName.Text  = "";
                this.lblID.Text    = "";
                this.lblClass.Text = "";
                this.lblEmail.Text = "";
            }
        }
Exemplo n.º 17
0
        private void initialInfoTable()
        {
            //统一初始化
            if (MemoryTable.isInitialized == false)
            {
                MemoryTable.initializeTabes();
            }
            this.dtRoomConfig     = MemoryTable.dtRoomConfig;
            this.studentInfoTable = MemoryTable.studentInfoTable;
            this.mapConfigsTable  = MemoryTable.mapConfigsTable;
            DataTable dtTemp = frmQuestionMngCtl.getAllQuestion();

            if (dtTemp != null && dtTemp.Rows.Count > 0)
            {
                for (int i = 0; i < dtTemp.Rows.Count; i++)
                {
                    DataRow dr = dtTemp.Rows[i];
                    this.dtQuestion.Rows.Add(dr["question_id"], dr["caption"], dr["answer"], dr["question_index"], "false");
                }
            }
        }
Exemplo n.º 18
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);
            }
        }
Exemplo n.º 19
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);
            }
        }
Exemplo n.º 20
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);
            }
        }
Exemplo n.º 21
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);
            }
        }