コード例 #1
0
        public DayViewModel([NotNull] Day dayData, WeekType weekType, int parity,
                            [NotNull] LessonMenuItemsFactory menuItemsFactory, bool isTeacher, int holderId,
                            NavigationFlow navigationFlow, [CanBeNull] Group group)
        {
            if (dayData == null)
            {
                throw new ArgumentNullException("dayData");
            }
            if (menuItemsFactory == null)
            {
                throw new ArgumentNullException("menuItemsFactory");
            }

            _dayData        = dayData;
            _parity         = parity;
            _isTeacher      = isTeacher;
            _holderId       = holderId;
            _navigationFlow = navigationFlow;
            _group          = @group;
            _date           = SetUpDayName(weekType);
            NavigationFlow  = navigationFlow;

            if (_dayData.Lessons != null)
            {
                Lessons =
                    new ObservableCollection <LessonViewModel>(
                        FilterLessons(_dayData.Lessons, menuItemsFactory));
            }
            else
            {
                Lessons = new ObservableCollection <LessonViewModel>();
            }
        }
コード例 #2
0
        public static string CreateDailyMessage(string groupName, WeekType week, int day)
        {
            var repository = new ServerStorageRepository();
            var localRepo  = new LocalStorageRepository();
            var lessonList = repository.GetLessonList(groupName, day, week);
            var localList  = localRepo.GetLessonList(groupName, day, week);

            var msg = AnswerGeneratorService.GenerateHeader(week, day);

            if (lessonList.Except(localList).Any())
            {
                msg += "❌ ИСУ вернула расписание, отличное от локального\n"
                       + "С ИСУ:\n" + string.Join("\n", lessonList.Select(AnswerGeneratorService.LessonToString))
                       + "\nЛокально:\n" + string.Join("\n", localList.Select(AnswerGeneratorService.LessonToString));
            }
            else if (!lessonList.Any())
            {
                msg += AnswerGeneratorService.NoLessonMessage();
            }
            else
            {
                msg += string.Join("\n", lessonList.Select(AnswerGeneratorService.LessonToString));
            }

            return(msg);
        }
コード例 #3
0
 public List <LessonModel> GetLessonList(string groupName, int day, WeekType weekType)
 {
     return(ReadFromFile(groupName)
            .Where(l => l.DayOfWeek == day &&
                   (l.WeekType == weekType || l.WeekType == WeekType.All))
            .ToList());
 }
コード例 #4
0
            public override string ToString()
            {
                var result = Day.ToString() + " " + Time.Hour.ToString() + ":" + Time.Minute.ToString() + " " + Group.ToString() + " " + Subject.ToString() + " " + Type.ToString() +
                             " " + WeekType.ToString() + " " + Room.ToString() + " " + Teacher.ToString();

                return(result);
            }
コード例 #5
0
        public static string GenerateHeader(WeekType targetWeekType, int targetDay)
        {
            var week     = targetWeekType != WeekType.Odd ? "чётная" : "нечётная";
            var greeting = "🔑 Расписание на завтра!\n 👀 Нас ждёт ";

            greeting += $"{GetDayName(targetDay)}, {week} неделя \n";
            return(greeting);
        }
コード例 #6
0
        public List <LessonModel> GetLessonList(string groupName, int day, WeekType weekType)
        {
            var lessons = GetFromApi(groupName);

            return(lessons
                   .Where(l => l.DayOfWeek == day &&
                          (l.WeekType == weekType || l.WeekType == WeekType.All))
                   .ToList());
        }
コード例 #7
0
 public Filter(DateFilter dateFilter, ModuleFilter moduleFilter, WeekFilter weekFilter,
               bool sessionFilter, WeekType firstWeekType)
 {
     this.DateFilter    = dateFilter;
     this.ModuleFilter  = moduleFilter;
     this.WeekFilter    = weekFilter;
     this.SessionFilter = sessionFilter;
     this.FirstWeekType = firstWeekType;
 }
コード例 #8
0
 public RequisitionItem(LearningPlanItem planItem, GroupRequisition[] groupPriorities, string location, int repetitionsCount, MeetingTimeRequisition[] meetingTimePriorities, Teacher teacher, WeekType weekType)
 {
     PlanItem              = planItem;
     GroupPriorities       = groupPriorities;
     Location              = location;
     RepetitionsCount      = repetitionsCount;
     MeetingTimePriorities = meetingTimePriorities;
     Teacher  = teacher;
     WeekType = weekType;
 }
コード例 #9
0
 public IEnumerable <DayViewModel> CreateList([CanBeNull] IEnumerable <Day> models, NavigationFlow navigationFlow,
                                              Group group, WeekType type, int parity)
 {
     if (models == null)
     {
         return(Enumerable.Empty <DayViewModel>());
     }
     return(models.Select(
                day =>
                new DayViewModel(day, type, parity, _menuItemsFactory, _isTeacher, _holderId, navigationFlow, group)));
 }
