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;
            }
        }
示例#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 SavePrelectorsSchedule(Schedule schedule, List <KeyValuePair <CourseClass, int> > courseClasses)
        {
            List <Prelector> _allPrelectors = _prelectorReader.GetPrelectors();
            int _sheetCount = ((int)_allPrelectors.Count / 10) + 1;

            int _prelectorsPosition = 0;

            for (int i = 1; i <= _sheetCount; i++)
            {
                int _prelectorCountInThisSheet = Math.Min(10, _allPrelectors.Count - _prelectorsPosition);
                if (_prelectorCountInThisSheet == 0)
                {
                    break;
                }

                string           _sheetName  = SHEET_NAME_PRELECTORS + (i > 1 ? $" {i}" : "");
                ExcelWorksheet   _ws         = CreateWorksheet(_sheetName);
                List <Prelector> _prelectors = _allPrelectors.GetRange(_prelectorsPosition, _prelectorCountInThisSheet);
                _prelectorsPosition += _prelectorCountInThisSheet;

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

                int _daySize = schedule.day_Hours * schedule.day_count;
                _prelectors.ForEach(pre =>
                {
                    foreach (KeyValuePair <CourseClass, int> it in courseClasses.Where(cc => cc.Key.Prelector.Equals(pre)).ToList())
                    {
                        int _pos     = it.Value;
                        int _roomId  = _pos / _daySize;
                        int _dayTime = _pos % _daySize;
                        int _day     = _dayTime / schedule.day_Hours;
                        _startRow    = _prelectors.IndexOf(pre) * (TABLE_ROW_SPACING + 1 + TIME_SPANS.Length);
                        int _time    = (_dayTime % 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 gs in _cc.StudentGroups)
                        {
                            _groups_Name += gs.Name + "  ";
                        }
                        _groups_Name = _groups_Name.Trim();

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

                        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;
                        }
                    }
                });
            }
        }