Exemplo n.º 1
0
        private void ReadStudents(byte[] buffer)
        {
            int index = 0;

            int studentsLen = IPAddress.NetworkToHostOrder(GetIntFromMessage(buffer, index));

            index += sizeof(int);

            if (File.Exists(students_xml))
            {
                File.Delete(students_xml);
            }

            FileStream fs = File.Create(students_xml);

            fs.Write(buffer, index, studentsLen);
            fs.Close();

            XMLFileManager.SaveMemberId(students_xml, memberID);

            students = XMLFileManager.GetStudentList(students_xml);

            parentForm.Invoke(new FillStudentResultsEventHandler(parentForm.FillStudentResults), new Object[] { students });
            if (studentID != -1)
            {
                Student.StudentUpdate stUpd = new Student.StudentUpdate();
                stUpd.student = Student.GetStudentById(students, studentID);
                parentForm.Invoke(new UpdateStudentEventHandler(parentForm.UpdateStudentInfo), new Object[] { stUpd.student });
            }
        }
Exemplo n.º 2
0
        private void ReadExamInfo(byte[] buffer)
        {
            int index = 0;

            examID = GetIntFromMessage(buffer, index);
            index += sizeof(int);

            memberID = GetIntFromMessage(buffer, index);
            index   += sizeof(int);

            studentCount = GetIntFromMessage(buffer, index);

            bool needStudents = false;

            if (File.Exists(students_xml))
            {
                ExamInfo examInfo = XMLFileManager.GetExamInfo(students_xml);
                if (examInfo.examId != examID || examInfo.studentCount != studentCount)
                {
                    needStudents = true;
                }
            }
            else
            {
                needStudents = true;
            }

            if (needStudents)
            {
                List <byte> message = new List <byte>();
                message.AddRange(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(AssistantProtocol.OpcodeNeedStudents)));
                message.AddRange(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(0)));

                byte[] msg = message.ToArray();
                SendMessage(msg);
            }
            else
            {
                XMLFileManager.SaveMemberId(students_xml, memberID);
                students = XMLFileManager.GetStudentList(students_xml);
            }

            if (!File.Exists(cards_xml))
            {
                List <byte> message = new List <byte>();
                message.AddRange(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(AssistantProtocol.OpcodeNeedCards)));
                message.AddRange(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(0)));

                byte[] msg = message.ToArray();
                SendMessage(msg);
            }
            else
            {
                cards = XMLFileManager.GetCardList(cards_xml);
            }
        }
Exemplo n.º 3
0
        private void ReadExamInfo(byte[] buffer)
        {
            int index = 0;

            examID = GetIntFromMessage(buffer, index);
            index += sizeof(int);

            memberID = GetIntFromMessage(buffer, index);
            index   += sizeof(int);

            studentCount = GetIntFromMessage(buffer, index);
            index       += sizeof(int);

            studentID = GetIntFromMessage(buffer, index);

            bool needStudents = false;

            if (File.Exists(students_xml))
            {
                ExamInfo examInfo = XMLFileManager.GetExamInfo(students_xml);
                if (examInfo.examId != examID || examInfo.studentCount != studentCount)
                {
                    needStudents = true;
                }
            }
            else
            {
                needStudents = true;
            }

            if (needStudents)
            {
                List <byte> message = new List <byte>();
                message.AddRange(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(AssistantProtocol.OpcodeNeedStudents)));
                message.AddRange(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(0)));

                byte[] msg = message.ToArray();
                SendMessage(msg);
            }
            else
            {
                XMLFileManager.SaveMemberId(students_xml, memberID);
                students = XMLFileManager.GetStudentList(students_xml);
                parentForm.Invoke(new FillStudentResultsEventHandler(parentForm.FillStudentResults), new Object[] { students });

                if (studentID != -1)
                {
                    Student.StudentUpdate stUpd = new Student.StudentUpdate();
                    stUpd.student = Student.GetStudentById(students, studentID);
                    parentForm.Invoke(new UpdateStudentEventHandler(parentForm.UpdateStudentInfo), new Object[] { stUpd.student });
                }
            }
        }
Exemplo n.º 4
0
        private void ReadStudents(byte[] buffer)
        {
            int index = 0;

            int studentsLen = IPAddress.NetworkToHostOrder(GetIntFromMessage(buffer, index));

            index += sizeof(int);

            if (File.Exists(students_xml))
            {
                File.Delete(students_xml);
            }

            FileStream fs = File.Create(students_xml);

            fs.Write(buffer, index, studentsLen);
            fs.Close();

            XMLFileManager.SaveMemberId(students_xml, memberID);

            students = XMLFileManager.GetStudentList(students_xml);
        }