public TeacherSchedule(Form antecedent, Schedule schedule)
        {
            InitializeComponent();

            _antecedent = antecedent;
            _schedule = schedule;
        }
Esempio n. 2
0
        public SettingsForm(Form antecedent, Schedule schedule)
        {
            InitializeComponent();

            Icon = Properties.Resources.settings1;

            updateInterval.Items.AddRange(_updateIntervalDictionary.Keys.ToArray());

            _schedule = schedule;
            _antecedent = antecedent;
            _autoStart = SettingsCore.Data["autoStart"];
        }
Esempio n. 3
0
        public Changes(Form antecedent, Schedule schedule, int groupId)
        {
            InitializeComponent();

            Icon = Resources.diffIcon;

            _uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            _schedule = schedule;
            _initialGroupId = groupId;
            _groupId = groupId;
            _antecedent = antecedent;
        }
Esempio n. 4
0
        public static List<Lesson> GetDailySchedule(Schedule s, int groupId, DateTime date, bool limitToExactGroup = false)
        {
            List<Lesson> result;
            if (limitToExactGroup)
            {
                result = s.lessons
                    .Where(l =>
                        (l.TeacherForDiscipline.Discipline.StudentGroup.StudentGroupId == groupId) &&
                        (l.Calendar.Date == date))
                    .OrderBy(l => l.Ring.Time.TimeOfDay)
                    .ToList();
            }
            else
            {
                var studentIds = s.studentsInGroups
                    .Where(sig => sig.StudentGroup.StudentGroupId == groupId)
                    .Select(stig => stig.Student.StudentId)
                    .ToList();

                var groupIds = s.studentsInGroups
                    .Where(sig => studentIds.Contains(sig.Student.StudentId))
                    .Select(stig => stig.StudentGroup.StudentGroupId)
                    .Distinct()
                    .ToList();

                result = s.lessons
                    .Where(l =>
                        (groupIds.Contains(l.TeacherForDiscipline.Discipline.StudentGroup.StudentGroupId)) &&
                        (l.Calendar.Date.Date == date.Date) &&
                        (l.IsActive))
                    .OrderBy(l => l.Ring.Time.TimeOfDay)
                    .ToList();

            }

            return result;
        }
Esempio n. 5
0
        public static Schedule FromFileSaveSchedule(FileSaveSchedule fss)
        {
            var result = new Schedule
            {
                auditoriums = new List<Auditorium>(),
                calendars = new List<Calendar>(),
                disciplines = new List<Discipline>(),
                lessons = new List<Lesson>(),
                rings = new List<Ring>(),
                students = new List<Student>(),
                studentGroups = new List<StudentGroup>(),
                studentsInGroups = new List<StudentsInGroups>(),
                teachers = new List<Teacher>(),
                teacherForDisciplines = new List<TeacherForDiscipline>(),

                configOptions = new List<ConfigOption>(),
                lessonLogEvents = new List<LessonLogEvent>()
            };

            foreach (var a in fss.auditoriums)
            {
                result.auditoriums.Add(a);
            }

            foreach (var c in fss.calendars)
            {
                result.calendars.Add(new Calendar
                    {
                        CalendarId = c.CalendarId,
                        Date = new DateTime(
                            int.Parse(c.Date.Substring(6,4)),
                            int.Parse(c.Date.Substring(3,2)),
                            int.Parse(c.Date.Substring(0,2))
                        )
                    }
                );
            }

            foreach (var r in fss.rings)
            {
                result.rings.Add(new Ring
                {
                    RingId = r.RingId,
                    Time = DateTime.ParseExact(r.Time, "H:mm", CultureInfo.InvariantCulture)
                }
                );
            }

            foreach (var sg in fss.studentGroups)
            {
                result.studentGroups.Add(sg);
            }

            foreach (var t in fss.teachers)
            {
                result.teachers.Add(t);
            }

            foreach (var co in fss.configOptions)
            {
                result.configOptions.Add(co);
            }

            foreach (var d in fss.disciplines)
            {
                var sg = result.studentGroups.FirstOrDefault(stgr => stgr.StudentGroupId == d.StudentGroupId);
                var newD = new Discipline(d.DisciplineId, d.Name,
                    sg, d.Attestation, d.AuditoriumHours, d.LectureHours, d.PracticalHours);

                result.disciplines.Add(newD);
            }

            foreach (var s in fss.students)
            {
                result.students.Add(new Student(s.StudentId, s.F, s.I, s.O,
                    s.Starosta == 1, s.NFactor == 1, s.Expelled == 1));
            }

            foreach (var sig in fss.studentsInGroups)
            {
                var stud = result.students.FirstOrDefault(s => s.StudentId == sig.StudentId);
                var stgr = result.studentGroups.FirstOrDefault(sg => sg.StudentGroupId == sig.StudentGroupId);
                result.studentsInGroups.Add(new StudentsInGroups
                {
                    StudentsInGroupsId = sig.StudentsInGroupsId,
                    Student = stud,
                    StudentGroup = stgr
                });
            }

            foreach (var tfd in fss.teacherForDisciplines)
            {
                var teacher = result.teachers.FirstOrDefault(t => t.TeacherId == tfd.TeacherId);
                var discipline = result.disciplines.FirstOrDefault(d => d.DisciplineId == tfd.DisciplineId);
                result.teacherForDisciplines.Add(new TeacherForDiscipline
                {
                    TeacherForDisciplineId = tfd.TeacherForDisciplineId,
                    Teacher = teacher,
                    Discipline = discipline
                });
            }

            foreach (var lesson in fss.lessons)
            {
                var tefd = result.teacherForDisciplines.FirstOrDefault(
                        tfd => tfd.TeacherForDisciplineId == lesson.TeacherForDisciplineId);
                var cal = result.calendars.FirstOrDefault(c => c.CalendarId == lesson.CalendarId);
                var ring = result.rings.FirstOrDefault(r => r.RingId == lesson.RingId);
                var aud = result.auditoriums.FirstOrDefault(a => a.AuditoriumId == lesson.AuditoriumId);
                result.lessons.Add(new Lesson(lesson.LessonId, tefd, cal, ring, aud, lesson.IsActive == 1));
            }

            foreach (var logEvent in fss.lessonLogEvents)
            {
                var oldLesson = result.lessons.FirstOrDefault(l => l.LessonId == logEvent.OldLessonId);
                var newLesson = result.lessons.FirstOrDefault(l => l.LessonId == logEvent.NewLessonId);
                result.lessonLogEvents.Add(new LessonLogEvent
                {
                    LessonLogEventId = logEvent.LessonLogEventId,
                    Comment = logEvent.Comment,
                    DateTime = logEvent.DateTime,
                    NewLesson = newLesson,
                    OldLesson = oldLesson

                });
            }

            return result;
        }
