public void Execute(IEnumerable <ICommand> commands, IMegaNzItemCollection megaNzItemCollection, IFileManager fileManager, IProgress <double> progressNotifier) { foreach (var command in commands) { _logger.Trace(string.Empty); _logger.Trace(command.ToString()); Policy.Handle <Exception>() .Retry(5, (ex, counter) => { _logger.Trace(string.Empty); // New Line _logger.Trace("An exception occurred: " + ex.GetType()); if (ex is AggregateException) { var aggregateException = (AggregateException)ex; if (aggregateException.InnerExceptions.Count > 0) { var innerException = aggregateException.InnerExceptions[0]; _logger.Trace("Inner exception: " + innerException.GetType()); _logger.Trace("Inner exception message: " + innerException.Message); } } _logger.Trace("Retry #" + counter); }) .Execute(() => { command.Execute(_megaApiClient, megaNzItemCollection, fileManager, progressNotifier); }); } }
public void Execute(IMegaApiClient megaApiClient, IMegaNzItemCollection megaNzItemCollection, IFileManager fileManager, IProgress <double> progressNotifier) { var nodeToDelete = megaNzItemCollection.GetByPath(PathToDelete); megaApiClient.Delete(nodeToDelete); megaNzItemCollection.RemoveItemByExactPath(PathToDelete); }
public void Execute(IMegaApiClient megaApiClient, IMegaNzItemCollection megaNzItemCollection, IFileManager fileManager, IProgress <double> progressNotifier) { using (var filestream = fileManager.GetStreamToReadFile(SourcePath)) { var sourceFileName = System.IO.Path.GetFileName(SourcePath); var remoteFileName = NameHandler.BuildRemoteFileName(sourceFileName, LastModifiedDate); var parentMegaNzNode = megaNzItemCollection.GetByPath(DestinationPath); var newMegaNzNode = megaApiClient.UploadAsync(filestream, remoteFileName, parentMegaNzNode, progressNotifier).Result; megaNzItemCollection.Add(newMegaNzNode); } }
public void Execute(IMegaApiClient megaApiClient, IMegaNzItemCollection megaNzItemCollection, IFileManager fileManager, IProgress <double> progressNotifier) { // Find the MegaNZ node related to the parent folder var parent = megaNzItemCollection.GetByPath(ParentPath); // Create the new folder var newNode = megaApiClient.CreateFolder(Name, parent); // Update the item collection megaNzItemCollection.Add(newNode); }