private void ExtractFile(string filePath)
 {
     string[] partpath = filePath.Split('\\');
     string[] arr_file = partpath[partpath.Length - 1].ToLower().Split();
     if (arr_file[0] == "расписание" && (arr_file[1] == "занятий" || arr_file[1] == "сессия" || arr_file[1] == "сессии"))
     {
         ExtractBacalavr(filePath);
     }
     else if (arr_file[0] == "магистратура")
     {
         ExtractMagistr(filePath);
     }
     else if (Months.Contains(arr_file[0]))
     {
         ExtractPartTime(filePath);
     }
     else if (arr_file[0][arr_file[0].Length - 1] == 'з')
     {
         ExtractDistance(filePath);
     }
     else if (arr_file[arr_file.Length - 1].Split('.')[0] == "(фак" || arr_file[arr_file.Length - 1].Split('.')[0] == "(фак)")
     {
         ExtractElective(filePath);
     }
     else if (arr_file[0] == "расписание" && arr_file[1].Split('.')[0] == "пересдач")
     {
         ExtractRetake(filePath);
     }
 }
 private void ReloadMonthsIfNecessary()
 {
     if (!Months.Contains(_currentMonth))
     {
         Months.Clear();
         InitializeMonths(DateTime.Now);
     }
 }
Example #3
0
        public bool CheckDateTime(DateTime?dateTime = null)
        {
            var time = dateTime ?? DateTime.Now;

            return(Minutes.Contains(time.Minute) &&
                   Hours.Contains(time.Hour) &&
                   Months.Contains(time.Month - 1) &&
                   (DaysOfMonth.Contains(time.Day - 1) || DaysOfWeek.Contains((int)time.DayOfWeek - 1)));
        }
Example #4
0
        private async void OnMonthUpdatedEvent(MonthModel changed)
        {
            if (!Months.Contains(changed))
            {
                await LoadMonthsAsync(changed);
            }
            else if (SelectedMonth == changed)
            {
                await LoadMonthSummaryAsync();
            }

            StateHasChanged();
        }
Example #5
0
 bool CheckNext(DateTime now)
 {
     if (InvokeTime <= now)
     {
         return(true);
     }
     if (Months != null && !Months.Contains(InvokeTime.Month))
     {
         return(true);
     }
     if (Weeks != null && !Weeks.Contains(InvokeTime.DayOfWeek))
     {
         return(true);
     }
     return(false);
 }
