Ejemplo n.º 1
0
 private void RemoveRecord(StudentDTO dto)
 {
     try
     {
         int        rowIndex = 1;
         StudentDTO currentStudent;
         for (int i = 0; i < this.dgvStudent.RowCount; i++)
         {
             var getStudentId = this.dgvStudent[1, i].Value.ToString();
             if (getStudentId.Equals(dto.StudentCode))
             {
                 dgvStudent.Rows.Remove(dgvStudent.Rows[i]);
             }
             if (i < dgvStudent.RowCount)
             {
                 this.dgvStudent[0, i].Value = rowIndex;
                 string currentStudentCode = dgvStudent[1, i].Value.ToString();
                 currentStudent = ListStudent.Where(t => t.StudentCode.Equals(currentStudentCode)).FirstOrDefault();
                 if (currentStudent != null)
                 {
                     currentStudent.NO = rowIndex;
                 }
                 rowIndex++;
             }
         }
     }
     catch (Exception ex)
     {
         Util.LogException("RemoveRecord", ex.Message);
     }
 }
Ejemplo n.º 2
0
        public List <ListStudent> ReadFileCsv(HttpPostedFileBase file)
        {
            var listStudentToCreate = new List <ListStudent>();

            if (file.ContentLength > 0)
            {
                var fileToRead = new StreamReader(file.InputStream);

                fileToRead.ReadLine().Split(',');
                while (!fileToRead.EndOfStream)
                {
                    var splits        = fileToRead.ReadLine().Split(',');
                    var createStudent = new ListStudent();

                    string matricule = Regex.Replace(splits[0], "[^0-9]", "");
                    createStudent.Matricule = Convert.ToInt32(matricule);
                    createStudent.LastName  = splits[1];
                    createStudent.FirstName = splits[2];

                    createStudent.LastName  = createStudent.LastName.Replace('"', ' ');
                    createStudent.FirstName = createStudent.FirstName.Replace('"', ' ');

                    listStudentToCreate.Add(createStudent);
                }
            }

            return(listStudentToCreate);
        }
Ejemplo n.º 3
0
        public void TestInstantiation()
        {
            ListStudent list = new ListStudent();

            Assert.NotEqual(null, list);
            Assert.Equal(null, list.Head);
        }
Ejemplo n.º 4
0
        public void TestRemoveFirstOnEmptyListThrowsListEmptyException()
        {
            // we create an empty list
            ListStudent list = new ListStudent();

            Exception ex = Assert.Throws <ListEmptyException>(() => list.removeFirst());

            Assert.Equal(ex.Message, "Unable to remove first element. List empty.");
        }
Ejemplo n.º 5
0
        public void TestReplaceOnEmptyListThrowsListEmptyException()
        {
            // we create an empty list
            ListStudent list = new ListStudent();

            Exception ex = Assert.Throws <ListEmptyException>(() => list.replace(97035, new ListElement <Student>(new Student("Fred", 27, 1987, 1.0))));

            Assert.Equal(ex.Message, "Unable to replace. List empty.");
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            UtilsCLass utils = new UtilsCLass();

            String      File = System.AppDomain.CurrentDomain.BaseDirectory + "/../../../Data.txt";
            ListStudent list = utils.createListFromFile(File);

            Console.WriteLine("Initial list: ");
            list.printList();

            try {
                Console.WriteLine("After remvoveFirst:");
                list.removeFirst();
                list.printList();
            } catch (ListElementNotFoundException e) { Console.WriteLine(e); }
            catch (ListEmptyException e) { Console.WriteLine(e); }


            Console.WriteLine("After adding Marc as last element(addAtEnd)");
            ListElement <Student> listElement = new ListElement <Student>(new Student("Marc", 23, 123456, 1.3));

            list.addAtEnd(listElement);
            list.printList();

            try {
                Console.WriteLine("After adding Melkis as first element(addAtStart)");
                ListElement <Student> listElement2 = new ListElement <Student>(new Student("Melkis", 27, 23423, 1.7));
                list.addAtStart(listElement2);
                list.printList();

                Console.WriteLine("After replacing Franck (Mat: 1470) by Fred (Mat: 1987)");
                list.replace(1470, new ListElement <Student>(new Student("Fred", 27, 1987, 1.0)));
                list.printList();
                ListStudent list2 = new ListStudent();
                // list2 is empty, exception ListEmptyException should be thrown
                list2.replace(1470, new ListElement <Student>(new Student("Fred", 27, 1987, 1.0)));
            } catch (ListElementNotFoundException e) { Console.WriteLine(e); }
            catch (ListEmptyException e) { Console.WriteLine(e); }

            // integer list now
            ListInt listInt = new ListInt();

            listInt.addAtEnd(new ListElement <int>(16));
            listInt.addAtEnd(new ListElement <int>(20));
            listInt.addAtEnd(new ListElement <int>(30));
            listInt.addAtStart(new ListElement <int>(22));
            listInt.printList();

            try {
                // element 19 does not exist in the list. should throw an exception
                listInt.replace(19, new ListElement <int>(100));
                listInt.printList();
            } catch (ListElementNotFoundException e) { Console.WriteLine(e); }
            catch (ListEmptyException e) { Console.WriteLine(e); }
        }
