public void Refresh() { if (BoxDetailFile != null && BoxDetailFile.Count > 0) { BoxDetailFile.Clear(); } if (BoxDetailFileChild != null && BoxDetailFileChild.Count > 0) { BoxDetailFileChild.Clear(); } BoxClient _boxClient = ServiceManager.Instence().BoxClient; if (_boxClient != null) { InitBoxRootFolderItems(_boxClient); } }
public async void InitBoxRootFolderItems(BoxClient client) { BoxCollection <BoxItem> items = null; if (BoxDetailFile == null) { BoxDetailFile = new ObservableCollection <FileEntity>(); } if (BoxDetailFile != null && BoxDetailFile.Count > 0) { BoxDetailFile.Clear(); } if (BoxDetailFileChild == null) { BoxDetailFileChild = new ObservableCollection <FileEntity>(); } if (BoxDetailFileChild != null && BoxDetailFile.Count > 0) { BoxDetailFileChild.Clear(); } try { if (client != null) { items = await client.FoldersManager.GetFolderItemsAsync("0", 500); if (items != null) { foreach (var item in items.Entries) { if (item != null) { var fileEntity = new FileEntity(); if (item.Type.ToLower().ToString().Equals("file")) { var boxfile = await client.FilesManager.GetInformationAsync(item.Id); fileEntity.FileName = boxfile.Name; fileEntity.FileId = boxfile.Id; fileEntity.FileSize = Convert.ToString(boxfile.Size); fileEntity.ParentID = boxfile.Parent.Id; fileEntity.IsFile = true; } else if (item.Type.ToLower().ToString().Equals("folder")) { var boxfolder = await client.FoldersManager.GetInformationAsync(item.Id); fileEntity.FileName = boxfolder.Name; fileEntity.FileId = boxfolder.Id; fileEntity.FileSize = Convert.ToString(boxfolder.Size); fileEntity.ParentID = boxfolder.Parent.Id; fileEntity.IsFile = false; } if (fileEntity != null) { BoxDetailFile.Add(fileEntity); } } } } } } catch (Exception ex) { throw; } }