private async Task <List <CategoryData> > CategoriesSortedData() { var categoryDatas = new List <CategoryData>(); var items = await ArchiveStore.GetItemsAsync(); List <Category> categories; if (DataStore is DataBaseStore dataBaseStore) { categories = await dataBaseStore.GetCateoriesAsync() as List <Category>; foreach (var category in categories) { var categoryData = new CategoryData() { Category = category }; var outData = items.Where(obj => obj.Category == category.Name).Select(obj => obj); categoryData.Tasks = new List <ArchiveItem>(outData); categoryDatas.Add(categoryData); } } else { return(null); } return(await Task.FromResult(categoryDatas)); }
async void RemoveFinishedItem(ItemsPage obj, Item item) { var archiveItem = new ArchiveItem(await DataStore.GetItemAsync(item.Id)); await DataStore.DeleteItemAsync(item.Id); Items.Remove(item); archiveItem.Id = null; archiveItem.Date = DateTime.Now.ToString(); await ArchiveStore.AddItemAsync(archiveItem); }
/// <summary> /// Constructor. /// </summary> public RepositoryContents( string repoName, string branchName, ArchiveStore backingStore) { RepoName = repoName; BranchName = branchName; BackingStore = backingStore; Contents = new UncompressedMemoryArchive ( new Dictionary <string, byte[]>() ); }
/// <summary> /// Returns an archive for the downloaded repository. /// </summary> private IArchive GetArchive(byte[] sourceRepoBytes, ArchiveStore archiveStore) { switch (archiveStore) { case ArchiveStore.FileSystem: return(GetFileSystemBackedArchive(sourceRepoBytes)); case ArchiveStore.Memory: return(GetMemoryBackedArchive(sourceRepoBytes)); default: throw new ArgumentOutOfRangeException(nameof(archiveStore)); } }
/// <summary> /// Returns the given repository in the GitHub organization. /// </summary> public async Task <IArchive> GetRepositoryContentsAsync( string organizationName, string repositoryName, string branchName, ArchiveStore backingStore) { var reference = branchName != null ? $"heads/{branchName}" : string.Empty; byte[] sourceRepoBytes = await _client.Repository.Content.GetArchive ( organizationName, repositoryName, ArchiveFormat.Zipball, reference ); return(GetArchive(sourceRepoBytes, backingStore)); }
/// <summary> /// Downloads submissions for a set of students. /// </summary> public async Task <IArchive> GetRepositoryContentsAsync( string organizationName, string repositoryName, string branchName, ArchiveStore backingStore) { try { return(await _repoClient.GetRepositoryContentsAsync ( organizationName, repositoryName, branchName, backingStore )); } catch (Octokit.NotFoundException) { return(null); } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); var categories = new List <Category>(); if (DataStore is DataBaseStore dataBaseStore) { categories = await dataBaseStore.GetCateoriesAsync() as List <Category>; } var items = await ArchiveStore.GetItemsAsync(true); foreach (var item in items) { var category = categories.Where <Category>(obj => obj.Name == item.Category).FirstOrDefault(); if (category != null) { item.Category = category.Section + ": " + category.Name; } Items.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
async void RemoveArchiveItem(ArchiveItemsPage obj, ArchiveItem item) { await ArchiveStore.DeleteItemAsync(item.Id); Items.Remove(item); }
/// <summary> /// Constructor. /// </summary> public RepositoryContents( string repoName, string branchName, ArchiveStore backingStore) { RepoName = repoName; BranchName = branchName; BackingStore = backingStore; Contents = new UncompressedMemoryArchive ( new Dictionary<string, byte[]>() ); }