Ejemplo n.º 7
0
        public void TestAddAtEnd()
        {
            ListElement <Student> listElement = new ListElement <Student>(Students[0]);
            ListStudent           list        = new ListStudent();

            list.addAtEnd(listElement);

            Assert.Equal(1, list.count());
            // element should be the last one now
            Assert.Equal(Students[0], list.getLastElement().Data);
        }
Ejemplo n.º 8
0
        private void dgvStudent_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var               selectedRow = dgvStudent.CurrentCell.RowIndex;
            string            number      = dgvStudent.Rows[selectedRow].Cells[0].Value.ToString();
            string            studentCode = dgvStudent.Rows[selectedRow].Cells[1].Value.ToString();
            StudentDTO        studentDto  = ListStudent.Where(student => student.StudentCode == studentCode).FirstOrDefault();
            PointDetailMsgBox msgBox      = new PointDetailMsgBox(studentDto);

            msgBox.SubmitAPIUrl      = submissionURL;
            msgBox.PracticalExamCode = PracticalExamCode;
            msgBox.Show();
        }
Ejemplo n.º 9
0
        public void TestReplaceOnEmptyListThrowsListElementNotFoundException()
        {
            ListStudent list      = new ListStudent();
            int         matricule = 1111;

            ListElement <Student> listElement = new ListElement <Student>(Students[0]);

            // we want to test a non empty list
            list.addAtStart(listElement);

            Exception ex = Assert.Throws <ListElementNotFoundException>(() => list.replace(matricule, new ListElement <Student>(new Student("Fred", 27, 1987, 1.0))));

            Assert.Equal(ex.Message, "Student with matricule " + matricule + " not found.");
        }
Ejemplo n.º 10
0
        public ListStudent createListFromFile(String file)
        {
            Student[] students = this.loadStudents(file);

            ListStudent list = new ListStudent();

            int i = 0;

            while (students[i] != null)
            {
                list.addAtEnd(new ListElement <Student>(students[i]));
                i++;
            }

            return(list);
        }
