Ejemplo n.º 1
0
        /// <summary>
        /// Deactivates all schedules and activates the given <paramref name="schedule"/>.
        /// Also saves the settings to the JSON file.
        /// </summary>
        /// <param name="schedule">The <see cref="Schedule"/> object to be activated.</param>
        public void ActivateSchedule(Schedule schedule)
        {
            Schedules.ForEach(s => s.Active = false);

            schedule.Active = true;
            SaveSettings();
        }
Ejemplo n.º 2
0
 public void Reset()
 {
     Continue         = Apps.Where(x => x.InOrder).ToList().Count > 0; // Should only be true if we have chains.
     _completedChains = 0;
     Apps.ForEach(x => x.Reset());
     Deadlines.ForEach(x => x.Reset());
     Jitters.ForEach(x => x.Reset());
     Schedules.ForEach(x => x.Reset());
 }
Ejemplo n.º 3
0
        public void ChangeDepartureTime(DateTime date)
        {
            long tics = date.Ticks - FirstDeparturTime.Ticks;

            Schedules.ForEach(s =>
            {
                s.SetTime(s.Departuretime.AddTicks(tics), s.Arrivaltime.AddTicks(tics));
            });
            FirstDeparturTime = date;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds a new schedule and saves the settings.
        /// </summary>
        /// <param name="schedule">The <see cref="Schedule"/> object to be added.</param>
        /// <param name="makeActive">If the schedule added should be set as the active schedule.</param>
        public void AddSchedule(Schedule schedule, bool makeActive)
        {
            if (makeActive)
            {
                Schedules.ForEach(s => s.Active = false);
                schedule.Active = true;
            }

            Schedules.Add(schedule);
            Schedules = Schedules.OrderBy(s => s.Name).ToList();
            SaveSettings();
        }
        private ObservableCollection <object> GetPreferredSchedules()
        {
            var result             = new ObservableCollection <object>();
            var preferredSchedules = _executor.GetPreferredSchedules(SelectedIdRequest);

            Schedules.ForEach(s =>
            {
                if (preferredSchedules.Any(p => p.IdSchedule == s.IdSchedule))
                {
                    result.Add(s);
                }
            });

            return(result);
        }
Ejemplo n.º 6
0
        public Schedule FindSchedule(DateTime date)
        {
            if (!WillFlight(date))
            {
                throw new Exception("Data not found");
            }

            Schedule returningValue = null;

            Schedules.ForEach(schedule =>
            {
                if (schedule.Departuretime == date)
                {
                    returningValue = schedule;
                    return;
                }
            });

            return(returningValue);
        }