public AccountFile(Account account, StorageFile storageFile, IEnumerable<DriveFile> driveFiles, AccountFile parent) { DriveFiles.AddRange(driveFiles); this.StorageFile = storageFile; Parent = parent; Account = account; }
public async Task<ICollection<AccountFile>> GetSubfoldersAsync(AccountFile folder, CancellationToken token) { IDictionary<string, DriveFileCollection> driveFiles = new Dictionary<string, DriveFileCollection>(); foreach (var f in folder.DriveFiles) { PutFilesTo(await f.Drive.GetSubfoldersAsync(f, token), driveFiles); } return driveFiles.Values.Select(files => new AccountFile(this, Storage.GetFile(files), files, folder)).ToList(); }
public static AccountFileStates GetFileState(AccountFile file) { AccountFileStates ret = 0; var nDrives = file.Account.Drives.Count; var nDrivesSyncronized = file.Account.Drives.Select(x => file.GetDriveFile(x)).Count(x => x != null); DriveFile inventoryFile; if (file.Account.Drives.InventoryDrive == null) { inventoryFile = null; } else { nDrives--; inventoryFile = file.GetDriveFile(file.Account.Drives.InventoryDrive); if (inventoryFile != null) { nDrivesSyncronized--; } } if (nDrivesSyncronized != nDrives) { ret |= AccountFileStates.UnsyncronizedWithAllDrives; } if (file.Account.Drives.InventoryDrive != null) { if (inventoryFile == null) { ret |= AccountFileStates.PlacedOnlyDrive; } else if (nDrivesSyncronized == 0) { ret |= AccountFileStates.PlacedOnlyStorage; } } if (file.StorageFileId == null) { ret |= AccountFileStates.UnsyncronizedWithStorage; } else if (!file.HasValidStorageFileId) { ret |= AccountFileStates.Error; } return ret; }
public async Task <Image> GetThumbnailAsync(AccountFile file, CancellationToken token) { foreach (var drive in Drives) { try { return(await drive.GetThumbnailAsync(file.GetDriveFile(drive), token)); } catch (Exception ex) { OnError(ex); } } throw new Exception("Can't download this file"); }
public async Task<Image> GetThumbnailAsync(AccountFile file, CancellationToken token) { foreach (var drive in Drives) { try { return await drive.GetThumbnailAsync(file.GetDriveFile(drive), token); } catch (Exception ex) { OnError(ex); } } throw new Exception("Can't download this file"); }
public async Task DownloadFileFromDriveAsync(AccountFile file, string destFolder, ActionIfFileExists actionIfFileExists, CancellationToken token) { foreach (var drive in Drives) { try { await drive.DownloadFileAsync(file.GetDriveFile(drive), destFolder, actionIfFileExists, token); return; } catch (Exception ex) { OnError(ex); } } throw new Exception("Can't download this file"); }
public async Task DownloadFileFromDriveAsync(AccountFile file, Stream output, CancellationToken token) { foreach (var drive in Drives) { try { await drive.DownloadFileAsync(file.GetDriveFile(drive), output, token); return; } catch (Exception ex) { OnError(ex); } } throw new Exception("Can't download this file"); }
public virtual async Task <Image> GetImageAsync(AccountFile file, CancellationToken token) { foreach (var drive in Drives) { var f = file.GetDriveFile(drive); if (f == null) { continue; } var image = await drive.GetImageAsync(f, token); if (image != null) { return(image); } } return(null); }
public async Task <AccountFile> GetFileAsync(XElement fileXml, CancellationToken token) { var storageXml = fileXml.Element("storageFile"); var driveXmls = fileXml.Element("driveFiles").Elements(); var storageFile = storageXml == null ? null : await Storage.GetFileAsync(storageXml, token); List <DriveFile> driveFiles; var tasks = Drives.Select( drive => { var driveFileXml = driveXmls.SingleOrDefault(x => x.Attribute("driveId").Value == drive.Id); var ret = driveFileXml == null ? null : drive.GetFileAsync(driveFileXml, token); return(ret); }).Where(x => x != null); driveFiles = new List <DriveFile>(await Task.WhenAll(tasks)); var parentXml = fileXml.Element("parent"); AccountFile parent = parentXml == null ? null : await GetFileAsync(parentXml, token); return(new AccountFile(this, storageFile, driveFiles, parent)); }
public AccountFile(Account account, StorageFile storageFile, AccountFile parent) { this.StorageFile = storageFile; Parent = parent; Account = account; }
public virtual async Task<Image> GetImageAsync(AccountFile file, CancellationToken token) { foreach (var drive in Drives) { var f = file.GetDriveFile(drive); if (f == null) { continue; } var image = await drive.GetImageAsync(f, token); if (image != null) { return image; } } return null; }
private void AddNode(AccountFile file, TreeNode parentNode, string accountName) { var newNode = parentNode.Nodes.Add("", file.Name, FolderImageKey); newNode.SelectedImageKey = FolderImageKey; newNode.Tag = new NodeInfo(file, accountName); if (file.HasChildren) newNode.Nodes.Add("", "", ""); }
public async Task<AccountFile> CreateFolderAsync(string folderName, AccountFile destFolder, CancellationToken token) { var storageDir = await Storage.CreateFolderAsync(folderName, destFolder.StorageFile, token); var tasks = Drives.Select(drive => drive.CreateFolderAsync(folderName, destFolder.GetDriveFile(drive), token)); return new AccountFile(this, storageDir, await Task.WhenAll(tasks), destFolder); }
public async Task DownloadFileFromStorageAsync(AccountFile file, Stream output, CancellationToken token, Action <TransferProgress> progressCallback) { await Storage.DownloadFileAsync(file.StorageFile, output, token, progressCallback); }
/// <summary> /// Download folder or file from storage (not from drive). /// </summary> /// <param name="destFolder">Path of folder whare to nest a downloaded file or folder. /// For example if <paramref name="file"/> is "/photo2010/egypt" and <paramref name="destFolder"/> /// is "d:/photos", then in "photos" folder will be created subfolder "egypt" with downloaded files. /// </param> public async Task DownloadFileFromStorageAsync(AccountFile file, string destFolder, ActionIfFileExists actionIfFileExists, CancellationToken token, Action <TransferProgress> progressCallback) { await Storage.DownloadFileAsync(file.StorageFile, destFolder, actionIfFileExists, token, progressCallback); }
public async Task DeleteFolderAsync(AccountFile folder, CancellationToken token) { var tasks = Drives.Select(drive => { var file = folder.GetDriveFile(drive); if (file == null) { return null; } return drive.DeleteFolderAsync(file, token); }).Where(x => x != null); await Task.WhenAll(tasks); }
/// <summary> /// Upload folder of file to storage and drive. /// </summary> public async Task<AccountFile> UploadFileAsync(string pathName, AccountFile destFolder, CancellationToken token, Action<TransferProgress> progressCallback) { var uploadedFile = await Storage.UploadFileAsync(pathName, destFolder.StorageFile, token, progressCallback); var tasks = Drives.Select(drive => drive.UploadFileAsync(pathName, destFolder.GetDriveFile(drive), uploadedFile.Id, token)); var uploadedDriveFiles = await Task.WhenAll(tasks); return new AccountFile(this, uploadedFile, uploadedDriveFiles, destFolder); }
public AccountFile(Account account, StorageFile storageFile, IEnumerable <DriveFile> driveFiles, AccountFile parent) { DriveFiles.AddRange(driveFiles); this.StorageFile = storageFile; Parent = parent; Account = account; }
public async Task DownloadFileFromDriveAsync(AccountFile file, string destFolder, ActionIfFileExists actionIfFileExists, CancellationToken token) { foreach (var drive in Drives) { try { await drive.DownloadFileAsync(file.GetDriveFile(drive), destFolder, actionIfFileExists, token); return; } catch (Exception ex) { OnError(ex); } } throw new Exception("Can't download this file"); }
public async Task DownloadFileFromStorageAsync(AccountFile file, Stream output, CancellationToken token, Action<TransferProgress> progressCallback) { await Storage.DownloadFileAsync(file.StorageFile, output, token, progressCallback); }
/// <summary> /// Download folder or file from storage (not from drive). /// </summary> /// <param name="destFolder">Path of folder whare to nest a downloaded file or folder. /// For example if <paramref name="file"/> is "/photo2010/egypt" and <paramref name="destFolder"/> /// is "d:/photos", then in "photos" folder will be created subfolder "egypt" with downloaded files. /// </param> public async Task DownloadFileFromStorageAsync(AccountFile file, string destFolder, ActionIfFileExists actionIfFileExists, CancellationToken token, Action<TransferProgress> progressCallback) { await Storage.DownloadFileAsync(file.StorageFile, destFolder, actionIfFileExists, token, progressCallback); }
public AccountFile(Account account, StorageFile storageFile, AccountFile parent) { this.StorageFile = storageFile; Parent = parent; Account = account; }
public async Task DownloadFileFromDriveAsync(AccountFile file, Stream output, CancellationToken token) { foreach (var drive in Drives) { try { await drive.DownloadFileAsync(file.GetDriveFile(drive), output, token); return; } catch (Exception ex) { OnError(ex); } } throw new Exception("Can't download this file"); }