Esempio n. 1
0
        private async Task DisableAlarmAsync()
        {
            try
            {
                var checkPassword = await UserManager.CheckPasswordAsync(ApplicationUser, UserConfirmPassword);

                if (!checkPassword)
                {
                    throw new Exception("Invalid password");
                }

                await RemoteWorkstationConnections.UnlockAllWorkstationsAsync(ApplicationUser.Email);

                await SynchronizationService.UpdateAlarm(ExceptPageId);

                await CallBack.InvokeAsync(this);

                await ToastService.ShowToastAsync("All workstations are unlocked.", ToastType.Success);

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

                await ModalDialogService.CancelAsync();
            }
        }
Esempio n. 2
0
        private async Task EnableAlarmAsync()
        {
            RenderFragment body = (builder) =>
            {
                builder.OpenComponent(0, typeof(EnableAlarm));
                builder.AddAttribute(1, nameof(EnableAlarm.CurrentUserEmail), CurrentUserEmail);
                builder.CloseComponent();
            };

            var instance = await ModalDialogService.ShowAsync("Turn on alarm", body);

            var result = await instance.Result;

            if (result.Succeeded)
            {
                await GetAlarmStateAsync();

                await SynchronizationService.UpdateAlarm(PageId);
            }
        }
Esempio n. 3
0
        private async Task EnableAlarmAsync()
        {
            try
            {
                RemoteWorkstationConnections = ScopedServices.GetRequiredService <IRemoteWorkstationConnectionsService>();

                string userEmail = null;
                try
                {
                    userEmail = (await AuthenticationStateTask).User.Identity.Name;
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex.Message);
                }
                finally
                {
                    await RemoteWorkstationConnections.LockAllWorkstationsAsync(userEmail);
                }

                await SynchronizationService.UpdateAlarm(ExceptPageId);

                await CallBack.InvokeAsync(this);

                await ToastService.ShowToastAsync("All workstations are locked.", ToastType.Success);

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

                await ModalDialogService.CancelAsync();
            }
        }