private async Task EnsureLoaded() { if (isLoading || controller == null || controller.Data != null) { return; } isLoading = true; try { var data = new SummaryReportView { Period = ZoomLevel, }; await data.Load(Period); IsError = data.IsError; if (controller != null) { controller.Data = data; } } finally { isLoading = false; if (LoadReady != null) { LoadReady(this, new LoadReadyEventArgs(Period, IsError)); } } }
public async void LoadData() { if (IsClean) { try { IsLoading = true; dataSource = new SummaryReportView(); dataSource.Period = ZoomLevel; _delaying = true; cts = new CancellationTokenSource(); await Task.Delay(500, cts.Token); _delaying = false; await dataSource.Load(TimeSpaceIndex); if (!dataSource.IsLoading) { barChart.ReportView = dataSource; pieChart.ReportView = dataSource; } IsClean = IsError; // Declare ReportView as clean if an error occurs.. } catch (Exception ex) { IsClean = true; } finally { IsLoading = false; _delaying = false; cts.Dispose(); } } }
public void TestCreateYearReport() { RunAsync(async delegate { var view = new SummaryReportView(); view.Period = ZoomLevel.Year; await view.Load(0); Assert.AreEqual(false, view.IsLoading); Assert.AreEqual(false, view.IsError); Assert.AreEqual(true, view.ActivityCount == 12); Assert.AreEqual(true, view.Projects.Count > 0); Assert.AreEqual(true, view.CollapsedProjects.Count > 0); }); }