private async Task ReadFileAsync() { BusyOverlayService.SetBusyState(BusyEnum.Busy); if (File != null) { var stopwatch = new Stopwatch(); stopwatch.Start(); if (SendToServer) { await ParseOnServer(); } else { using (MemoryStream ms = new MemoryStream()) { await File.OpenReadStream().CopyToAsync(ms); Articles = ArticleExcelReader.Read(ms); } } stopwatch.Stop(); TimeElapsedMs = stopwatch.ElapsedMilliseconds; StateHasChanged(); } BusyOverlayService.SetBusyState(BusyEnum.NotBusy); }
private void OnInputFileChange(InputFileChangeEventArgs e) { BusyOverlayService.SetBusyState(BusyEnum.Busy); File = e.File; this.StateHasChanged(); BusyOverlayService.SetBusyState(BusyEnum.NotBusy); }
private async Task HandleDeleteFromIndexedDb() { BusyOverlayService.SetBusyState(BusyEnum.Busy); var stopwatch = new Stopwatch(); stopwatch.Start(); ItemCount = Articles.Count; foreach (var article in Articles) { await PersistenceService.DeleteAsync <Article>(article); if (!UiUpdates) { continue; } ItemCount = Math.Max(0, ItemCount--); ProcessingTimeMs = stopwatch.ElapsedMilliseconds; if ((ItemCount % 100) == 0 || ItemCount == Articles.Count) { StateHasChanged(); await Task.Delay(1); } } stopwatch.Stop(); ProcessingTimeMs = stopwatch.ElapsedMilliseconds; BusyOverlayService.SetBusyState(BusyEnum.NotBusy); }
private async void DeleteAllDone() { try { BusyOverlayService.SetBusyState(BusyEnum.Busy); await UserItemManager.DeleteAllDoneAsync(CurrentUserService.CurrentUser); } finally { BusyOverlayService.SetBusyState(BusyEnum.NotBusy); } }
private void OrderbyDescription() { BusyOverlayService.SetBusyState(BusyEnum.Busy); Articles = Ascending ? Articles.OrderBy(e => e.Description).ToList() : Articles.OrderByDescending(e => e.Description).ToList(); Ascending = !Ascending; BusyOverlayService.SetBusyState(BusyEnum.NotBusy); }
private async Task CalculatePrimes() { BusyOverlayService?.SetBusyState(BusyEnum.Busy); await Task.Delay(1); var stopwatch = new Stopwatch(); stopwatch.Start(); Primes = PrimeService?.FindPrimeNumbersUpTo(MaxNumber); stopwatch.Stop(); TimeElapsedMs = stopwatch.ElapsedMilliseconds; BusyOverlayService?.SetBusyState(BusyEnum.NotBusy); }
private void HandleClearTable() { BusyOverlayService.SetBusyState(BusyEnum.Busy); var stopwatch = new Stopwatch(); stopwatch.Start(); Articles.Clear(); ItemCount = 0; stopwatch.Stop(); ProcessingTimeMs = stopwatch.ElapsedMilliseconds; BusyOverlayService.SetBusyState(BusyEnum.NotBusy); }
private async Task HandleLoadArticlesFromIndexedDb() { BusyOverlayService.SetBusyState(BusyEnum.Busy); var stopwatch = new Stopwatch(); stopwatch.Start(); var result = await PersistenceService.GetAllAsync <Article>(); Articles = result.ToList(); ItemCount = Articles.Count(); stopwatch.Stop(); ProcessingTimeMs = stopwatch.ElapsedMilliseconds; BusyOverlayService.SetBusyState(BusyEnum.NotBusy); }
protected async void OnValidSubmit() { try { BusyOverlayService.SetBusyState(BusyEnum.Busy); User.GenderType = SelectedGenderTypeDropdownItem.ItemObject; await UserManager.InsertUserAsync(User); NavigationManager.NavigateTo("signin"); } catch (Exception ex) { var parameters = new ModalParameters(); parameters.Add(nameof(ModalMessage.Message), ex.Message); ModalService.Show <ModalMessage>("Error", parameters); } finally { BusyOverlayService.SetBusyState(BusyEnum.Busy); } }
protected override async Task OnParametersSetAsync() { await base.OnParametersSetAsync(); var authState = await AuthenticationStateTask; IsAuthenticated = authState.User.Identity.IsAuthenticated; if (!IsAuthenticated || CurrentUserService.CurrentUser.IsUserItemsPropertyLoaded) { return; } try { BusyOverlayService.SetBusyState(BusyEnum.Busy); await UserItemManager.RetrieveAllUserItemsOfUserAndSetToUserAsync(CurrentUserService.CurrentUser); } finally { BusyOverlayService.SetBusyState(BusyEnum.NotBusy); } }
protected async void OnSubmit() { if (!EditContext.Validate()) { return; } try { BusyOverlayService.SetBusyState(BusyEnum.Busy); var foundUser = await UserManager.TrySignInAndGetUserAsync(User); if (foundUser != null) { AuthenticationStateProvider.SetAuthenticationState(foundUser); CurrentUserService.CurrentUser = foundUser; NavigationManager.NavigateTo("items"); } else { var parameters = new ModalParameters(); parameters.Add(nameof(ModalMessage.Message), "User not found!"); ModalService.Show <ModalMessage>("Error", parameters); } } catch (Exception ex) { var parameters = new ModalParameters(); parameters.Add(nameof(ModalMessage.Message), ex.Message); ModalService.Show <ModalMessage>("Error", parameters); } finally { BusyOverlayService.SetBusyState(BusyEnum.NotBusy); } }
private async Task AddTenToPrice() { ProcessingTimeMs = 0; BusyOverlayService.SetBusyState(BusyEnum.Busy); var stopwatch = new Stopwatch(); stopwatch.Start(); // Load all articles from the DB Articles = (await PersistenceService.GetAllAsync <Article>()).ToList(); // Display in table ProcessingTimeMs = stopwatch.ElapsedMilliseconds; await Task.Yield(); StateHasChanged(); // Add price int counter = 0; foreach (var article in Articles) { article.Price += 10; if (!UiUpdates) { continue; } ItemCount = ++counter; ProcessingTimeMs = stopwatch.ElapsedMilliseconds; if ((counter % 100) == 0 || counter == Articles.Count) { StateHasChanged(); await Task.Delay(1); } } var counter2 = 0; // Update all articles in DB foreach (var article in Articles) { await PersistenceService.UpdateAsync <Article>(article); if (!UiUpdates) { continue; } ItemCount = ++counter2; ProcessingTimeMs = stopwatch.ElapsedMilliseconds; if ((counter2 % 100) == 0 || counter2 == Articles.Count) { StateHasChanged(); await Task.Delay(1); } } stopwatch.Stop(); ProcessingTimeMs = stopwatch.ElapsedMilliseconds; BusyOverlayService.SetBusyState(BusyEnum.NotBusy); }