Esempio n. 6
0
        private void SetGroupListAndDatePicker(Schedule schedule)
        {
            var groupName = groupList.Text;

            var filteredGroups = schedule.studentGroups
                .Where(sg => !sg.Name.Contains('I') && !sg.Name.Contains('-') && !sg.Name.Contains('+'))
                .OrderBy(sg => sg.Name)
                .ToList();

            groupList.DisplayMember = "Name";
            groupList.ValueMember = "StudentGroupId";
            groupList.DataSource = filteredGroups;

            groupList.Text = groupName;

            datePicker.MinDate = schedule.calendars.Select(c => c.Date).Min();
            datePicker.MaxDate = schedule.calendars.Select(c => c.Date).Max();
        }
Esempio n. 7
0
        private void LoadScheduleOnSettings()
        {
            if (SettingsCore.Data.ContainsKey("saveScheduleLocally"))
            {
                var baseExePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Substring(6);

                if ((SettingsCore.Data["saveScheduleLocally"] == "1") && File.Exists(baseExePath + "\\schedule.txt"))
                {
                    Schedule schedule = null;

                    var splashForm = new SplashScreen();

                    var loadTask = Task.Factory.StartNew(() => { schedule = Schedule.LoadScheduleFromFile(); });

                    loadTask.ContinueWith(
                        antecedent => splashForm.Close(),
                        TaskScheduler.FromCurrentSynchronizationContext()
                    );

                    string[] args = Environment.GetCommandLineArgs();
                    if (!args.Contains("-Startup"))
                    {
                        splashForm.ShowDialog();
                    }

                    loadTask.Wait();

                    if (schedule != null)
                    {
                        if (_schedule != null)
                        {
                            lock (_schedule)
                            {
                                _schedule = schedule;
                            }
                        }
                        else
                        {
                            _schedule = schedule;
                        }

                        SwitchInterFace(true);
                    }
                }
            }
        }
Esempio n. 8
0
        private void LoadSchedule()
        {
            Text = Resources.MainFormScheduleLoadingTitle;
            updateSchedule.Enabled = false;
            updateSchedule.Image = Resources.update24sepia;
            refreshButtonTooltip.Active = false;
            обновитьРасписниеToolStripMenuItem.Enabled = false;
            обновитьРасписниеToolStripMenuItem.Text = "Идёт обновление ...";
            обновитьРасписниеToolStripMenuItem.Image = Resources.update24sepia;

            if (!IsConnectedToInternet())
            {
                Text = Resources.MainFormNoInternetTitle;
                return;
            }

            var request = new WNURequest(new Dictionary<string, string>
                {
                  { "action", "bundle" }
                }
            );

            var siteLoadTask = Task.Factory.StartNew(arg =>
                {
                    var req = (WNURequest)arg;
                    return WNU.PostRequest("http://wiki.nayanova.edu/api.php", req.ToJSON());
                },
                request
            );

            var deserializeAndConvertTask = siteLoadTask.ContinueWith(antecedent =>
                {
                    var jsonSerializer = new System.Web.Script.Serialization.JavaScriptSerializer { MaxJsonLength = 10000000 };
                    var deserializedWebSchedule = jsonSerializer.Deserialize<WebSchedule>(antecedent.Result);
                    var schedule = Schedule.FromWebSchedule(deserializedWebSchedule);
                    return schedule;
                }
            );

            deserializeAndConvertTask.ContinueWith(antecedent =>
                {
                    var schedule = antecedent.Result;

                    SetGroupListAndDatePicker(schedule);

                    if (_schedule != null)
                    {
                        lock (_schedule)
                        {
                            _schedule = schedule;
                        }
                    }
                    else
                    {
                        _schedule = schedule;
                    }

                    SwitchInterFace(true);

                    Text = Resources.MainFormScheduleTitle;

                    DatePickerValueChanged(null, null);

                    ChackForAndDisplayUpdateCount();

                    updateSchedule.Enabled = true;
                    updateSchedule.Image = Resources.update24;
                    refreshButtonTooltip.Active = true;
                    refreshButtonTooltip.SetToolTip(updateSchedule, "Обновить расписание");
                    обновитьРасписниеToolStripMenuItem.Enabled = true;
                    обновитьРасписниеToolStripMenuItem.Text = "Обновить расписание";
                    обновитьРасписниеToolStripMenuItem.Image = Resources.update24;

                },
                _uiScheduler
            );
        }