public CourseBlock(CourseBlock i_Block)
        {
            m_CourseId = i_Block.ID;
            m_GroupNumberForFirstClass = i_Block.GroupNumberForFirstClass;
            m_TypeOfFirstClass = i_Block.TypeOfFirstClass;
            m_StartTimeSlotOfFirstClass = i_Block.StartTimeSlotOfFirstClass;
            m_EndTimeSlotOfFirstClass = i_Block.EndTimeSlotOfFirstClass;
            m_TeacherCodeOfFirstClass = i_Block.TeacherCodeOfFirstClass;
            m_GroupNumberForSecondClass = i_Block.GroupNumberForSecondClass;
            m_TypeOfSecondClass = i_Block.TypeOfSecondClass;
            m_StartTimeSlotOfSecondClass = i_Block.StartTimeSlotOfSecondClass;
            m_EndTimeSlotOfSecondClass = i_Block.EndTimeSlotOfSecondClass;
            m_TeacherCodeOfSecondClass = i_Block.TeacherCodeOfSecondClass;
            m_GroupNumberForThirdClass = i_Block.GroupNumberForThirdClass;
            m_TypeOfThirdClass = i_Block.TypeOfThirdClass;
            m_StartTimeSlotOfThirdClass = i_Block.StartTimeSlotOfThirdClass;
            m_EndTimeSlotOfThirdClass = i_Block.EndTimeSlotOfThirdClass;
            m_TeacherCodeOfThirdClass = i_Block.TeacherCodeOfThirdClass;

            this.CourseCredit = i_Block.CourseCredit;
            this.CourseTitle = i_Block.CourseTitle;
            this.StartTimeSlotOfFirstClassEx = i_Block.StartTimeSlotOfFirstClassEx;
            this.EndTimeSlotOfFirstClassEx = i_Block.EndTimeSlotOfFirstClassEx;
            this.TeacherNameOfFirstClass = i_Block.TeacherNameOfFirstClass;
            this.StartTimeSlotOfSecondClassEx = i_Block.StartTimeSlotOfSecondClassEx;
            this.EndTimeSlotOfSecondClassEx = i_Block.EndTimeSlotOfSecondClassEx;
            this.TeacherNameOfSecondClass = i_Block.TeacherNameOfSecondClass;
            this.StartTimeSlotOfThirdClassEx = i_Block.StartTimeSlotOfThirdClassEx;
            this.EndTimeSlotOfThirdClassEx = i_Block.EndTimeSlotOfThirdClassEx;
            this.TeacherNameOfThirdClass = i_Block.TeacherNameOfThirdClass;
        }
 public VectorOfCourses(int[] i_arrayOfNumberOfCourses, List<List<CourseBlock>> i_BlockList, Student i_Student)
 {
     //MySqlConnection conn = null;
     //MySqlDataReader rdr = null;
     //List<int> testlist = new List<int>();
     int[] rand;
     m_Vector = new List<CourseBlock>();
     int count = 0;
     for (; count < i_Student.numberOfRequiredCourseTheStudentWantToTake; count++)
     {
         //testlist.Add(rnd.Next(i_BlockList[count].Count)); ;
         CourseBlock newBlock = new CourseBlock(i_BlockList[count][rnd.Next(i_BlockList[count].Count)]);
         m_Vector.Add(newBlock);
     }
     selectRandomCoursesPositions(i_Student.numberOfElectiveCourseTheStudentWantToTake, out rand);
     for (count = 0; count < i_Student.numberOfElectiveCourseTheStudentWantToTake; count++)
     {
         CourseBlock newBlock = new CourseBlock(i_BlockList[i_Student.numberOfRequiredCourseTheStudentWantToTake + rand[count]][rnd.Next(i_BlockList[i_Student.numberOfRequiredCourseTheStudentWantToTake + rand[count]].Count)]);
         m_Vector.Add(newBlock);
     }
     rateVector(i_Student);
 }
        private int CountOverlaps(CourseBlock block1, CourseBlock block2)
        {
            int count = 0;

            // First/First
            if (IsOveralap(block1.StartTimeSlotOfFirstClass, block1.EndTimeSlotOfFirstClass, block2.StartTimeSlotOfFirstClass, block2.EndTimeSlotOfFirstClass))
                count++;

            // First/Second
            if (IsOveralap(block1.StartTimeSlotOfFirstClass, block1.EndTimeSlotOfFirstClass, block2.StartTimeSlotOfSecondClass, block2.EndTimeSlotOfSecondClass))
                count++;

            // First/Third
            if (IsOveralap(block1.StartTimeSlotOfFirstClass, block1.EndTimeSlotOfFirstClass, block2.StartTimeSlotOfThirdClass, block2.EndTimeSlotOfThirdClass))
                count++;

            ////

            // Second/First
            //if (IsOveralap(block1.StartTimeSlotOfSecondClass, block1.EndTimeSlotOfSecondClass, block2.StartTimeSlotOfFirstClass, block2.EndTimeSlotOfFirstClass))
            //    count++;

            // Second/Second
            if (IsOveralap(block1.StartTimeSlotOfSecondClass, block1.EndTimeSlotOfSecondClass, block2.StartTimeSlotOfSecondClass, block2.EndTimeSlotOfSecondClass))
                count++;

            // Second/Third
            if (IsOveralap(block1.StartTimeSlotOfSecondClass, block1.EndTimeSlotOfSecondClass, block2.StartTimeSlotOfThirdClass, block2.EndTimeSlotOfThirdClass))
                count++;

            ////

            // Third/First
            //if (IsOveralap(block1.StartTimeSlotOfThirdClass, block1.EndTimeSlotOfThirdClass, block2.StartTimeSlotOfFirstClass, block2.EndTimeSlotOfFirstClass))
            //    count++;

            // Third/Second
            //if (IsOveralap(block1.StartTimeSlotOfThirdClass, block1.EndTimeSlotOfThirdClass, block2.StartTimeSlotOfSecondClass, block2.EndTimeSlotOfSecondClass))
            //    count++;

            // Third/Third
            if (IsOveralap(block1.StartTimeSlotOfThirdClass, block1.EndTimeSlotOfThirdClass, block2.StartTimeSlotOfThirdClass, block2.EndTimeSlotOfThirdClass))
                count++;

            return count;
        }
 public void removeCourse(CourseBlock i_Course)
 {
     m_Vector.Remove(i_Course);
 }
 public bool addCourse(CourseBlock i_course)
 {
     if (m_Vector.Count >= k_MaximumNumberOfCourses)
     { return false; }
     else
     {
     m_Vector.Add(i_course);
     return true;
     }
 }
