private void _asyncMgr_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e) { try { if (AsyncSolveCompleted != null) { AsyncSolveCompleted(this, e); } } finally { _asyncOperations.Remove(e.OperationId); } }
/// <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(); }
/// <summary> /// Updates IsEnabled state and tooltip when solve completed. /// </summary> /// <param name="sender">Solver.</param> /// <param name="e">Event args.</param> private void Solver_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e) { _CheckEnabled(); _UpdateTooltip(); }
/// <summary> /// Handler contains logic to update page's state when solve operation will be completed. /// </summary> /// <param name="sender">Solver.</param> /// <param name="e">Solve event args.</param> private void OptimizeAndEditPage_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e) { AsyncOperationInfo info = null; Schedule schedule = null; if (App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info)) schedule = info.Schedule; // If operation was completed on other date - remove locked status for this date. if (schedule != null && schedule.PlannedDate.Equals(App.Current.CurrentDate)) { if (_lockedStatuses.ContainsKey((DateTime)schedule.PlannedDate)) _lockedStatuses.Remove((DateTime)schedule.PlannedDate); } // If operation was completed on current date - unlock UI. if (schedule.PlannedDate.Equals(App.Current.CurrentDate)) IsLocked = false; // Update page's "IsComplete" property if necessary. _CheckPageComplete(); WorkingStatusHelper.SetReleased(); }
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); } } }
private void Solver_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e) { App.Current.Messenger.AddInfo("Solve completed."); }
/// <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(); }
/// <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(); }
/// <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(); } } }
/// <summary> /// Async. solve completed event handler. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Async. solve completed event arguments.</param> private void _Cmd_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e) { if (e.OperationId.Equals(_operationID)) { Debug.Assert(0 < _listOfRoutes.Count); // process operation results if (e.Error != null) // error occured during operation _OnSolveError(e.Error); else if (e.Cancelled) { // operation was cancelled _listOfRoutes.Clear(); App.Current.UIManager.Unlock(); WorkingStatusHelper.SetReleased(); var message = App.Current.FindString("GenerateDirectionsCancelledText"); App.Current.Messenger.AddInfo(message); } else { // operation successed _listOfRoutes.RemoveAt(0); var message = App.Current.FindString("GenerateDirectionsCompletedText"); App.Current.Messenger.AddInfo(message); if (0 == _listOfRoutes.Count) { // all routes updated try { App.Current.Project.Save(); } catch (Exception ex) { Logger.Error(ex); } WorkingStatusHelper.SetReleased(); } // restart generation procedure _DoGenerationProcess(); } } else { // update page content _UpdateSchedules(); _UpdateGui(); } }
/// <summary> /// Solver async solve completed handler. /// </summary> private void solver_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e) { _UpdateSchedules(); _UpdateGui(); }
/// <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(); }
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)); } }