public OperationResult StartDownload(InputPropertyPackage inputPropertyPackage) { double totalMemoryBefore = (double)GC.GetTotalMemory(false) / (1024 * 1024); Logger.Instance.WriteLog.InfoFormat("Total memory {0:N1} MBytes", totalMemoryBefore); OperationResult result = new OperationResult(); try { result = PackageManagerParameters.Instance.LoadingInitialData(inputPropertyPackage); IList<ICommand> commandsList = CreateCommands(); foreach (ICommand command in commandsList) { result = command.Execute(); if (result.Status == StatusResult.Fail) { Logger.Instance.WriteLog.Error(command + ": " + result.ErrorMessage); return result; } } } catch (Exception ex) { Logger.Instance.WriteLog.Error(ex); throw; } Logger.Instance.WriteLog.Info("Installation package finished"); double totalMemoryAfter = (double)GC.GetTotalMemory(false) / (1024 * 1024); Logger.Instance.WriteLog.InfoFormat("Memory footprint {0:N1} MBytes", totalMemoryAfter - totalMemoryBefore); return result; }
public static OperationResult GetOperationResultAndCheckValueOnNullOrEmpty(Dictionary<string, object> values) { OperationResult result = new OperationResult(); result.ErrorMessage = CheckValueOnNullOrEmpty(values); if (result.ErrorMessage.Length > 0) { result.Status = StatusResult.Fail; } return result; }
public OperationResult RestoreCodeTree() { Logger.Instance.WriteLog.Info("RestoreCodeTree started"); OperationResult result = new OperationResult() { Status = StatusResult.Success }; try { gitWrapper.RevertLastCommit(); Logger.Instance.WriteLog.Info("RestoreCodeTree finished"); } catch (LibGit2SharpException e) { result.GetErrorFromException(e); } return result; }
public OperationResult DecompressZip(string zipPath, bool isDeleteAfterDecompress) { Logger.Instance.WriteLog.Info("Decompress Zip started"); OperationResult result = new OperationResult { Status = StatusResult.Success }; try { FileManager.DecompressZip(zipPath, isDeleteAfterDecompress); Logger.Instance.WriteLog.Info("Decompress Zip finished"); } catch (IOException e) { result.GetErrorFromException(e); } return result; }
private static OperationResult XmlPoke(PackageConfig packageConfig) { if (!packageConfig.XmlPoke.Any()) { Logger.Instance.WriteLog.Info(CommonResources.MsgPropertyNotExistInConfigFile.GetStringByFormat("XmlPoke")); return null; } Logger.Instance.WriteLog.Info("XmlPoke started"); OperationResult result = new OperationResult(); foreach (XmlPoke poke in packageConfig.XmlPoke) { OperationResult newResult = new XmlPokeTask(poke).Execute(); result = result.СombineResult(newResult); } Logger.Instance.WriteLog.Info("XmlPoke finished"); return result; }
private OperationResult XmlPeek(PackageConfig packageConfig) { if (!packageConfig.XmlPeek.Any()) { Logger.Instance.WriteLog.Info(CommonResources.MsgPropertyNotExistInConfigFile.GetStringByFormat("XmlPeek")); return null; } Logger.Instance.WriteLog.Info("XmlPeek started"); OperationResult result = new OperationResult(); foreach (XmlPeek peek in packageConfig.XmlPeek) { OperationResult newResult = new XmlPeekTask(peek, configurationFileManager).Execute(); result = result.СombineResult(newResult); } Logger.Instance.WriteLog.Info("XmlPeek finished"); return result; }
static internal OperationResult СombineResult(this OperationResult result, OperationResult newResult) { if (newResult == null) { return result; } if (newResult.Status == StatusResult.Warning) { result.AddWarningMessage(newResult.WarningMessages); result.Status = newResult.Status; } if (newResult.Status == StatusResult.Fail) { result.ErrorMessage = newResult.ErrorMessage; result.Status = newResult.Status; } return result; }
public OperationResult CreateDirectories() { Logger.Instance.WriteLog.Info("CreateDirectories started"); OperationResult result = new OperationResult() {Status = StatusResult.Success}; try { foreach (string directoryPath in directoriesList) { FileManager.CreateDirectoryIfNotExists(directoryPath); } Logger.Instance.WriteLog.Info("CreateDirectories finished"); } catch (IOException e) { result.GetErrorFromException(e); } return result; }
public OperationResult InstallModule(string configPath, IList<InstallationModuleType> moduleInstallationTypes) { OperationResult result = new OperationResult(); OperationResult newResult; IEnumerable<ModuleInstallation> moduleInstallations = configurationFileManager.PackageConfig.Installation.Module.Where(x => moduleInstallationTypes.Contains(x.InstallationModuleType)); if (!moduleInstallations.Any()) { return result.GetWarningFromString(CommonResources.MsgInstallationModuleNotExistInConfigFile); } newResult = XmlPeek(configurationFileManager.PackageConfig); result = result.СombineResult(newResult); newResult = XmlPoke(configurationFileManager.PackageConfig); result = result.СombineResult(newResult); foreach (ModuleInstallation module in moduleInstallations) { Logger.Instance.WriteLog.Info(string.Format(CultureInfo.InvariantCulture, "Installation module ({0}) started", module.Id)); newResult = DeleteFiles(module); result = result.СombineResult(newResult); newResult = CopyingFile(module); result = result.СombineResult(newResult); newResult = ProgramExecution(module); result = result.СombineResult(newResult); newResult = ImportIntoDb(module); result = result.СombineResult(newResult); Logger.Instance.WriteLog.Info(string.Format(CultureInfo.InvariantCulture, "Installation module ({0}) finished", module.Id)); } return result; }
private static OperationResult CopyingFile(ModuleInstallation module) { if (!module.Copy.Any()) { Logger.Instance.WriteLog.Info(CommonResources.MsgPropertyNotExistInConfigFile.GetStringByFormat("Copy")); return null; } Logger.Instance.WriteLog.Info("CopyingFile started"); OperationResult result = new OperationResult(); foreach (Copy item in module.Copy) { OperationResult newResult = new CopyTask(item).Execute(); result = result.СombineResult(newResult); } Logger.Instance.WriteLog.Info("CopyingFile finished"); return result; }
private static OperationResult ImportIntoDb(ModuleInstallation module) { if (!module.Import.Any()) { Logger.Instance.WriteLog.Info(CommonResources.MsgPropertyNotExistInConfigFile.GetStringByFormat("Import")); return null; } Logger.Instance.WriteLog.Info("ImportIntoDb started"); OperationResult result = new OperationResult(); foreach (Import item in module.Import) { OperationResult newResult = new ImportTask(item).Execute(); result = result.СombineResult(newResult); } Logger.Instance.WriteLog.Info("ImportIntoDb finished"); return result; }
private static OperationResult ProgramExecution(ModuleInstallation module) { if (!module.Exec.Any()) { Logger.Instance.WriteLog.Info(CommonResources.MsgPropertyNotExistInConfigFile.GetStringByFormat("Exec")); return null; } Logger.Instance.WriteLog.Info("Program execution started"); OperationResult result = new OperationResult(); foreach (Exec item in module.Exec) { OperationResult newResult = new ExecTask(item).Execute(); result = result.СombineResult(newResult); } Logger.Instance.WriteLog.Info("Program execution finished"); return result; }