Exemplo n.º 1
0
        public void ProfileOperation(Token token, ProfileOperationParam param)
        {
            var            securityInfo   = SecurityManager.EnsureAuthentication(token);
            ProfileService profileService = new ProfileService(Session, securityInfo, Configuration, SecurityManager, PushNotificationService, EMailService);

            profileService.ProfileOperation(token, param);
        }
Exemplo n.º 2
0
        public void ChangeStatus()
        {
            //progressStatus.ShowProgress(true, ApplicationStrings.ChangeStatusControl_ChangingStatusProgress);
            var m = new ServiceManager <AsyncCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <AsyncCompletedEventArgs> operationCompleted)
            {
                var param       = new ProfileOperationParam();
                param.Operation = ProfileOperation.SetStatus;
                param.ProfileId = ApplicationState.Current.SessionData.Profile.GlobalId;
                param.Status    = new ProfileStatusDTO()
                {
                    Status = Comment
                };
                client1.ProfileOperationAsync(ApplicationState.Current.SessionData.Token, param);
                client1.ProfileOperationCompleted -= operationCompleted;
                client1.ProfileOperationCompleted += operationCompleted;
            });

            m.OperationCompleted += (s1, a1) =>
            {
                if (a1.Error != null)
                {
                    //progressStatus.ShowProgress(false);
                    BAMessageBox.ShowError(ApplicationStrings.ChangeStatusControl_ErrChangeStatus);
                    return;
                }
                else
                {
                    //progressStatus.ShowProgress(false);
                    if (OperationCompleted != null)
                    {
                        OperationCompleted(this, EventArgs.Empty);
                    }
                }
            };

            if (!m.Run())
            {
                progressStatus.ShowProgress(false);
                if (ApplicationState.Current.IsOffline)
                {
                    BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode);
                }
                else
                {
                    BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork);
                }
                return;
            }
        }
Exemplo n.º 3
0
 private void btnDeleteProfile_Click(object sender, EventArgs e)
 {
     if (BAMessageBox.AskWarningYesNo(Strings.QDeleteProfile) == MessageBoxResult.Yes)
     {
         PleaseWait.Run(delegate
         {
             var profileOperation       = new ProfileOperationParam();
             profileOperation.ProfileId = UserContext.Current.CurrentProfile.GlobalId;
             profileOperation.Operation = ProfileOperation.Delete;
             ServiceManager.ProfileOperation(profileOperation);
             ProfileDeleted = true;
         });
         UserContext.Current.Logout(skipLogoutOnServer: true);
     }
 }
Exemplo n.º 4
0
 void changeAccountType(AccountType accountType)
 {
     if (UserContext.Current.ProfileInformation.Licence.AccountType > accountType)
     {
         int accountDiff = accountType - UserContext.Current.ProfileInformation.Licence.AccountType;
         int kara        = Math.Abs(accountDiff) * UserContext.Current.ProfileInformation.Licence.Payments.Kara;
         if (BAMessageBox.AskWarningYesNo(EnumLocalizer.Default.GetGUIString("ChangeAccountTypeView_QLowerAccountType"), kara) == MessageBoxResult.No)
         {
             return;
         }
     }
     else
     {
         if (BAMessageBox.AskYesNo(EnumLocalizer.Default.GetGUIString("ChangeAccountTypeView_QUpAccountType")) == MessageBoxResult.No)
         {
             return;
         }
     }
     PleaseWait.Run((x) =>
     {
         try
         {
             var param         = new ProfileOperationParam();
             param.Operation   = ProfileOperation.AccountType;
             param.ProfileId   = UserContext.Current.CurrentProfile.GlobalId;
             param.AccountType = accountType;
             ServiceManager.ProfileOperation(param);
             UserContext.Current.RefreshUserData();
             Scheduler.Ensure();
         }
         catch (ConsistencyException ex)
         {
             x.CloseProgressWindow();
             Dispatcher.Invoke(new Action(() => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetGUIString("ChangeAccountTypeView_ErrEnoughtBAPoints"), ErrorWindow.MessageBox)));
         }
         catch (Exception ex)
         {
             x.CloseProgressWindow();
             Dispatcher.Invoke(new Action(() => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetGUIString("ChangeAccountTypeView_ErrDuringChangeAccountType"), ErrorWindow.EMailReport)));
         }
     }, false, MainWindow.Instance);
 }
