public async Task <IStepLog> RollBackTransactionAsync() { var result = await RollBackAsync(); Loggmanager.Log(result.Message); return(result); }
public void Enqueue(IStep step) { if (!IsRunning) { QueueToBeDone.Enqueue(step); } Loggmanager.Log("=========Step Enqueue has been added"); }
public async Task <IStepLog> StopTransactionAsync() { cts.Cancel(); var result = await RollBackAsync(); Loggmanager.Log(result.Message); return(result); }
public CopyFileStep(string fileName, string sourceDirectory, string destinationDirectory) { Loggmanager.Log("Replace instance is creating"); FileName = fileName; SourceDirectory = sourceDirectory; DestinationDirectory = destinationDirectory; Loggmanager.Log("Replace instance is created"); }
private LogMessage RollBackFile(string fileName, string backupDirectory, string targetDirectory) { var result = ReplaceFile(fileName, backupDirectory, targetDirectory); // Loggmanager.Log(result); // return(result); }
//Implementation of async transaction manager #region Async wrapper public async Task <IStepLog> StartTransactionAsync() { var result = await StartAsync(); if (!result.IsSuccess) { result = await RollBackAsync(); } Loggmanager.Log(result.Message); return(result); }
private LogMessage RollBackFile(string fileName, string backupDirectory, string targetDirectory) { Loggmanager.Log($"========== ROLLBACK the file:{Path.Combine(backupDirectory, fileName)} to: {Path.Combine(targetDirectory, fileName)} directory"); var result = ReplaceFile(fileName, backupDirectory, targetDirectory); // Loggmanager.Log(result); Loggmanager.Log($"========== ROLLBACK the file:{Path.Combine(backupDirectory, fileName)} to: {Path.Combine(targetDirectory, fileName)} directory"); // return(result); }
private LogMessage BackupFile(string fileName, string sourceDirectory, string destinationDirectory) { if (!Directory.Exists(BackupDirectory)) { Directory.CreateDirectory(BackupDirectory); } var result = ReplaceFile(fileName, destinationDirectory, BackupDirectory); Loggmanager.Log(result); // return(result); }
private LogMessage BackupFile(string fileName, string sourceDirectory, string destinationDirectory) { if (!Directory.Exists(BackupDirectory)) { Directory.CreateDirectory(BackupDirectory); } Loggmanager.Log($"==BACKUP the file:{Path.Combine(sourceDirectory, fileName)} to: {Path.Combine(destinationDirectory, fileName)} directory"); var result = ReplaceFile(fileName, sourceDirectory, BackupDirectory); Loggmanager.Log(result); Loggmanager.Log($"==BACKUP file :{Path.Combine(sourceDirectory, fileName)} to: {Path.Combine(destinationDirectory, fileName)} directory has been completed with state: {result.IsSuccess}, Message: {result.Message}"); // return(result); }
private LogMessage ReplaceFile(string fileName, string sourceDirectory, string destinationDirectory) { try { Loggmanager.Log($"REPLACING started the file: {Path.Combine(sourceDirectory, fileName)} to: {Path.Combine(destinationDirectory, fileName)} directory"); if (!Directory.Exists(sourceDirectory)) { LogMessage l = new LogMessage(); l.IsSuccess = false; l.Message = $"Directory for copying :{sourceDirectory} is not exists"; return(l); } // FullFilePath = Path.Combine(sourceDirectory, fileName); if (!File.Exists(FullFilePath)) { LogMessage l = new LogMessage(); l.IsSuccess = false; l.Message = $"File for copying :{FullFilePath} is not exists"; return(l); } // if (!Directory.Exists(destinationDirectory)) { LogMessage l = new LogMessage(); l.IsSuccess = false; l.Message = $"Cant create inexistent folder :{destinationDirectory} is not exists"; return(l); } FullTargetPath = Path.Combine(destinationDirectory, fileName); File.Copy(FullFilePath, FullTargetPath, true); Loggmanager.Log($"REPLACING ended the file: {Path.Combine(sourceDirectory, fileName)} to: {Path.Combine(destinationDirectory, fileName)} directory"); // return(new LogMessage() { IsSuccess = true }); } catch (Exception ex) { LogMessage l = new LogMessage(); l.IsSuccess = false; l.Message = $"Exception while : {ex.Message}, Internal exception: {ex.InnerException?.Message}"; // return(l); } }