/// <summary> /// Procesa una copia de archivos /// </summary> private async Task ProcessCopyAsync(BlockLogModel parent, CopyBlobSentence sentence, CancellationToken cancellationToken) { string processType = sentence.Move ? "move" : "copy"; string blobTarget = sentence.Target.Blob; // Obtiene el nombre del archivo destino si hay que transformarlo en un nombre único if (sentence.TransformFileName) { blobTarget = System.IO.Path.GetFileNameWithoutExtension(sentence.Target.Blob) + $" {DateTime.UtcNow:yyyy-MM-dd HH_mm_ss_ms}" + System.IO.Path.GetExtension(sentence.Target.Blob); } // Procesa la instrucción using (BlockLogModel block = parent.CreateBlock(LogModel.LogType.Info, $"Start {processType} from '{sentence.Source.ToString()}' to '{sentence.Target.Container}/{blobTarget}'")) { CloudConnection connection = GetConnection(sentence.StorageKey); if (connection == null) { AddError(block, $"Can't find the connection for '{sentence.StorageKey}'"); } else { try { // Copia / mueve el archivo using (ICloudStorageManager manager = new StorageManager().OpenAzureStorageBlob(connection.StorageConnectionString)) { if (sentence.Move) { await manager.MoveAsync(GetContainerName(sentence.Source.Container), sentence.Target.Blob, GetContainerName(sentence.Target.Container), blobTarget, cancellationToken); } else { await manager.CopyAsync(GetContainerName(sentence.Source.Container), sentence.Target.Blob, GetContainerName(sentence.Target.Container), blobTarget, cancellationToken); } } // Log block.Info($"End {processType} from '{sentence.Source.ToString()}' to '{sentence.Target.Container}/{blobTarget}'"); } catch (Exception exception) { AddError(block, $"Error when {processType} from '{sentence.Source.ToString()}' to '{sentence.Target.Container}/{blobTarget}'", exception); } } } }