private async Task CreateAccountAsync()
        {
            try
            {
                await ButtonSpinner.SpinAsync(async() =>
                {
                    await SharedAccountService.CreateSharedAccountAsync(SharedAccount);
                    await ToastService.ShowToastAsync("Account created.", ToastType.Success);
                    await SynchronizationService.UpdateSharedAccounts(ExceptPageId);
                    await ModalDialogService.CloseAsync();
                });
            }
            catch (AlreadyExistException ex)
            {
                ValidationErrorMessage.DisplayError(nameof(SharedAccount.Name), ex.Message);
            }
            catch (IncorrectUrlException ex)
            {
                ValidationErrorMessage.DisplayError(nameof(SharedAccount.Urls), ex.Message);
            }
            catch (IncorrectOtpException ex)
            {
                ValidationErrorMessage.DisplayError(nameof(SharedAccount.OtpSecret), ex.Message);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
예제 #2
0
        private async Task EditAccoountOtpAsync()
        {
            try
            {
                await ButtonSpinner.SpinAsync(async() =>
                {
                    var vaults = await SharedAccountService.EditSharedAccountOtpAsync(Account, AccountOtp);
                    RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(vaults);
                    await SynchronizationService.UpdateSharedAccounts(ExceptPageId);
                    await ToastService.ShowToastAsync("Account OTP updated.", ToastType.Success);
                    await ModalDialogService.CloseAsync();
                });
            }
            catch (IncorrectOtpException ex)
            {
                ValidationErrorMessage.DisplayError(nameof(SharedAccount.OtpSecret), ex.Message);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
예제 #3
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                SharedAccountService           = ScopedServices.GetRequiredService <ISharedAccountService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                ModalDialogService.OnCancel += OnCancelAsync;

                Account = await SharedAccountService.GetSharedAccountByIdAsync(AccountId);

                if (Account == null)
                {
                    throw new Exception("Account not found");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Account.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Account.Id, Account);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
예제 #4
0
 private async Task EditAccountAsync()
 {
     try
     {
         await Button.SpinAsync(async() =>
         {
             var vaults = await SharedAccountService.EditSharedAccountAsync(SharedAccountEditModel);
             RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(vaults);
             await ToastService.ShowToastAsync("Shared account updated.", ToastType.Success);
             await ModalDialogClose();
         });
     }
     catch (AlreadyExistException ex)
     {
         ValidationErrorMessage.DisplayError(nameof(SharedAccount.Name), ex.Message);
     }
     catch (IncorrectUrlException ex)
     {
         ValidationErrorMessage.DisplayError(nameof(SharedAccount.Urls), ex.Message);
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message, ex);
         await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
         await ModalDialogCancel();
     }
 }
예제 #5
0
        private async Task DeleteAccoountAsync()
        {
            try
            {
                var vaults = await SharedAccountService.DeleteSharedAccountAsync(Account.Id);

                RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(vaults);
                await ToastService.ShowToastAsync("Account deleted.", ToastType.Success);
                await ModalDialogClose();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
예제 #6
0
 private async Task EditAccoountPasswordAsync()
 {
     try
     {
         await Button.SpinAsync(async() =>
         {
             var vaults = await SharedAccountService.EditSharedAccountPwdAsync(Account, AccountPassword);
             RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(vaults);
             await ToastService.ShowToastAsync("Account password updated.", ToastType.Success);
             await ModalDialogClose();
         });
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message);
         await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
         await ModalDialogCancel();
     }
 }
예제 #7
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService                = ScopedServices.GetRequiredService <IEmployeeService>();
                HardwareVaultService           = ScopedServices.GetRequiredService <IHardwareVaultService>();
                OrgStructureService            = ScopedServices.GetRequiredService <IOrgStructureService>();
                SharedAccountService           = ScopedServices.GetRequiredService <ISharedAccountService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                Companies = await OrgStructureService.GetCompaniesAsync();

                Departments = new List <Department>();
                Positions   = await OrgStructureService.GetPositionsAsync();

                SharedAccounts = await SharedAccountService.GetAllSharedAccountsAsync();

                SharedAccountId = SharedAccounts.FirstOrDefault()?.Id;

                await LoadHardwareVaultsAsync();

                Employee = new Employee()
                {
                    Id = Guid.NewGuid().ToString()
                };
                EmployeeContext = new EditContext(Employee);
                PersonalAccount = new AccountAddModel {
                    EmployeeId = Employee.Id, LoginType = LoginType.Local
                };
                PersonalAccountContext = new EditContext(PersonalAccount);

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
예제 #8
0
 private async Task OnCancelAsync()
 {
     await SharedAccountService.UnchangedAsync(Account);
 }
예제 #9
0
        protected override async Task ModalDialogCancel()
        {
            await SharedAccountService.UnchangedAsync(Account);

            await base.ModalDialogCancel();
        }