public WeekSchedule()
 {
     Monday = new DaySchedule();
     Tuesday = new DaySchedule();
     Wednesday = new DaySchedule();
     Thursday = new DaySchedule();
     Friday = new DaySchedule();
     Saturday = new DaySchedule();
     Sunday = new DaySchedule();
     Shuffle = false;
 }
Example #2
0
 public WeekSchedule()
 {
     Monday    = new DaySchedule();
     Tuesday   = new DaySchedule();
     Wednesday = new DaySchedule();
     Thursday  = new DaySchedule();
     Friday    = new DaySchedule();
     Saturday  = new DaySchedule();
     Sunday    = new DaySchedule();
     Shuffle   = false;
 }
Example #3
0
        public void GenerateNewSchedule()
        {
            int n  = 0; // Box number
            var md = new DaySchedule();

            for (int d = 1; d <= 7; d++)
            {
                md = GetDaySchedule(d);
                for (int h = 0; h < 24; h++)
                {
                    md.Hours[h] = Forms.Wizard.WeekSchedule.getSchedule[n].isEnabled;
                    n++; // increase box number
                }
            }
        }
Example #4
0
        public bool ShouldRun(bool isRunning)
        {
            var day = (int)DateTime.Now.DayOfWeek; // Get number for current day of the week

            day = (day == 0 ? 7 : day);            // day fix sunday is 7
            DaySchedule currentDay = GetDaySchedule(day);
            //DaySchedule nextDay = GetDaySchedule((day == 7 ? 1 : day + 1));
            int currentHour = ClockFix(Convert.ToInt32(DateTime.Now.ToString("HH")));
            int prevHour    = ClockFix((currentHour - 1 != -1 ? currentHour - 1 : 0));

            bool thisHour = currentDay.Hours[currentHour];

            Debug.WriteLine("isRunning:{0} thishour:{1} day:{2}", isRunning, thisHour, day);
            if (isRunning)
            {
                // Check if we should stop

                if (!thisHour && DateTime.Now.Minute >= _currentRandom)
                {
                    GenerateNewRandom();
                    return(ForceStart);
                }

                if (ForceStart)
                {
                    // Disable ForceStart
                    ForceStart = false;
                    Logger.Instance.Write("Continue normal schedule");
                }

                return(true);
            }
            // Check if we need to start
            if (thisHour && (DateTime.Now.Minute >= _currentRandom || currentDay.Hours[prevHour]))
            {
                GenerateNewRandom();

                if (ForceStart)
                {
                    // Disable ForceStart
                    ForceStart = false;
                    Logger.Instance.Write("Continue normal schedule");
                }

                return(true);
            }
            return(ForceStart);
        }
Example #5
0
        public void NextSchedule(bool start)
        {
            var day = (int)DateTime.Now.DayOfWeek; // Get number for current day of the week

            day = (day == 0 ? 7 : day);            // day fix sunday is 7
            int currentHour = ClockFix(Convert.ToInt32(DateTime.Now.ToString("HH")));

            DateTime date = DateTime.Now;

            int  x     = 1;
            bool first = true;

            for (int i = day; i <= 8; i++)
            {
                Debug.WriteLine("Day: " + i);
                DaySchedule currentDay = GetDaySchedule(i);
                for (int h = (first ? currentHour : 0); h < 24; h++)
                {
                    if (currentDay.Hours[h] && start)
                    {
                        Logger.Instance.Write("Next scheduled start: {0:d/M} {1}:{2}", date, h, _currentRandom);
                        return;
                    }
                    if (!currentDay.Hours[h] && !start)
                    {
                        Logger.Instance.Write("Next scheduled stop: {0:d/M} {1}:{2}", date, h, _currentRandom);
                        return;
                    }
                }
                date  = date.AddDays(1);
                first = false;
                // Check if we had all days of the week
                x++;
                Debug.WriteLine("Count: " + x);
                if (x > 7)
                {
                    break;
                }
                if (i >= 7)
                {
                    i = 1;
                }
            }
        }
Example #6
0
        private DaySchedule GetDaySchedule(int day)
        {
            var md = new DaySchedule();

            switch (day)
            {
            case 1:
                md = Monday;
                break;

            case 2:
                md = Tuesday;
                break;

            case 3:
                md = Wednesday;
                break;

            case 4:
                md = Thursday;
                break;

            case 5:
                md = Friday;
                break;

            case 6:
                md = Saturday;
                break;

            case 7:
                md = Sunday;
                break;
            }
            return(md);
        }
 public void GenerateNewSchedule()
 {
     int n = 0; // Box number
     var md = new DaySchedule();
     for (int d = 1; d <= 7; d++)
     {
         md = GetDaySchedule(d);
         for (int h = 0; h < 24; h++)
         {
             md.Hours[h] = Forms.Wizard.WeekSchedule.getSchedule[n].isEnabled;
             n++; // increase box number
         }
     }
 }
 private DaySchedule GetDaySchedule(int day)
 {
     var md = new DaySchedule();
     switch (day)
     {
         case 1:
             md = Monday;
             break;
         case 2:
             md = Tuesday;
             break;
         case 3:
             md = Wednesday;
             break;
         case 4:
             md = Thursday;
             break;
         case 5:
             md = Friday;
             break;
         case 6:
             md = Saturday;
             break;
         case 7:
             md = Sunday;
             break;
     }
     return md;
 }
        private void ScheduleLoader(object bot)
        {
            var b = bot as BotClass;

            while (!isDone)
                Thread.Sleep(250);

            int n = 0; // Box number
            var md = new DaySchedule();
            for (int d = 1; d <= 7; d++)
            {
                switch (d)
                {
                    case 1:
                        md = b.Week.Monday;
                        break;
                    case 2:
                        md = b.Week.Tuesday;
                        break;
                    case 3:
                        md = b.Week.Wednesday;
                        break;
                    case 4:
                        md = b.Week.Thursday;
                        break;
                    case 5:
                        md = b.Week.Friday;
                        break;
                    case 6:
                        md = b.Week.Saturday;
                        break;
                    case 7:
                        md = b.Week.Sunday;
                        break;
                }
                for (int h = 0; h <= 23; h++)
                {
                    getSchedule[n].isEnabled = md.Hours[h];
                    n++; // increase box number
                }
            }
        }