Example #6
0
        protected async Task LoadMonthsAsync(bool isReload = true)
        {
            if (isReload || Months == null)
            {
                using (Loading.Start())
                    Months = await Queries.QueryAsync(new ListMonthWithOutcome());
            }

            if (SelectedMonth != null && !Months.Contains(SelectedMonth))
            {
                Navigator.OpenSummary();
                return;
            }

            if (SelectedMonth == null)
            {
                SelectedMonth = Months.FirstOrDefault();
            }

            await LoadMonthSummaryAsync();
        }
        public void LoadDataIfNecessary(int appearedItemIndex, bool shouldSelectDay)
        {
            if (Months.Count <= 1)
            {
                return;
            }

            if (appearedItemIndex == 0)
            {
                CachePreviousMonths();
            }

            if (appearedItemIndex == CurrentMonthIndex &&
                Months.Contains(_currentMonth))
            {
                if (shouldSelectDay)
                {
                    if (DateTime.Now.Year == _currentMonth.CurrentDate.Year &&
                        DateTime.Now.Month == _currentMonth.CurrentDate.Month)
                    {
                        SelectCurrentDay();
                        return;
                    }
                }
            }

            if (appearedItemIndex == Months.Count - 1)
            {
                CacheNextMonths();
            }

            if (shouldSelectDay)
            {
                var appearedMonth = Months.ElementAt(appearedItemIndex);
                SelectDay(appearedMonth.Days.First().CurrentDate);
            }
        }
        public void CalculateNextExecution()
        {
            NextExecution = Start;

            switch (Type)
            {
            case TriggerType.Time:
                if (RepeatInterval != TimeSpan.Zero)
                {
                    //Handle repeat
                    var endRepeatDate = (RepeatDuration != TimeSpan.Zero ? NextExecution + RepeatDuration : DateTime.MaxValue);
                    if (endRepeatDate < DateTime.Now)
                    {
                        break;
                    }
                    while (true)
                    {
                        if (NextExecution > DateTime.Now || NextExecution > EndFinal || NextExecution > endRepeatDate)
                        {
                            //Found within repeat
                            break;
                        }
                        NextExecution += RepeatInterval;
                    }
                }
                break;

            case TriggerType.Daily:
                while (true)
                {
                    if (NextExecution > DateTime.Now || NextExecution > EndFinal)
                    {
                        //Found
                        break;
                    }

                    if (RepeatInterval != TimeSpan.Zero)
                    {
                        //Handle repeat
                        var nextRepeatExecution = NextExecution;
                        var endRepeatDate       = (RepeatDuration != TimeSpan.Zero ? nextRepeatExecution + RepeatDuration : DateTime.MaxValue);
                        while (endRepeatDate > DateTime.Now)
                        {
                            if (nextRepeatExecution > DateTime.Now || nextRepeatExecution > EndFinal || nextRepeatExecution > endRepeatDate)
                            {
                                break;
                            }
                            nextRepeatExecution += RepeatInterval;
                        }

                        if (nextRepeatExecution > DateTime.Now || nextRepeatExecution > EndFinal)
                        {
                            //Found within repeat
                            NextExecution = nextRepeatExecution;
                            break;
                        }
                    }

                    NextExecution = NextExecution.AddDays(DaysInterval);
                }
                break;

            case TriggerType.Weekly:
                while (true)
                {
                    if (Weekdays.Length == 0)
                    {
                        break;
                    }

                    //Check day of week
                    for (int i = 0; i < 6; i++)
                    {
                        var nextWeekExecution = NextExecution.AddDays(i);
                        if (!Weekdays.Contains((int)nextWeekExecution.DayOfWeek))
                        {
                            continue;
                        }

                        if (nextWeekExecution > DateTime.Now || nextWeekExecution > EndFinal)
                        {
                            //Found
                            NextExecution = nextWeekExecution;
                            break;
                        }

                        if (RepeatInterval != TimeSpan.Zero)
                        {
                            //Handle repeat
                            var nextRepeatExecution = nextWeekExecution;
                            var endRepeatDate       = (RepeatDuration != TimeSpan.Zero ? nextRepeatExecution + RepeatDuration : DateTime.MaxValue);
                            while (endRepeatDate > DateTime.Now)
                            {
                                if (nextRepeatExecution > DateTime.Now || nextRepeatExecution > EndFinal || nextRepeatExecution > endRepeatDate)
                                {
                                    break;
                                }
                                nextRepeatExecution += RepeatInterval;
                            }

                            if (nextRepeatExecution > DateTime.Now || nextRepeatExecution > EndFinal)
                            {
                                //Found within repeat
                                NextExecution = nextRepeatExecution;
                                break;
                            }
                        }
                    }

                    if (NextExecution > DateTime.Now || NextExecution > EndFinal)
                    {
                        //Found
                        break;
                    }

                    NextExecution = NextExecution.AddDays(7 * WeeksInterval);
                }
                break;

            case TriggerType.Monthly:
                while (true)
                {
                    if (Months.Length == 0)
                    {
                        break;
                    }
                    if (Days.Length == 0)
                    {
                        break;
                    }

                    //Check days and months
                    bool isLastDayOfMonth = (Days.Contains(32) && Months.Contains(NextExecution.Month) && NextExecution.Day == DateTime.DaysInMonth(NextExecution.Year, NextExecution.Month));
                    if (!isLastDayOfMonth)
                    {
                        if (!Days.Contains(NextExecution.Day) || !Months.Contains(NextExecution.Month))
                        {
                            NextExecution = NextExecution.AddDays(1);
                            continue;
                        }
                    }

                    if (NextExecution > DateTime.Now || NextExecution > EndFinal)
                    {
                        //Found
                        break;
                    }

                    if (RepeatInterval != TimeSpan.Zero)
                    {
                        //Handle repeat
                        var nextRepeatExecution = NextExecution;
                        var endRepeatDate       = (RepeatDuration != TimeSpan.Zero ? nextRepeatExecution + RepeatDuration : DateTime.MaxValue);
                        while (endRepeatDate > DateTime.Now)
                        {
                            if (nextRepeatExecution > DateTime.Now || nextRepeatExecution > EndFinal || nextRepeatExecution > endRepeatDate)
                            {
                                break;
                            }
                            nextRepeatExecution += RepeatInterval;
                        }

                        if (nextRepeatExecution > DateTime.Now || nextRepeatExecution > EndFinal)
                        {
                            //Found within repeat
                            NextExecution = nextRepeatExecution;
                            break;
                        }
                    }

                    //Check next day
                    NextExecution = NextExecution.AddDays(1);
                }
                break;
            }

            if (NextExecution < DateTime.Now)
            {
                NextExecution = DateTime.MaxValue;
            }
        }