Ejemplo n.º 11
0
        public void TestRemoveFirst()
        {
            ListElement <Student> listElement = new ListElement <Student>(Students[0]);

            ListStudent list = new ListStudent();

            list.addAtStart(listElement);
            ListElement <Student> firstListElement = list.removeFirst();

            // returned element should be the one added
            Assert.Equal(firstListElement.Data, Students[0]);
            // list should be empty
            Assert.Equal(0, list.count());
            // yeah, really empty
            Assert.Equal(null, list.Head);
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            ListStudent listStudent = new ListStudent();


            do
            {
                Console.WriteLine("Меню \r\n 1)Добавить элемент \r\n 2)Найти элемент \r\n 3)Удалить элемент \r\n 0) Закончить ");
                int x = Convert.ToInt32(Console.ReadLine());
                switch (x)
                {
                case 1:
                    Console.WriteLine("Введите номер студента");
                    int id = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Введите имя студента");
                    string NameStudent = Console.ReadLine();
                    Console.WriteLine("Введите курс студента");
                    int     course  = Convert.ToInt32(Console.ReadLine());
                    Student student = new Student(id, NameStudent, course);
                    listStudent.AddStudent(student);
                    listStudent.ShowList();

                    break;

                case 2:
                    string find = Console.ReadLine();
                    listStudent.FindStudent(find);
                    break;

                case 3:
                    int index = Convert.ToInt32(Console.ReadLine());
                    listStudent.DeleteStudent(index);
                    listStudent.ShowList();
                    break;

                case 0:
                    Console.WriteLine("Конец");
                    break;

                default:
                    Console.WriteLine("Нет такого");
                    break;
                }
            } while (true);
        }
Ejemplo n.º 13
0
    // Use this for initialization
    void Awake()
    {
        //busca los objetos con los tags correspondientes
        ScheduleList       = GameObject.FindWithTag("ScheduleList");
        addSignatureCanvas = GameObject.FindWithTag("AddSignature");
        menu         = GameObject.FindWithTag("Menu");
        canvas_login = GameObject.FindWithTag("LogIn");

        //Instanciamos objeto de la clase ListStudent, aqui se agregara los estudiantes registrados
        students = new ListStudent();

        //Set Cavas(UI) como modo  inicio
        canvas_login.SetActive(false);
        menu.SetActive(false);
        addSignatureCanvas.SetActive(false);
        ScheduleList.SetActive(false);
        //Estudiante en base de datos pruebas
    }
        public void createList_post_can_not_create_two_profils_with_two_same_matricule()
        {
            var listStudents = _fixture.CreateMany <ListStudent>(3).ToList();
            var liststudent  = new ListStudent
            {
                FirstName = "Bob",
                LastName  = "Patrick",
                Matricule = listStudents[0].Matricule
            };

            coordinatorController.CreateListPost();
            listStudents.Add(liststudent);
            coordinatorController.TempData["listStudent"] = listStudents;

            coordinatorController.CreateListPost();

            studentRepository.DidNotReceive().Add(Arg.Is <Student>(x => x.FirstName == listStudents[3].FirstName));
            studentRepository.DidNotReceive().Add(Arg.Is <Student>(x => x.LastName == listStudents[3].LastName));
        }
Ejemplo n.º 15
0
        public void TestAddAtStart()
        {
            ListElement <Student> listElement  = new ListElement <Student>(Students[0]);
            ListElement <Student> listElement2 = new ListElement <Student>(Students[1]);
            ListElement <Student> listElement3 = new ListElement <Student>(Students[2]);
            ListElement <Student> listElement4 = new ListElement <Student>(Students[3]);

            ListStudent list = new ListStudent();

            list.addAtStart(listElement);
            list.addAtStart(listElement2);
            list.addAtStart(listElement3);
            list.addAtStart(listElement4);

            // there should be 4 elements in the list
            Assert.Equal(4, list.count());
            // last element to be added should be head
            Assert.Equal(listElement4.Data, list.Head.Data);
        }
