Exemplo n.º 1
0
        /// <summary>
        /// Inits data grid.
        /// </summary>
        private void _InitDataGrid()
        {
            try
            {
                // If active schedule hasn't been set - do it.
                if (App.Current.Project != null &&
                    App.Current.Project.Schedules.ActiveSchedule == null)
                {
                    // Load schedule for current date.
                    var currentSchedule = OptimizeAndEditHelpers.LoadSchedule(
                        App.Current.Project,
                        App.Current.CurrentDate,
                        OptimizeAndEditHelpers.FindScheduleToSelect);

                    // If current date schedule have routes -
                    // select current schedule as active.
                    if (currentSchedule.Routes.Count > 0)
                    {
                        App.Current.Project.Schedules.ActiveSchedule = currentSchedule;
                    }
                }

                _ClearGridSource();

                IVrpSolver                solver         = App.Current.Solver;
                SolverSettings            solverSettings = solver.SolverSettings;
                ICollection <Restriction> restrictions   = solverSettings.Restrictions;
                if (0 < restrictions.Count)
                {
                    NetworkDescription networkDescription = solver.NetworkDescription;

                    // Obtain max "non-restriction" parameters count.
                    int maxParametersCount = _GetNonRestrictionParametersMaximumCount(
                        networkDescription, restrictions);

                    _InitDataGridLayout(maxParametersCount);
                }
            }
            catch (Exception ex)
            {
                Logger.Critical(ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads schedule with the specified planned date from the specified project.
        /// </summary>
        /// <param name="project">The project to load schedule from</param>
        /// <param name="plannedDate">The date/time to load schedule for.</param>
        /// <param name="scheduleSelector">The function for selecting particular schedule object
        /// from all schedules with the same planned date.</param>
        /// <returns>A "Current" schedule for the specified planned date.</returns>
        public static Schedule LoadSchedule(
            Project project,
            DateTime plannedDate,
            Func <IEnumerable <Schedule>, Schedule> scheduleSelector)
        {
            Debug.Assert(project != null);
            Debug.Assert(scheduleSelector != null);

            // Load or create schedule for plannedDate.
            var currentSchedule = project.Schedules.Search(plannedDate, false)
                                  .FirstOrDefault(schedule => schedule.Type == ScheduleType.Current);

            if (currentSchedule == null)
            {
                currentSchedule = project.AddNewSchedule(
                    plannedDate,
                    App.Current.FindString("CurrentScheduleName"));
            }

            OptimizeAndEditHelpers.FixSchedule(project, currentSchedule);

            return(currentSchedule);
        }