Exemplo n.º 5
0
        private void txtProfileStatus_LostFocus(object sender, RoutedEventArgs e)
        {
            string newStatus = txtProfileStatus.Text;

            if (string.IsNullOrEmpty(newStatus))
            {//normalize string. instead of "" use null always
                newStatus = null;
            }
            if (User.Statistics.Status.Status != newStatus)
            {//change status only if user type something else in the status textbox
                ServiceCommand command = new ServiceCommand(() =>
                {
                    var param           = new ProfileOperationParam();
                    param.Operation     = ProfileOperation.SetStatus;
                    param.ProfileId     = User.GlobalId;
                    param.Status        = new ProfileStatusDTO();
                    param.Status.Status = newStatus;
                    ServiceManager.ProfileOperation(param);
                    User.Statistics.Status.Status = newStatus;
                });
                ServicePool.Add(command);
            }
        }
Exemplo n.º 6
0
        void changeAccountType(AccountType accountType)
        {
            if (ApplicationState.Current.ProfileInfo.Licence.AccountType > accountType)
            {
                int accountDiff = accountType - ApplicationState.Current.ProfileInfo.Licence.AccountType;
                int kara        = Math.Abs(accountDiff) * ApplicationState.Current.ProfileInfo.Licence.Payments.Kara;
                if (BAMessageBox.Ask(string.Format(ApplicationStrings.AccountTypePage_QChangeAccountToLower, kara)) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }
            else
            {
                if (BAMessageBox.Ask(string.Format(ApplicationStrings.AccountTypePage_QChangeAccountToHigher)) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            progressBar.ShowProgress(true, ApplicationStrings.AccountTypePage_ChangingAccountType);
            updateButtons(false);
            var m = new ServiceManager <AsyncCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <AsyncCompletedEventArgs> operationCompleted)
            {
                var param         = new ProfileOperationParam();
                param.Operation   = ProfileOperation.AccountType;
                param.ProfileId   = ApplicationState.Current.SessionData.Profile.GlobalId;
                param.AccountType = accountType;

                client1.ProfileOperationAsync(ApplicationState.Current.SessionData.Token, param);
                client1.ProfileOperationCompleted -= operationCompleted;
                client1.ProfileOperationCompleted += operationCompleted;
            });

            m.OperationCompleted += (s, a) =>
            {
                FaultException <BAServiceException> serviceEx = a.Error as FaultException <BAServiceException>;
                if (serviceEx != null && serviceEx.Detail.ErrorCode == ErrorCode.ConsistencyException)
                {
                    updateButtons(true);
                    BAMessageBox.ShowError(ApplicationStrings.AccountTypePage_ErrNotEnoughPoints);
                    return;
                }
                if (a.Error != null)
                {
                    BugSenseHandler.Instance.SendExceptionAsync(a.Error);
                    updateButtons(true);
                    progressBar.ShowProgress(false);

                    BAMessageBox.ShowError(ApplicationStrings.AccountTypePage_ErrCannotChangeAccountType);
                    return;
                }


                refreshProfileInfo();
            };

            if (!m.Run())
            {
                updateButtons(true);
                progressBar.ShowProgress(false);
                if (ApplicationState.Current.IsOffline)
                {
                    BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode);
                }
                else
                {
                    BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork);
                }
            }
        }
 public void ProfileOperation(Token token, ProfileOperationParam param)
 {
     exceptionHandling(token, () => InternalService.ProfileOperation(token, param));
 }
Exemplo n.º 8
0
 public static void ProfileOperation(ProfileOperationParam msg)
 {
     exceptionHandling(() => Instance.ProfileOperation(Token, msg));
 }