Esempio n. 6
0
        private List<AgendaItem> ExtractAgendaItemsFromBlock(CourseBlock b)
        {
            List<AgendaItem> items = new List<AgendaItem>();

            // First class (if exists)
            if (b.HasFirstClass)
            {
                AgendaItem first = new AgendaItem()
                {
                    CourseNumber = b.ID,
                    CourseName = b.CourseTitle,
                    CourseType = b.TypeOfFirstClass,
                    TeacherName = b.TeacherNameOfFirstClass,
                    GroupNumber = b.GroupNumberForFirstClass,
                    StartTime = b.StartTimeSlotOfFirstClassEx.Value,
                    EndTime = b.EndTimeSlotOfFirstClassEx.Value,
                    Day = b.DayOfFirstClass,
                    CourseCredit = b.CourseCredit
                };
                items.Add(first);
            }

            // Second class (if exists)
            if (b.HasSecondClass)
            {
                AgendaItem second = new AgendaItem()
                {
                    CourseNumber = b.ID,
                    CourseName = b.CourseTitle,
                    CourseType = b.TypeOfSecondClass,
                    TeacherName = b.TeacherNameOfSecondClass,
                    GroupNumber = b.GroupNumberForSecondClass,
                    StartTime = b.StartTimeSlotOfSecondClassEx.Value,
                    EndTime = b.EndTimeSlotOfSecondClassEx.Value,
                    Day = b.DayOfSecondClass,
                    CourseCredit = b.CourseCredit
                };
                items.Add(second);
            }

            // Third class (if exists)
            if (b.HasThirdClass)
            {
                AgendaItem third = new AgendaItem()
                {
                    CourseNumber = b.ID,
                    CourseName = b.CourseTitle,
                    CourseType = b.TypeOfThirdClass,
                    TeacherName = b.TeacherNameOfThirdClass,
                    GroupNumber = b.GroupNumberForThirdClass,
                    StartTime = b.StartTimeSlotOfThirdClassEx.Value,
                    EndTime = b.EndTimeSlotOfThirdClassEx.Value,
                    Day = b.DayOfThirdClass,
                    CourseCredit = b.CourseCredit
                };
                items.Add(third);
            }

            return items;
        }
        void UpdateDataOfBlocksFromDB()
        {
            int i=0;
            MySqlConnection conn = null;
            MySqlDataReader rdr = null;

            for (; i < m_arrayOfCoursesNumbers.Length; i++)
            {
                List<CourseBlock> listBlock = new List<CourseBlock>();
                try
                {
                    conn = new MySqlConnection(k_CS);
                    conn.Open();
                    //string quaery = "select * FROM sql217024.coursesblocks where idcourses = " + m_arrayOfCoursesNumbers[i];
                    string query = string.Format(@"SELECT blocks.*,
                                                    courses.TitleCourses, credits.courseCredit,
                                                    teachers1.teacherName AS 'teacher1', starttime1.StartTime AS 'startTime1', endtime1.EndTime AS 'endTime1',
                                                    teachers2.teacherName AS 'teacher2', starttime2.StartTime AS 'startTime2', endtime2.EndTime AS 'endTime2',
                                                    teachers3.teacherName AS 'teacher3', starttime3.StartTime AS 'startTime3', endtime3.EndTime AS 'endTime3'
                                                    FROM sql217024.coursesblocks blocks
                                                    LEFT JOIN sql217024.coursescredit credits ON blocks.idCourses = credits.CourseID
                                                    LEFT JOIN sql217024.coursesnames courses ON blocks.idCourses = courses.idCourses
                                                    LEFT JOIN sql217024.teachersmapping teachers1 ON blocks.Teacher1 = teachers1.TeacherID
                                                    LEFT JOIN sql217024.teachersmapping teachers2 ON blocks.Teacher2 = teachers2.TeacherID
                                                    LEFT JOIN sql217024.teachersmapping teachers3 ON blocks.Teacher3 = teachers3.TeacherID
                                                    LEFT JOIN sql217024.timemapping starttime1 ON blocks.startTimeSlot1 = starttime1.TimeID
                                                    LEFT JOIN sql217024.timemapping starttime2 ON blocks.startTimeSlot2 = starttime2.TimeID
                                                    LEFT JOIN sql217024.timemapping starttime3 ON blocks.startTimeSlot3 = starttime3.TimeID
                                                    LEFT JOIN sql217024.timemapping endtime1 ON blocks.endTimeSlot1 = endtime1.TimeID
                                                    LEFT JOIN sql217024.timemapping endtime2 ON blocks.endTimeSlot2 = endtime2.TimeID
                                                    LEFT JOIN sql217024.timemapping endtime3 ON blocks.endTimeSlot3 = endtime3.TimeID
                                                    WHERE blocks.idCourses = {0}", m_arrayOfCoursesNumbers[i]);

                    MySqlCommand cmd = new MySqlCommand(query, conn);

                    rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        CourseBlock newBlock = null;

                        // No third class
                        if (rdr.IsDBNull(12))
                        {
                            // No second class
                            if (rdr.IsDBNull(7))
                            {
                                newBlock = new CourseBlock(rdr.GetInt32(1), rdr.GetInt32(2), rdr.GetInt32(3), rdr.GetInt32(4), rdr.GetInt32(5), rdr.GetInt32(6), -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
                            }
                            else
                            {
                                newBlock = new CourseBlock(rdr.GetInt32(1), rdr.GetInt32(2), rdr.GetInt32(3), rdr.GetInt32(4), rdr.GetInt32(5), rdr.GetInt32(6), rdr.GetInt32(7), rdr.GetInt32(8), rdr.GetInt32(9), rdr.GetInt32(10), rdr.GetInt32(11), -1, -1, -1, -1, -1);
                            }
                        }
                        else
                        {
                            newBlock = new CourseBlock(rdr.GetInt32(1), rdr.GetInt32(2), rdr.GetInt32(3), rdr.GetInt32(4), rdr.GetInt32(5), rdr.GetInt32(6), rdr.GetInt32(7), rdr.GetInt32(8), rdr.GetInt32(9), rdr.GetInt32(10), rdr.GetInt32(11), rdr.GetInt32(12), rdr.GetInt32(13), rdr.GetInt32(14), rdr.GetInt32(15), rdr.GetInt32(16));
                        }

                        // First class data (always exists)
                        newBlock.StartTimeSlotOfFirstClassEx = DateTime.Parse(rdr.GetString("startTime1"));
                        newBlock.EndTimeSlotOfFirstClassEx = DateTime.Parse(rdr.GetString("endTime1"));
                        newBlock.TeacherNameOfFirstClass = rdr.GetString("teacher1");

                        // Second class data
                        if (newBlock.StartTimeSlotOfSecondClass != -1)
                        {
                            newBlock.StartTimeSlotOfSecondClassEx =  DateTime.Parse(rdr.GetString("startTime2"));
                            newBlock.EndTimeSlotOfSecondClassEx = DateTime.Parse(rdr.GetString("endTime2"));
                            newBlock.TeacherNameOfSecondClass = rdr.GetString("teacher2");
                        }

                        // Third class data
                        if (newBlock.StartTimeSlotOfThirdClass != -1)
                        {
                            newBlock.StartTimeSlotOfThirdClassEx =  DateTime.Parse(rdr.GetString("startTime3"));
                            newBlock.EndTimeSlotOfThirdClassEx = DateTime.Parse(rdr.GetString("endTime3"));
                            newBlock.TeacherNameOfThirdClass = rdr.GetString("teacher3");
                        }

                        newBlock.CourseCredit = rdr.GetInt32("courseCredit");
                        newBlock.CourseTitle = rdr.GetString("TitleCourses");

                        // Add to list
                        listBlock.Add(newBlock);

                    }
                }

                catch (MySqlException ex)
                {
                    Console.WriteLine("Error: {0}", ex.ToString());

                }
                finally
                {
                    if (rdr != null)
                    {
                        rdr.Close();
                    }

                    if (conn != null)
                    {
                        conn.Close();
                    }

                }
                addNullCourse(listBlock, m_arrayOfCoursesNumbers[i]);
                courseBlockDB.Add(listBlock);
                }
        }
 private bool isCourseInVector(CourseBlock i_CourseBlock, List<CourseBlock> i_ListOfCourses)
 {
     int i;
     bool res = false;
     for (i = 0; i < i_ListOfCourses.Count; i++)
     {
         if ((i_CourseBlock.ID == i_ListOfCourses[i].ID) && (i_CourseBlock.StartTimeSlotOfFirstClass == i_ListOfCourses[i].StartTimeSlotOfFirstClass) && (i_CourseBlock.StartTimeSlotOfSecondClass == i_ListOfCourses[i].StartTimeSlotOfSecondClass) && (i_CourseBlock.StartTimeSlotOfThirdClass == i_ListOfCourses[i].StartTimeSlotOfThirdClass))
         {
             res = true;
         }
     }
     return res;
 }