async Task LoadProjectsFromDb() { var projects = await GetStorageService().GetProjects(Id); foreach (var asanaProject in projects) { var tasksCount = await SetProjectInfo(asanaProject); asanaProject.TasksCount = tasksCount.Item1; asanaProject.OverdueTasksCount = tasksCount.Item2; } DispatcherHelper.OnUi(() => { //model.ArchiveProjects.Clear(); Projects.Clear(); Projects.AddRange(projects); Workspace.ProjectsCount = projects.Count(x => !x.archived); if (IsPinned) { PinService.CreateUpdateStartTileAsync(Workspace.name, Workspace.ProjectsCountText, PinService.GetWorkspaceDetailsUri(Id), false); } // model.ArchiveProjects.AddRange(projects.Where(x => x.archived)); }); }
private async Task LoadTasksFromDb() { var tasks = await new StorageService().GetTasks(Id); foreach (var asanaTask in tasks) { FillTaskCommands(asanaTask); await MapperService.FillSubtasksInfo(asanaTask); } Tasks.Clear(); Tasks.AddRange(tasks); Project.TasksCount = ActiveTasks.Count; if (IsPinned) { PinService.CreateUpdateStartTileAsync(Project.name, Project.TasksCountText, PinService.GetProjectDetailsUri(Id), false); } NotifyAll(); }
public async void LoadData(bool isUserAction = false) { IsBusy = true; User = await new StorageService().Find <AsanaUser>(UserId); await LoadTasksFromDb(); IsBusy = false; if (NavigationEventArgs.IsBackOrReset()) { NotifyAll(); return; } if (CheckInternetConnection(false)) { AddOperation(); var tasks = new List <System.Threading.Tasks.Task>(); foreach (var w in User.GetAvailableWorkspaces()) { tasks.Add(LoadTasks(w, isUserAction)); } System.Threading.Tasks.Task.Factory.ContinueWhenAll(tasks.ToArray(), x => { User.TasksCount = ActiveTasks.Count; if (IsPinned) { PinService.CreateUpdateStartTileAsync(User.name, User.TasksCountText, PinService.GetUserDetailsUri(UserId), false); } RemoveOperation(); }); } await OffineSyncTaskService.Execute(this, () => { }); }