Ejemplo n.º 16
0
        private void dgvStudent_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int columnClicked = e.ColumnIndex;
            int rowClicked    = e.RowIndex;

            if (ListStudent.Count == 0 || rowClicked < 0 || rowClicked > ListStudent.Count - 1)
            {
                return;
            }
            if (columnClicked == dgvStudent.Columns[nameof(StudentDTO.Close)].Index && rowClicked >= 0)
            {
                string       studentCode = dgvStudent.Rows[rowClicked].Cells[dgvStudent.Columns[nameof(StudentDTO.StudentCode)].Index].Value.ToString();
                DialogResult result      = MessageBox.Show(Constant.REMOVE_STUDENT_MESSAGE + studentCode, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    StudentDTO removeStudent = ListStudent.Where(f => f.StudentCode == studentCode).FirstOrDefault();
                    ListStudent.Remove(removeStudent);
                    ResetDataGridViewDataSourceWithDto(removeStudent, Constant.ACTION_REMOVE);
                }
            }
            //else if (Constant.PRACTICAL_STATUS[2].Equals(PracticalExamStatus))
            //{
            //    StudentDTO dto = ListStudent[rowClicked];
            //    DialogResult result = MessageBox.Show(Constant.REEVALUATE_STUDENT_MESSAGE + dto.StudentCode, "RE-Evaluate", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            //    if (result == DialogResult.Yes)
            //    {
            //        var appDomainDir = Util.GetProjectDirectory();
            //        var destinationPath = Path.Combine(appDomainDir + Constant.SCRIPT_FILE_PATH);
            //        string listStudentPath = destinationPath + "\\" + PracticalExamCode + "\\" + Constant.SUMISSION_FOLDER_NAME;
            //        listStudentPath = listStudentPath + "\\" + dto.StudentCode + Constant.ZIP_EXTENSION;
            //        Task.Run(async delegate
            //        {
            //            string message = await SendFile(listStudentPath, dto.StudentCode, dto.ScriptCode);
            //            Console.WriteLine(message);
            //        }
            //        );
            //    }
            //}
        }
