private void ResultForm_Load(object sender, EventArgs e)
        {
            rooms         = roomReader.GetRooms();
            courses       = courseReader.GetCourses();
            prelectors    = prelectorReader.GetPrelectors();
            studentGroups = studentGroupReader.GetStudentGroups();

            courseClassReader.ResetData();
            if (_isExamProblem)
            {
                courseClasses = courseClassReader.GetCourseClasses();
            }
            else
            {
                courseClasses = courseClassReader.GetCourseClassesWithoutRoomSplit();
            }

            prelectors    = prelectorReader.UpdateCourseClasses(courseClasses);
            studentGroups = studentGroupReader.UpdateCourseClasses(courseClasses);

            Configuration.GetInstance.InitializeDate(prelectors, studentGroups, courses, rooms, courseClasses);

            btnPause.Enabled = false;
            btnStop.Enabled  = false;

            if (Algorithm.Configuration.GetInstance.GetNumberOfRooms() > 0)
            {
                _createGridView = new CreateDataGridViews(Configuration.GetInstance.Rooms, this);
                Schedule prototype = new Schedule(int.Parse(PARAMETER_NUMBER_OF_CROSSOVER_POINTS), int.Parse(PARAMETER_MUTAITION_SIZE),
                                                  int.Parse(PARAMETER_CROSSOVER_PROBABILITY), int.Parse(PARAMETER_MUTAITION_PROBABILITY), _isExamProblem);
                Schedule.ScheduleObserver sso = new Schedule.ScheduleObserver();
                sso.SetWindow(_createGridView);

                _algorithm = new Algorithm.Algorithm(int.Parse(PARAMETER_NUMBER_OF_CHROMOSOMES), int.Parse(PARAMETER_REPLACE_BY_GENERATION),
                                                     int.Parse(PARAMETER_TRACK_BEST), prototype, sso, _isExamProblem);

                _state = ThreadState.Unstarted;
                timerWorkingSet.Start();
            }
            else
            {
                MessageBox.Show("Not found any room!", "Number of Rooms Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                timerWorkingSet.Stop();
                _algorithm = null;
                Dispose();
                return;
            }

            if (Configuration.GetInstance.GetNumberOfCourseClasses() <= 0)
            {
                btnStart.Enabled = false;
            }
        }
Esempio n. 2
0
        private void CollectData()
        {
            _roomReader.ResetData();
            _courseReader.ResetData();
            _prelectorReader.ResetData();
            _courseClassReader.ResetData();
            _studentGroupReader.ResetData();

            try
            {
                _rooms = _roomReader.GetRooms();
            } catch (Exception _ex)
            {
                MessageBox.Show("Sınıf verileri okunurken hata oluştu!", "Veri Okuma Hatası", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            try
            {
                _courses = _courseReader.GetCourses();
            }
            catch (Exception _ex)
            {
                MessageBox.Show("Ders verileri okunurken hata oluştu!", "Veri Okuma Hatası", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            try
            {
                _prelectors = _prelectorReader.GetPrelectors();
            }
            catch (Exception _ex)
            {
                MessageBox.Show("Öğretim görevlisi verileri okunurken hata oluştu!", "Veri Okuma Hatası", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            try
            {
                _courseClasses = _courseClassReader.GetCourseClasses();
            }
            catch (Exception _ex)
            {
                MessageBox.Show("Ders oturumu verileri okunurken hata oluştu!", "Veri Okuma Hatası", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            try
            {
                _studentGroups = _studentGroupReader.GetStudentGroups();
            }
            catch (Exception _ex)
            {
                MessageBox.Show("Öğrenci grubu verileri okunurken hata oluştu!", "Veri Okuma Hatası", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            UpdateDashboard();
        }
        private void SaveRoomsSchedule(Schedule schedule, List <KeyValuePair <CourseClass, int> > courseClasses)
        {
            List <Room> _allRooms   = _roomReader.GetRooms();
            int         _sheetCount = ((int)_allRooms.Count / 10) + 1;

            int _roomsPosition = 0;

            for (int i = 1; i <= _sheetCount; i++)
            {
                int _roomCountInThisSheet = Math.Min(10, _allRooms.Count - _roomsPosition);
                if (_roomCountInThisSheet == 0)
                {
                    break;
                }

                string         _sheetName = SHEET_NAME_ROOMS + (i > 1 ? $" {i}" : "");
                ExcelWorksheet _ws        = CreateWorksheet(_sheetName);
                List <Room>    _rooms     = _allRooms.GetRange(_roomsPosition, _roomCountInThisSheet);
                _roomsPosition += _roomCountInThisSheet;

                int _startRow = 0;
                _rooms.ForEach(r =>
                {
                    CreateTable(_ws, r.Name, _startRow);
                    _startRow += TIME_SPANS.Length + 1 + TABLE_ROW_SPACING;
                });

                int _numberOfRooms = _rooms.Count;
                int _daySize       = schedule.day_Hours * _numberOfRooms;

                foreach (KeyValuePair <CourseClass, int> it in courseClasses)
                {
                    int _pos    = it.Value;
                    int _day    = _pos / _daySize;
                    int _time   = _pos % _daySize;
                    int _roomId = _time / schedule.day_Hours;
                    _startRow = _roomId * (TABLE_ROW_SPACING + 1 + TIME_SPANS.Length);
                    _time     = (_time % schedule.day_Hours) + _startRow;
                    int _dur = it.Key.Duration;

                    CourseClass _cc   = it.Key;
                    Room        _room = Algorithm.Configuration.GetInstance.GetRoomById(_roomId);

                    string _groups_Name = "";
                    foreach (var group in _cc.StudentGroups)
                    {
                        _groups_Name += group.Name + "  ";
                    }
                    _groups_Name = _groups_Name.Trim();

                    _ws.Cells[_time + 1, _day + 1].Value = $"{_cc.Course.Name}\n{_cc.Prelector.Name}\n{_groups_Name}";
                    _ws.Cells[_time + 1, _day + 1].Style = _anyCellStyle;

                    // Merge Cells
                    try
                    {
                        if (_cc.Duration > 1)
                        {
                            _ws.Cells.GetSubrangeAbsolute(_time + 1, _day + 1, _time + _dur, _day + 1).Merged = true;
                        }
                        _ws.Cells[_time + 1, _day + 1].Style = _anyCellStyle;
                    }
                    catch
                    {
                        _ws.Cells[_time + 1, _day + 1].Style.Font.Color = Color.DarkRed;
                    }
                }
            }
        }