private void usrProgressIndicatorButtons_OkClick(object sender, Controls.CancellationSourceEventArgs e)
        {
            try
            {
                UserContext.Current.Logout(LoginStatus.InProgress);
                ProfileDTO newProfile = usrCreateProfile1.Profile;
                bool       res        = false;
                this.SynchronizationContext.Send(delegate
                {
                    res = usrCreateProfile1.SaveProfile(newProfile);

                    var validator = new ObjectValidator(typeof(ProfileDTO));
                    var result    = validator.Validate(newProfile);

                    if (!result.IsValid)
                    {
                        BAMessageBox.ShowValidationError(result.ToBAResults());
                        res = false;
                    }
                }, null);
                if (!res)
                {
                    return;
                }

                newProfile.Privacy.CalendarView = Privacy.Public;
                newProfile.Privacy.Sizes        = Privacy.Public;
                var sessionData = ServiceManager.CreateProfile(newProfile);
                if (sessionData != null)
                {
                    UserContext.CreateUserContext(sessionData);
                    CreatedSessionData = sessionData;
                }
                ThreadSafeClose(true);
            }
            catch (EMailSendException ex)
            {
                TasksManager.SetException(ex);
                this.SynchronizationContext.Send(delegate
                {
                    ExceptionHandler.Default.Process(ex, Strings.ErrProblemWithSendingEmail, ErrorWindow.MessageBox);
                }, null);
            }
            catch (ValidationException validException)
            {
                TasksManager.SetException(validException);
                this.SynchronizationContext.Send(delegate
                {
                    BAMessageBox.ShowValidationError(validException.Results);
                }, null);
            }
            catch (UniqueException uniqueEx)
            {
                TasksManager.SetException(uniqueEx);
                this.SynchronizationContext.Send(delegate
                {
                    ExceptionHandler.Default.Process(uniqueEx, Strings.ErrorCreateProfileUnique, ErrorWindow.MessageBox);
                }, null);
            }
        }
        private void usrProgressIndicatorButtons_OkClick(object sender, Controls.CancellationSourceEventArgs e)
        {
            bool isValid = true;

            Dispatcher.Invoke(new Action(delegate
            {
                if (!validateInternal())
                {
                    isValid = false;
                    BAMessageBox.ShowError(Strings.Message_EditDomainObjectWindow_WrongFields);
                    return;
                }
            }));
            if (!isValid)
            {
                return;
            }
            var res = userControl.Save();

            UIHelper.BeginInvoke(new Action(delegate
            {
                if (res != null)
                {
                    userControl.Object = res;
                    DialogResult       = true;
                    Close();
                }
            }), Dispatcher);
        }
Пример #3
0
 private void usrProgressIndicatorButtons_OkClick(object sender, Controls.CancellationSourceEventArgs e)
 {
     try
     {
         ServiceManager.ImportLicence(LicenceKey);
         UserContext.Current.RefreshUserData();
         ThreadSafeClose(true);
     }
     catch (AlreadyOccupiedException ex)
     {
         TasksManager.SetException(ex);
         this.SynchronizationContext.Send(state => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetGUIString("ImportLicenceKeyWindow_ErrKeyAlreadyImported"), ErrorWindow.MessageBox), null);
     }
     catch (Exception ex)
     {
         TasksManager.SetException(ex);
         this.SynchronizationContext.Send(state => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetGUIString("ImportLicenceKeyWindow_ErrImportKey"), ErrorWindow.MessageBox), null);
     }
 }