コード例 #10
0
        public bool NewWeek(int newWeek, WeekType newWeekType)
        {
            var current = _game.Find(record => true).SingleOrDefault();
            var filter  = Builders <GameDocument> .Filter.Eq(record => record.Id, current.Id);

            var update = Builders <GameDocument> .Update.Set(record => record.Week, newWeek)
                         .Set(record => record.NextWeekType, newWeekType);

            var result = _game.UpdateOne(filter, update);

            return(result.ModifiedCount == 1);
        }
コード例 #11
0
 public Lesson(DateTime time, LessonType type, string group, string room,
               WeekType weekType, DayOfWeek day, ITeacher teacher, ISubject name)
 {
     Time     = time;
     Type     = type;
     Group    = group;
     Room     = room;
     WeekType = weekType;
     Day      = day;
     Teacher  = teacher;
     Subject  = name;
 }
コード例 #12
0
ファイル: Schedule.cs プロジェクト: shults-s/SmtuSchedule
        public Subject[] GetSubjects(DateTime upperWeekDate, DateTime date)
        {
            Subject[] subjects = Timetable.GetSubjects(date.DayOfWeek);

            if (subjects == null || subjects.Length == 0)
            {
                return(null);
            }

            WeekType currentWeekType = date.GetWeekType(upperWeekDate);

            subjects = subjects.Where(s => s.Week.HasFlag(currentWeekType)).ToArray();

            return((subjects.Length == 0) ? null : subjects);
        }
コード例 #13
0
        public WeekViewModel(IEnumerable <Day> days, int weekNumber, [NotNull] DayViewModelFactory dayViewModelFactory,
                             WeekType type, NavigationFlow navigationFlow, [CanBeNull] Group group)
        {
            if (dayViewModelFactory == null)
            {
                throw new ArgumentNullException("dayViewModelFactory");
            }
            var parity = weekNumber % 2;

            WeekNumber = weekNumber;

            Days =
                new ObservableCollection <DayViewModel>(
                    dayViewModelFactory.CreateList(days, navigationFlow, @group, type, parity)
                    .Where(d => d.Lessons.Any()));
        }
コード例 #14
0
        public ClassInstance(Class classData, ClassType classType, TimeSpan from, TimeSpan to, string room, WeekDay day, WeekType weekType, Teacher teacher, string uid = "")
        {
            this.classData = classData;
            this.classType = classType;
            this.from = from;
            this.to = to;
            this.room = room;
            this.weekDay = day;
            this.weekType = weekType;
            this.teacher = teacher;

            if (string.IsNullOrWhiteSpace(uid))
                this.uid = Guid.NewGuid().ToString();
            else
                this.uid = uid;
        }
コード例 #15
0
        public ClassInstance(Class classData, ClassType classType, TimeSpan from, TimeSpan to, string room, WeekDay day, WeekType weekType, Teacher teacher, string uid = "")
        {
            this.classData = classData;
            this.classType = classType;
            this.from      = from;
            this.to        = to;
            this.room      = room;
            this.weekDay   = day;
            this.weekType  = weekType;
            this.teacher   = teacher;

            if (string.IsNullOrWhiteSpace(uid))
            {
                this.uid = Guid.NewGuid().ToString();
            }
            else
            {
                this.uid = uid;
            }
        }
コード例 #16
0
        private DateTime SetUpDayName(WeekType weekType)
        {
            var today  = DateTime.Now;
            var delta  = (7 + (today.DayOfWeek - DayOfWeek.Monday)) % 7;
            var monday = today.AddDays(-delta);

            switch (weekType)
            {
            case WeekType.Previous:
                monday -= TimeSpan.FromDays(7);
                break;

            case WeekType.Current:
                break;

            case WeekType.Next:
                monday += TimeSpan.FromDays(7);
                break;

            default:
                throw new ArgumentOutOfRangeException("weekType");
            }
            return((monday + TimeSpan.FromDays(_dayData.Weekday - 1)).Date);
        }
コード例 #17
0
 public WeekTimetable(DateTime _weekStartDay)
 {
     weekStartDay = _weekStartDay;
     weekType     = GetIso8601WeekNumber(weekStartDay) % 2 == 0?WeekType.Even:WeekType.Odd;
     days         = new List <DayTimetable> ();
 }
コード例 #18
0
 public static string GetPairMD5(DayOfWeek day, string time, string name, string location, string lecturer, WeekType week_type)
 {
     return(CalculateMD5Hash((week_type == WeekType.Odd?"1":"0") + day.ToString() + time + name + location + lecturer));
 }
コード例 #19
0
 public void MondayLessonList(int day, WeekType weekType, int count)
 {
     //TODO: fix this test
     //var lessons = _repository.GetLessonList(_groupName, day, weekType);
     //Assert.AreEqual(lessons.Count(), count);
 }
コード例 #20
0
 public static string GetOLDPairMD5(string time, string name, string location, string lecturer, WeekType week_type)
 {
     return(CalculateMD5Hash((week_type == WeekType.Odd?"1":"0") + time + name + location + lecturer));
 }
コード例 #21
0
 public WeekViewModel Create([CanBeNull] IEnumerable <Day> days, int weekNumber, WeekType weekType,
                             NavigationFlow navigationFlow, [CanBeNull] Group group)
 {
     return(new WeekViewModel(days, weekNumber, _dayViewModelFactory, weekType, navigationFlow, group));
 }