public override void Execute(IReportStatus status, ConDepSettings settings, CancellationToken token) { var configFilePath = Path.Combine(_configDirPath, _configName); var transformFilePath = Path.Combine(_configDirPath, _transformName); var backupPath = ""; if (ConDepConfigBackupExist(_configDirPath, _configName)) { Logger.Info("Using [{0}] as configuration file to transform", _configDirPath + CONDEP_CONFIG_EXTENSION); backupPath = Path.Combine(_configDirPath, _configName + CONDEP_CONFIG_EXTENSION); } else { BackupConfigFile(_configDirPath, _configName); } Logger.Info("Transforming [{0}] using [{1}]", configFilePath, transformFilePath); var trans = new SlowCheetah.Tasks.TransformXml { BuildEngine = new TransformConfigBuildEngine(), Source = string.IsNullOrWhiteSpace(backupPath) ? configFilePath : backupPath, Transform = transformFilePath, Destination = configFilePath }; var success = trans.Execute(); if (!success) { throw new CondepWebConfigTransformException(string.Format("Failed to transform [{0}] file.", _configName)); } }
public override IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options) { var configFilePath = Path.Combine(_configDirPath, _configName); var transformFilePath = Path.Combine(_configDirPath, _transformName); var backupPath = ""; if(ConDepConfigBackupExist(_configDirPath, _configName)) { Logger.Info("Using [{0}] as configuration file to transform", _configDirPath + CONDEP_CONFIG_EXTENSION); backupPath = Path.Combine(_configDirPath, _configName + CONDEP_CONFIG_EXTENSION); } else { BackupConfigFile(_configDirPath, _configName); } Logger.Info("Transforming [{0}] using [{1}]", configFilePath, transformFilePath); var trans = new SlowCheetah.Tasks.TransformXml { BuildEngine = new TransformConfigBuildEngine(), Source = string.IsNullOrWhiteSpace(backupPath) ? configFilePath : backupPath, Transform = transformFilePath, Destination = configFilePath }; var success = trans.Execute(); if(!success) throw new CondepWebConfigTransformException(string.Format("Failed to transform [{0}] file.", _configName)); return status; }
public override Result Execute(ConDepSettings settings, CancellationToken token) { var result = Result.SuccessChanged(); var configFilePath = Path.Combine(_configDirPath, _configName); var transformFilePath = Path.Combine(_configDirPath, _transformName); var backupPath = ""; if (ConDepConfigBackupExist(_configDirPath, _configName)) { Logger.Info("Using [{0}] as configuration file to transform", _configDirPath + CONDEP_CONFIG_EXTENSION); backupPath = Path.Combine(_configDirPath, _configName + CONDEP_CONFIG_EXTENSION); } else { BackupConfigFile(_configDirPath, _configName); } Logger.Info("Transforming [{0}] using [{1}]", configFilePath, transformFilePath); var trans = new SlowCheetah.Tasks.TransformXml { BuildEngine = new TransformConfigBuildEngine(), Source = string.IsNullOrWhiteSpace(backupPath) ? configFilePath : backupPath, Transform = transformFilePath, Destination = configFilePath }; result.Data.Config = trans.Source; result.Data.Trasform = trans.Transform; var success = trans.Execute(); if (!success) { result.Success = false; Logger.Error($"Failed to transform [{_configName}] file."); } return(result); }