示例#1
0
 /// <summary>
 /// Checks whether command is enabled when solve operation cancelled.
 /// </summary>
 /// <param name="sender">Solver.</param>
 /// <param name="e">Event args.</param>
 private void _AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         _CheckEnabled();
     }
 }
        protected void Cmd_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            // check is completed operation was started by this command
            if (OperationsIds.Contains(e.OperationId))
            {
                _operationsIds.Remove(e.OperationId);
                AsyncOperationInfo info     = null;
                Schedule           schedule = null;
                if (App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info))
                {
                    schedule = info.Schedule;
                }

                IsEnabled = true;

                if (e.Cancelled)
                {
                    App.Current.Messenger.AddInfo(_FormatCancelMsg(schedule));
                }
                else if (e.Error != null)
                {
                    _HandleSolveError(e.Error);
                }
                else
                {
                    SolveResult res = e.Result;
                    if (schedule != null)
                    {
                        _SaveSchedule(res, schedule, info);
                    }
                }
            }
        }
        /// <summary>
        /// React on async solve completed.
        /// </summary>
        private void _Cmd_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            if (_operationID.Equals(e.OperationId))
            {
                _app.Solver.AsyncSolveCompleted -= _Cmd_AsyncSolveCompleted;

                if (e.Cancelled)
                {
                    _app.MainWindow.Unlock();
                    WorkingStatusHelper.SetReleased();

                    _app.Messenger.AddInfo((string)_app.FindResource("GenerateDirectionsCancelledText"));
                }
                else if (e.Error != null)
                {
                    _OnSolveError(e.Error);
                }
                else
                {
                    _app.Messenger.AddInfo((string)_app.FindResource("GenerateDirectionsCompletedText"));

                    _app.Project.Save();
                    _app.MainWindow.Unlock();
                    WorkingStatusHelper.SetReleased();

                    _StartSendProcess();
                }
            }
        }
示例#4
0
 private void Solver_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         _CheckEnabled();
         _UpdateTooltip();
     }
 }
        /// <summary>
        /// Handle contains logic to save changes, start new operation or process errors when solve conpleted.
        /// </summary>
        /// <param name="sender">Solver.</param>
        /// <param name="e">Solve completed event args.</param>
        private void Solver_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            // If event came from any else solve operation - exit.
            if (e.OperationId != _currentOperationId)
            {
                return;
            }

            AsyncOperationInfo info = null;

            App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info); // Get operation info.

            // If operation complete successful.
            if (e.Error == null && !e.Cancelled && !e.Result.IsFailed)
            {
                Schedule changedSchedule = info.Schedule;
                _ProcessSaveSchedule(changedSchedule, info);                                           // Save edited schedule.
                _SetScheduleProcessed(changedSchedule);                                                // Set schedule Processed to "true".
                App.Current.Messenger.AddInfo(_FormatSuccessSolveCompletedMsg(changedSchedule, info)); // Add info message.
                _NotifyScheduleChanged(changedSchedule);

                UnassignScheduleInfo nextInfo = null;

                if (_GetNextScheduleToUnassign(out nextInfo))
                {
                    _StartNextScheduleUnassigning(nextInfo);
                    return;
                }

                _ProcessOrders(_args); // Call abstract method _ProcessOrders overrided in child command (to move orders to other date or delete them).
            }
            else if (e.Error != null)  // If Error occured during operation.
            {
                Logger.Error(e.Error);
                CommonHelpers.AddRoutingErrorMessage(e.Error);

                if (e.Result != null) // Result is "null" when connection failed.
                {
                    // Create violations collection.
                    ICollection <MessageDetail> details = _GetErrorFailedDetails(info, e.Result);
                    _ShowFailedMessage(e.Error, info.Schedule, details); // Show failed message.
                }
            }
            else if (e.Cancelled) // If operation was cancelled.
            {
                App.Current.Messenger.AddInfo(_FormatCancelMsg(info.Schedule));
            }
            else if (e.Result.IsFailed) // If operation's failed.
            {
                // Create violations collection.
                ICollection <MessageDetail> details = _GetErrorFailedDetails(info, e.Result);
                _ShowFailedMessage(e.Error, info.Schedule, details);
            }

            _UpdateOptimizeAndEditPageSchedules();  // Update optimize and edit page content.
            _CleanUp();
            _UnlockUI();
        }
示例#6
0
        private void _AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            Schedule           schedule = null;
            AsyncOperationInfo info     = null;

            if (App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info))
            {
                schedule = info.Schedule;
            }

            if (!IsEnabled)
            {
                IsEnabled = ((null == _schedulePage.CurrentSchedule) ||
                             (schedule.PlannedDate == _schedulePage.CurrentSchedule.PlannedDate));
            }
        }
示例#7
0
        /// <summary>
        /// Occurs when solve operation completed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnAsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            AsyncOperationInfo info     = null;
            Schedule           schedule = null;

            if (App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info))
            {
                schedule = info.Schedule;
            }

            if (schedule != null && !_pendingDatesToUpdate.Contains((DateTime)schedule.PlannedDate))
            {
                _pendingDatesToUpdate.Add((DateTime)schedule.PlannedDate);
                _optimizeAndEditPage.Dispatcher.BeginInvoke(new DayStatusDelegate(_UpdateDayStatus), System.Windows.Threading.DispatcherPriority.Send);
            }
        }
        /// <summary>
        /// React on solve operation finished.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Solve operation event args.</param>
        private void _AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            // Check that finished operation ID equals to current.
            if (!_operationID.Equals(e.OperationId))
            {
                return;
            }

            App.Current.Solver.AsyncSolveCompleted -= _AsyncSolveCompleted;

            if (e.Cancelled)
            {
                App.Current.Messenger.AddInfo(
                    string.Format((string)App.Current.FindResource("GenerateRouteShapesCancelledText"), App.Current.CurrentDate.ToShortDateString()));

                App.Current.MapDisplay.TrueRoute = false;
            }
            else if (e.Error != null)
            {
                Debug.Assert(e.Error != null);
                Logger.Error(e.Error);
                CommonHelpers.AddRoutingErrorMessage(e.Error);

                App.Current.MapDisplay.TrueRoute = false;
            }
            else
            {
                App.Current.Messenger.AddInfo(
                    string.Format((string)App.Current.FindResource("GenerateRouteShapesCompletedText"), App.Current.CurrentDate.ToShortDateString()));

                App.Current.Project.Save();

                // Set "Follow streets option". Set it to false first for notifying all route graphics.
                App.Current.MapDisplay.TrueRoute = false;
                App.Current.MapDisplay.TrueRoute = true;
            }

            _ReturnUIToDefaultState();
        }
示例#9
0
 /// <summary>
 /// Updates IsEnabled state and tooltip when solve completed.
 /// </summary>
 /// <param name="sender">Solver.</param>
 /// <param name="e">Event args.</param>
 private void _AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
 {
     Debug.Assert(_schedulePage != null);
     _CheckEnabled(_schedulePage);
     _UpdateTooltip();
 }
示例#10
0
 private void Solver_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
 {
     App.Current.Messenger.AddInfo("Solve completed.");
 }