public async Task <bool> LoadAutomationSequencesAsync(List <DatabasePackage> packagesToRun) { if (RootDocument == null) { throw new NullReferenceException(); } if (packagesToRun == null) { throw new NullReferenceException(); } if (packagesToRun.Count == 0) { throw new BadMemeException("packagesToRun must have at least one package to run automation on"); } Logging.AutomationRunner(LogOptions.MethodName, "Checking root document for to build urls to download automation sequences", LogLevel.Info); foreach (DatabasePackage package in packagesToRun) { Logging.AutomationRunner(LogOptions.MethodName, "Parsing path for automation of package {0}", LogLevel.Info, package.PackageName); //sample xpath: /root.xml/AutomationSequence[@UID='123456789ABCD'] XmlElement result = XmlUtils.GetXmlNodeFromXPath(RootDocument, string.Format("/root.xml/AutomationSequence[@UID='{0}']", package.UID)) as XmlElement; if (result == null) { Logging.Error(Logfiles.AutomationRunner, "Package not found in automation database"); return(false); } if (result.Attributes["packageName"].Value != package.PackageName) { Logging.Warning(Logfiles.AutomationRunner, "The packageName property is out of date. From database: {0}. From Package: {1}", result.Attributes["packageName"].Value, package.PackageName); } string pathToFileFromRepoRoot = result.Attributes["path"].Value; if (string.IsNullOrEmpty(pathToFileFromRepoRoot)) { Logging.Error(Logfiles.AutomationRunner, "Package path attribute not found from xml node"); return(false); } if (pathToFileFromRepoRoot[0] == '/') { Logging.Warning(Logfiles.AutomationRunner, "Package path attribute starts with slash, please update entry to remove it!"); pathToFileFromRepoRoot = pathToFileFromRepoRoot.Substring(1); } AutomationSequences.Add(new AutomationSequence() { AutomationSequencer = this, Package = package, SequenceDownloadUrl = AutomationXmlRepoFilebaseEscaped + pathToFileFromRepoRoot }); Logging.Debug(Logfiles.AutomationRunner, "Added automation sequence URL: {0}", AutomationSequences.Last().SequenceDownloadUrl); } Logging.Info(Logfiles.AutomationRunner, LogOptions.MethodName, "Parsing each automationSequence xml document from its download URL"); foreach (AutomationSequence automationSequence in AutomationSequences) { Logging.Info(Logfiles.AutomationRunner, "Load automation sequence xml for package {0}", automationSequence.Package.PackageName); await automationSequence.LoadAutomationXmlAsync(); } return(true); }
public bool ParseRootDocumentAsync() { if (RootDocument == null) { throw new NullReferenceException(); } if (AutomationRunnerSettings == null) { throw new NullReferenceException(); } Logging.AutomationRunner(LogOptions.MethodName, "Checking root document for to build automation sequences", LogLevel.Info); XmlNodeList sequencesXml = XmlUtils.GetXmlNodesFromXPath(RootDocument, "//root.xml/AutomationSequence"); if (sequencesXml == null || sequencesXml.Count == 0) { return(false); } AutomationSequences.Clear(); foreach (XmlElement result in sequencesXml) { string sequencePackageName = result.Attributes["packageName"].Value; string sequenceUID = result.Attributes["UID"].Value; string sequenceUrlPath = result.Attributes["path"].Value; string sequenceLoadString; if (AutomationRunnerSettings.UseLocalRunnerDatabase) { sequenceUrlPath = sequenceUrlPath.Replace('/', Path.DirectorySeparatorChar); sequenceLoadString = Path.Combine(AutomationRepoPathEscaped, sequenceUrlPath); } else { sequenceLoadString = AutomationRepoPathEscaped + sequenceUrlPath; } AutomationSequences.Add(new AutomationSequence(DatabasePackages, ApplicationMacros, GlobalMacros, AutomationRunnerSettings, DatabaseManager, CancellationToken) { AutomationSequencer = this, Package = null, PackageName = sequencePackageName, PackageUID = sequenceUID, SequenceDownloadUrl = sequenceLoadString }); } return(true); }