/// <summary> /// Read the list of compilation Path Items, /// if the file is present in the Config dir, use it /// </summary> public static void Import() { var outputMessage = new StringBuilder(); _fullDeployRulesList = new List<DeployRule>(); Utils.ForEachLine(Config.FileDeploymentRules, new byte[0], (lineNb, lineString) => { var items = lineString.Split('\t'); int step = 0; if (items.Length > 1 && !int.TryParse(items[0].Trim(), out step)) step = 0; // new transfer rule if (items.Length == 7) { DeployType type; if (!Enum.TryParse(items[3].Trim(), true, out type)) type = DeployType.Copy; var obj = new DeployTransferRule { Step = step, NameFilter = items[1].Trim(), SuffixFilter = items[2].Trim(), Type = type, ContinueAfterThisRule = items[4].Trim().EqualsCi("yes"), SourcePattern = items[5].Trim().Replace('/', '\\'), DeployTarget = items[6].Trim().Replace('/', '\\'), Line = (lineNb + 1) }; if (obj.Type == DeployType.Ftp && !obj.DeployTarget.IsValidFtpAdress()) { outputMessage.Append("- The FTP rule line n°" + (lineNb + 1) + " has an incorrect deployment target, it should follow the pattern ftp://user:pass@server:port/distantpath/ (with user/pass/port being optionnal)<br>"); return; } if (obj.Type == DeployType.Zip && !obj.DeployTarget.ContainsFast(".zip")) { outputMessage.Append("- The ZIP rule line n°" + (lineNb + 1) + " has an incorrect deployment target, a .zip should be found<br>"); return; } if (obj.Type == DeployType.Prolib && !obj.DeployTarget.ContainsFast(".pl")) { outputMessage.Append("- The Prolib rule line n°" + (lineNb + 1) + " has an incorrect deployment target, a .pl should be found<br>"); return; } if (!string.IsNullOrEmpty(obj.SourcePattern) && !string.IsNullOrEmpty(obj.DeployTarget)) _fullDeployRulesList.Add(obj); // new filter rule } else if (items.Length == 5) { var obj = new DeployFilterRule { Step = step, NameFilter = items[1].Trim(), SuffixFilter = items[2].Trim(), Include = items[3].Trim().EqualsCi("+") || items[3].Trim().EqualsCi("Include"), SourcePattern = items[4].Trim().Replace('/', '\\'), }; if (!string.IsNullOrEmpty(obj.SourcePattern)) _fullDeployRulesList.Add(obj); } }, Encoding.Default); if (outputMessage.Length > 0) UserCommunication.NotifyUnique("deployRulesErrors", "The following rules are incorrect:<br><br>" + outputMessage + "<br><br>Please correct them " + Config.FileDeploymentRules.ToHtmlLink("here"), MessageImg.MsgHighImportance, "Errors reading rules file", "Rules incorrect", args => { EditRules(); args.Handled = true; }); else UserCommunication.CloseUniqueNotif("deployRulesErrors"); if (OnDeployConfigurationUpdate != null) OnDeployConfigurationUpdate(); }
/// <summary> /// Read the list of compilation Path Items, /// if the file is present in the Config dir, use it /// </summary> public static void Import() { var outputMessage = new StringBuilder(); _fullDeployRulesList = new List <DeployRule>(); Utils.ForEachLine(Config.FileDeploymentRules, new byte[0], (lineNb, lineString) => { var items = lineString.Split('\t'); int step = 0; if (items.Length > 1 && !int.TryParse(items[0].Trim(), out step)) { step = 0; } // new transfer rule if (items.Length == 7) { DeployType type; if (!Enum.TryParse(items[3].Trim(), true, out type)) { type = DeployType.Copy; } var obj = new DeployTransferRule { Step = step, NameFilter = items[1].Trim(), SuffixFilter = items[2].Trim(), Type = type, ContinueAfterThisRule = items[4].Trim().EqualsCi("yes"), SourcePattern = items[5].Trim().Replace('/', '\\'), DeployTarget = items[6].Trim().Replace('/', '\\'), Line = (lineNb + 1) }; if (obj.Type == DeployType.Ftp && !obj.DeployTarget.IsValidFtpAdress()) { outputMessage.Append("- The FTP rule line n°" + (lineNb + 1) + " has an incorrect deployment target, it should follow the pattern ftp://user:pass@server:port/distantpath/ (with user/pass/port being optionnal)<br>"); return; } if (obj.Type == DeployType.Zip && !obj.DeployTarget.ContainsFast(".zip")) { outputMessage.Append("- The ZIP rule line n°" + (lineNb + 1) + " has an incorrect deployment target, a .zip should be found<br>"); return; } if (obj.Type == DeployType.Prolib && !obj.DeployTarget.ContainsFast(".pl")) { outputMessage.Append("- The Prolib rule line n°" + (lineNb + 1) + " has an incorrect deployment target, a .pl should be found<br>"); return; } if (!string.IsNullOrEmpty(obj.SourcePattern) && !string.IsNullOrEmpty(obj.DeployTarget)) { _fullDeployRulesList.Add(obj); } // new filter rule } else if (items.Length == 5) { var obj = new DeployFilterRule { Step = step, NameFilter = items[1].Trim(), SuffixFilter = items[2].Trim(), Include = items[3].Trim().EqualsCi("+") || items[3].Trim().EqualsCi("Include"), SourcePattern = items[4].Trim().Replace('/', '\\'), }; if (!string.IsNullOrEmpty(obj.SourcePattern)) { _fullDeployRulesList.Add(obj); } } }, Encoding.Default); if (outputMessage.Length > 0) { UserCommunication.NotifyUnique("deployRulesErrors", "The following rules are incorrect:<br><br>" + outputMessage + "<br><br>Please correct them " + Config.FileDeploymentRules.ToHtmlLink("here"), MessageImg.MsgHighImportance, "Errors reading rules file", "Rules incorrect", args => { EditRules(); args.Handled = true; }); } else { UserCommunication.CloseUniqueNotif("deployRulesErrors"); } if (OnDeployConfigurationUpdate != null) { OnDeployConfigurationUpdate(); } }