Ejemplo n.º 17
0
        // Return submission API - document questions - expired time to student
        private void ReturnWebserviceURL(string ipAddress, int port, string studentCode)
        {
            try
            {
                // Student's TCP information
                TcpClient tcpClient = new System.Net.Sockets.TcpClient(ipAddress, port);

                string scriptCode = "";
                string message;

                if (IsConnected(ipAddress))
                {
                    message = Constant.EXISTED_IP_MESSAGE;
                    Util.SendMessage(System.Text.Encoding.Unicode.GetBytes(message), tcpClient);
                }
                else
                {
                    count++;
                    bool       isSent              = false;
                    StudentDTO student             = ListStudent.Where(t => t.StudentCode == studentCode).FirstOrDefault();
                    StudentDTO studentDisconnected = ListStudentBackUp.Where(t => t.StudentCode == studentCode).FirstOrDefault();
                    if (student != null)
                    {
                        student.TcpClient = tcpClient;
                        student.Status    = Constant.STATUSLIST[0];

                        // Exam code
                        scriptCode = student.ScriptCode;
                        ResetDataGridViewDataSourceWithDto(student, Constant.ACTION_UPDATE);
                    }
                    else if (studentDisconnected != null)
                    {
                        StudentDTO studentDTO = (StudentDTO)studentDisconnected.Shallowcopy();
                        studentDTO.TcpClient = tcpClient;
                        studentDTO.Status    = Constant.STATUSLIST[0];
                        studentDTO.NO        = ListStudent.Count + 1;
                        ListStudent.Add(studentDTO);
                        scriptCode = studentDTO.ScriptCode;
                        ResetDataGridViewDataSourceWithDto(studentDTO, Constant.ACTION_ADD);
                    }
                    else
                    {
                        MessageBox.Show("Student not in class is connecting");
                        return;
                    }
                    //ResetDataGridViewDataSource();
                    while (!isSent)
                    {
                        try
                        {
                            // Cập nhật giao diện ở đây
                            message = "=" + submissionURL + "=" + scriptCode + "=" + PracticalExamCode;
                            //SendMessage(ipAddress, port, message);
                            var messageEncode = Util.Encode(message, "SE1267");
                            messageEncode = Constant.RETURN_URL_CODE + messageEncode;
                            Util.SendMessage(System.Text.Encoding.Unicode.GetBytes(messageEncode), tcpClient);
                            //byte[] bytes = File.ReadAllBytes(@"D:\Capstone_WF_Lecturer\PE2A_WF_LECTURER\submission\PracticalExams\Practical_Java_SE1269_05022020\TestScripts\Java_SE1269_05_02_2020_De1.java");
                            //Util.sendMessage(bytes, tcpClient);
                            isSent = true;
                        }
                        catch (Exception e)
                        {
                            // resent message
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Util.LogException("ReturnWebserviceURL", ex.Message);
            }
        }
Ejemplo n.º 18
0
        public ActionResult Member(ListStudent ls, string searchString, string searchCheck, string selectString2, string selectString3)
        {
            var                context      = new MSSEntities();
            List <string>      NoEnrollment = new List <string>();
            List <ListStudent> s            = new List <ListStudent>();

            var CourseStudent = (from a in context.Student_Course_Log
                                 select new
            {
                Roll = a.Roll
            }).Distinct().ToList();
            var Student = (from a in context.Student_Course_Log
                           join b in context.Courses on a.Course_ID equals b.Course_ID
                           join c in context.Specifications on b.Specification_ID equals c.Specification_ID
                           join d in context.Subjects on c.Subject_ID equals d.Subject_ID
                           select new
            {
                Roll = a.Roll
            }).Distinct().ToList();

            foreach (var cs in CourseStudent)
            {
                int temp = 0;
                foreach (var st in Student)
                {
                    if (cs.Roll.Equals(st.Roll))
                    {
                        temp = 0;
                        break;
                    }
                    else
                    {
                        temp = 1;
                    }
                }
                if (temp == 1)
                {
                    NoEnrollment.Add(cs.Roll);
                }
            }
            if (!String.IsNullOrEmpty(searchCheck))
            {
                int rowNo = 0;
                foreach (var b in NoEnrollment)
                {
                    List <ListStudent> infoStudent = (from c in context.Students
                                                      where c.Roll == b
                                                      select new
                    {
                        Email = c.Email,
                        Roll = c.Roll,
                        Full_Name = c.Full_Name,
                        Campus = c.Campus
                    }).ToList().Select(p => new ListStudent
                    {
                        STT       = rowNo++,
                        Email     = p.Email,
                        Roll      = p.Roll,
                        Full_Name = p.Full_Name,
                        Campus    = p.Campus
                    }).ToList();
                    List <string> subjectStudent = (from c in context.Students
                                                    join d in context.Subject_Student on c.Roll equals d.Roll
                                                    join e in context.Subjects on d.Subject_ID equals e.Subject_ID
                                                    where c.Roll == b
                                                    select e.Subject_Name).ToList();


                    foreach (var i in infoStudent)
                    {
                        s.Add(new ListStudent {
                            STT = rowNo, Email = i.Email, Roll = i.Roll, Full_Name = i.Full_Name, Campus = i.Campus, ListSubject = subjectStudent
                        });
                    }
                }
                if (!String.IsNullOrEmpty(searchString))
                {
                    s = s.Where(a => a.Roll.Contains(searchString)).ToList();
                }
                if (!String.IsNullOrEmpty(selectString2))
                {
                    s = s.Where(a => a.Campus.Contains(selectString2)).ToList();
                }
                if (!String.IsNullOrEmpty(selectString3))
                {
                    s = s.Where(a => a.ListSubject.Contains(selectString3)).ToList();
                }
            }
            var listCampus = (from a in context.Campus
                              select a.Campus_ID).ToList();
            var listSubject = (from a in context.Subjects
                               select a.Subject_Name).ToList();
            List <SelectListItem> selectCp = new List <SelectListItem>();
            List <SelectListItem> selectSj = new List <SelectListItem>();

            selectCp.Add(new SelectListItem
            {
                Text  = "--Select Campus--",
                Value = ""
            });
            foreach (var a in listCampus)
            {
                selectCp.Add(new SelectListItem
                {
                    Text  = a,
                    Value = a
                });
            }

            selectSj.Add(new SelectListItem
            {
                Text  = "--Select Subject--",
                Value = ""
            });
            foreach (var a in listSubject)
            {
                selectSj.Add(new SelectListItem
                {
                    Text  = a,
                    Value = a
                });
            }
            ViewBag.SelectString3 = selectSj;
            ViewBag.SelectString2 = selectCp;
            ls.ls1 = s;
            //rp.Students = s;
            return(View("Member", ls));
        }
Ejemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     studients    = new ListStudent();
     canvas_login = GameObject.FindGameObjectWithTag("singUp");
 }