/// <summary> /// Reads the given rule file /// </summary> public static List <DeployRule> ReadConfigurationFile(string path, out string readingErrorsHtml) { var outputMessage = new StringBuilder(); // get all the rules var list = new List <DeployRule>(); Utils.ForEachLine(path, new byte[0], (lineNb, lineString) => { try { var items = lineString.Split('\t'); if (items.Length == 4) { // new variable var obj = new DeployVariableRule { Source = path, Line = lineNb + 1, NameFilter = items[0].Trim(), SuffixFilter = items[1].Trim(), VariableName = items[2].Trim(), Path = items[3].Trim() }; if (!obj.VariableName.StartsWith("<") || !obj.VariableName.EndsWith(">")) { outputMessage.Append("- The variable rule line n°" + (lineNb + 1) + " is incorrect, the variable should have the format <b><XXX></b><br>"); return; } if (!string.IsNullOrEmpty(obj.Path)) { list.Add(obj); } } int step = 0; if (items.Length > 1 && !int.TryParse(items[0].Trim(), out step)) { return; } // new transfer rule if (items.Length >= 6) { DeployType type; if (Enum.TryParse(items[3].Trim(), true, out type)) { var obj = DeployTransferRule.New(type); obj.Source = path; obj.Line = lineNb + 1; obj.Step = step; obj.NameFilter = items[1].Trim(); obj.SuffixFilter = items[2].Trim(); obj.ContinueAfterThisRule = items[4].Trim().EqualsCi("yes") || items[4].Trim().EqualsCi("true"); obj.SourcePattern = items[5].Trim(); var newRules = new List <DeployTransferRule> { obj }; if (items.Length > 6) { var multipleTargets = items[6].Split('|'); obj.DeployTarget = multipleTargets[0].Trim().Replace('/', '\\'); for (int i = 1; i < multipleTargets.Length; i++) { DeployTransferRule copiedRule = obj.GetCopy(); copiedRule.ContinueAfterThisRule = true; copiedRule.DeployTarget = multipleTargets[i].Trim().Replace('/', '\\'); newRules.Add(copiedRule); } } foreach (var rule in newRules) { rule.ShouldDeployTargetReplaceDollar = rule.DeployTarget.StartsWith(":"); if (rule.ShouldDeployTargetReplaceDollar) { rule.DeployTarget = rule.DeployTarget.Remove(0, 1); } string errorMsg; var isOk = rule.IsValid(out errorMsg); if (isOk) { list.Add(rule); } else if (!string.IsNullOrEmpty(errorMsg)) { outputMessage.Append(errorMsg); outputMessage.Append("<br>"); } } } } if (items.Length == 5) { // new filter rule var obj = new DeployFilterRule { Source = path, Line = lineNb + 1, Step = step, NameFilter = items[1].Trim(), SuffixFilter = items[2].Trim(), Include = items[3].Trim().EqualsCi("+") || items[3].Trim().EqualsCi("Include"), SourcePattern = items[4].Trim() }; obj.RegexSourcePattern = obj.SourcePattern.StartsWith(":") ? obj.SourcePattern.Remove(0, 1) : obj.SourcePattern.Replace('/', '\\').WildCardToRegex(); if (!string.IsNullOrEmpty(obj.SourcePattern)) { list.Add(obj); } } } catch (Exception e) { outputMessage.Append("- Unknown error reading rule line n°" + (lineNb + 1) + " : " + e.Message + "<br>"); } }, Encoding.Default); readingErrorsHtml = outputMessage.ToString(); return(list); }
public FileToDeployCopy(string sourcePath, string targetBasePath, DeployTransferRule rule) : base(sourcePath, targetBasePath, rule) { }
public FileToDeployDeleteInProlib(string sourcePath, string targetBasePath, DeployTransferRule rule) : base(sourcePath, targetBasePath, rule) { }
/// <summary> /// Constructor /// </summary> protected FileToDeployInPack(string sourcePath, string targetBasePath, DeployTransferRule rule) : base(sourcePath, targetBasePath, rule) { }
public static FileToDeploy New(DeployType deployType, string sourcePath, string targetBasePath, DeployTransferRule rule) { switch (deployType) { case DeployType.Prolib: return(new FileToDeployProlib(sourcePath, targetBasePath, rule)); case DeployType.Zip: return(new FileToDeployZip(sourcePath, targetBasePath, rule)); case DeployType.DeleteInProlib: return(new FileToDeployDeleteInProlib(sourcePath, targetBasePath, rule)); case DeployType.Ftp: return(new FileToDeployFtp(sourcePath, targetBasePath, rule)); case DeployType.Delete: return(new FileToDeployDelete(sourcePath, targetBasePath, rule)); case DeployType.Copy: return(new FileToDeployCopy(sourcePath, targetBasePath, rule)); case DeployType.Move: return(new FileToDeployMove(sourcePath, targetBasePath, rule)); case DeployType.Cab: return(new FileToDeployCab(sourcePath, targetBasePath, rule)); case DeployType.CopyFolder: return(new FileToDeployCopyFolder(sourcePath, targetBasePath, rule)); case DeployType.DeleteFolder: return(new FileToDeployDeleteFolder(sourcePath, targetBasePath, rule)); default: throw new ArgumentOutOfRangeException("deployType", deployType, null); } }
/// <summary> /// Constructor /// </summary> public FileToDeploy(string sourcePath, string targetBasePath, DeployTransferRule rule) { Origin = sourcePath; TargetBasePath = targetBasePath; RuleReference = rule; }