private void RaiseCancelInteractionRequest(object arg)
        {
            if (IsModified)
            {

                var confirmation = new RefusedConfirmation { Title = "Action confirmation".Localize(null, LocalizationScope.DefaultCategory) };
                if (CaseActionState == CaseActionState.None)
                {
                    confirmation.Content = string.Format("Save changes to contact '{0}'?".Localize(), CurrentCustomer.FullName);
                }
                else
                {
                    confirmation.Content = string.Format("Save changes to case '{0}'?".Localize(), InnerItem.Number);
                }

                CancelConfirmRequest.Raise(confirmation,
                       async x =>
                       {
                           if (x.Confirmed)
                           {
                               if (Validate())
                               {
                                   //Save
                                   await DoSaveChanges();
                                   Close();
                               }
                               else
                               {
                                   if (CommonInfoRequest != null)
                                   {
                                       CommonInfoRequest.Raise(new ConditionalConfirmation
                                           {
                                               Title = "Warning".Localize(null, LocalizationScope.DefaultCategory),
                                               Content = "Can't be saved, because not all the fields are filled".Localize()
                                           }, y => { });
                                   }
                               }
                           }
                           else if (((RefusedConfirmation)x).Refused)
                           {
                               //Reloading viewModels
                               InnerItem = _originalItem;
                               IsModified = false;
                               _isItemsInitialized = false;
                               CurrentCustomer = _originalContact;
                               InitializeViewModels();
                               Close();
                           }
                           else
                           {
                               var cancelArg = arg as CancelEventArgs;
                               if (cancelArg != null)
                               {
                                   cancelArg.Cancel = true;
                                   OpenItemCommand.Execute();
                               }
                           }
                       });
            }
            else
                Close();
        }
Пример #2
0
		private void OnError(object sender, ErrorEventArgs e)
		{
			lock (_lock)
			{
				if (!Cancelled)
				{
					if (e.ErrorCode == (int)SystemErrorCodes.ERROR_CANCELLED)
					{
						_completedStepVmFactory.GetViewModelInstance().Result = OperationResult.Cancelled;
					}
					else
					{
						_progressStepVmFactory.GetViewModelInstance().Message = e.ErrorMessage;
						_completedStepVmFactory.GetViewModelInstance().Message = e.ErrorMessage;
						_completedStepVmFactory.GetViewModelInstance().Result = OperationResult.Failed;

						if (_installer.Command.Display == Display.Full)
						{
							var code = e.UIHint & 0xF;
							switch (code)
							{
								case 0:
									{
										var notification = new Notification { Title = Resources.SDKTitle, Content = e.ErrorMessage };
										OKDialogRequest.Raise(notification);
										e.Result = Result.Ok;
									}
									break;
								case 1:
								case 4:
									{
										var confirmation = new Confirmation { Title = Resources.SDKTitle, Content = e.ErrorMessage };
										switch (e.UIHint & 0xF)
										{
											case 1:
												OKCancelDialogRequest.Raise(confirmation);
												e.Result = confirmation.Confirmed ? Result.Ok : Result.Cancel;
												break;
											case 4:
												YesNoDialogRequest.Raise(confirmation);
												e.Result = confirmation.Confirmed ? Result.Ok : Result.Cancel;
												break;
										}
									}
									break;
								case 2:
								case 3:
									{
										var refusedConfirmation = new RefusedConfirmation();
										switch (e.UIHint & 0xF)
										{
											case 2:
												AbortRetryIgnoreDialogRequest.Raise(refusedConfirmation);
												e.Result = refusedConfirmation.Refused ? Result.Abort : (refusedConfirmation.Confirmed ? Result.Retry : Result.Ignore);
												if (!refusedConfirmation.Refused)
												{
													_completedStepVmFactory.GetViewModelInstance().Result = OperationResult.Successful;
												}
												break;
											case 3:
												YesNoCancelDialogRequest.Raise(refusedConfirmation);
												e.Result = refusedConfirmation.Confirmed ? Result.Yes : (refusedConfirmation.Refused ? Result.No : Result.Cancel);
												break;
										}
									}
									break;
							}
						}
					}
				}
				else
				{
					e.Result = Result.Cancel;
				}
			}
		}