private ReportGroup CreateReportGroup(string name, string targetFolder, string dataSourceName, string reportServer, IEnumerable <Report> reports) { DataSource dataSource = dataSourceName != null && DataSources.ContainsKey(dataSourceName) ? DataSources[dataSourceName] : null; ReportServerInfo reportServerInfo = reportServer != null && ReportServers.ContainsKey(reportServer) ? ReportServers[reportServer] : null; return(new ReportGroup(name, targetFolder, dataSource, reportServerInfo, reports)); }
private void ReadSettings(XmlDocument d) { // Globals XmlNodeList globalVariableNodes = d.SelectNodes("//Settings/Globals/Global"); if (globalVariableNodes != null) { foreach (XmlNode node in globalVariableNodes) { XmlNode key = node.Attributes["Name"]; if (key != null) { _globalVariables[key.Value] = node.InnerText; } } } // ReportServers XmlNodeList reportServerNodes = d.SelectNodes("//Settings/ReportServers/ReportServer"); if (reportServerNodes != null) { foreach (XmlNode node in reportServerNodes) { XmlNode n0 = node.Attributes["Name"]; if (n0 != null) { string name = ProcessGlobals(n0.Value); XmlNode rsHost = node.Attributes["Host"]; XmlNode rsPath = node.Attributes["Path"]; if (rsHost != null && rsPath != null) { XmlNode rsProtocol = node.Attributes["Protocol"]; string protocol = rsProtocol != null ? ProcessGlobals(rsProtocol.Value) : "http"; XmlNode rsTimeout = node.Attributes["Timeout"]; string timeout = rsTimeout != null ? ProcessGlobals(rsTimeout.Value) : null; XmlNode rsUserName = node.Attributes["UserName"]; string userName = rsUserName != null && rsUserName.Value.Trim().Length > 0 ? ProcessGlobals(rsUserName.Value) : null; XmlNode rsPassword = node.Attributes["Password"]; string password = rsPassword != null ? ProcessGlobals(rsPassword.Value) : null; _reportServers[name] = new ReportServerInfo(name, protocol, ProcessGlobals(rsHost.Value), ProcessGlobals(rsPath.Value), timeout, userName, password); } } } } // DataSources XmlNodeList dataSourceNodes = d.SelectNodes("//Settings/DataSources/DataSource"); if (dataSourceNodes != null) { foreach (XmlNode node in dataSourceNodes) { XmlNode nameAttribute = node.Attributes["Name"]; if (nameAttribute != null) { XmlNode publishAttribute = node.Attributes["Publish"]; XmlNode extensionElement = node.SelectSingleNode("Extension"); XmlNode connectionStringElement = node.SelectSingleNode("ConnectionString"); XmlNode overwriteAttribute = node.Attributes["Overwrite"]; XmlNode userNameElement = node.SelectSingleNode("UserName"); XmlNode passwordElement = node.SelectSingleNode("Password"); XmlNode credentialRetrievalElement = node.SelectSingleNode("CredentialRetrieval"); XmlNode windowsCredentialsElement = node.SelectSingleNode("WindowsCredentials"); XmlNode targetFolderElement = node.Attributes["TargetFolder"]; XmlNode reportServerAttribute = node.Attributes["ReportServer"]; string name = nameAttribute.Value; bool publish = publishAttribute != null && Convert.ToBoolean(publishAttribute.Value, CultureInfo.InvariantCulture); bool overwrite = overwriteAttribute != null && Convert.ToBoolean(overwriteAttribute.Value, CultureInfo.InvariantCulture); string extension = extensionElement != null ? ProcessGlobals(extensionElement.InnerText) : null; string connectionString = connectionStringElement != null ? ProcessGlobals(connectionStringElement.InnerText) : null; string userName = userNameElement != null ? ProcessGlobals(userNameElement.InnerText).Trim() : null; string password = passwordElement != null ? ProcessGlobals(passwordElement.InnerText) : null; string credentialRetrieval = credentialRetrievalElement != null ? ProcessGlobals(credentialRetrievalElement.InnerText) : null; bool windowsCredentials = windowsCredentialsElement != null && Convert.ToBoolean(windowsCredentialsElement.Value, CultureInfo.InvariantCulture); string targetFolder = targetFolderElement != null ? PathUtil.FormatPath(ProcessGlobals(targetFolderElement.Value)) : null; string reportServer = reportServerAttribute != null ? ProcessGlobals(reportServerAttribute.Value) : null; ReportServerInfo reportServerInfo = reportServer != null && ReportServers.ContainsKey(reportServer) ? ReportServers[reportServer] : null; DataSource dataSource = new DataSource(name, userName, password, credentialRetrieval, windowsCredentials, extension, connectionString, publish, overwrite, targetFolder, reportServerInfo); _dataSources[name] = dataSource; string dbConnectionString; if (dataSource.TryGetDbConnectionString(out dbConnectionString)) { _dbConnections[name] = dbConnectionString; } } } } // Reports XmlNodeList reportGroupNodes = d.SelectNodes("//Settings/Reports/ReportGroup"); if (reportGroupNodes != null) { foreach (XmlNode node in reportGroupNodes) { XmlNode n1 = node.Attributes["Name"]; XmlNode n2 = node.Attributes["DataSourceName"]; XmlNode n3 = node.Attributes["TargetFolder"]; XmlNode n4 = node.Attributes["ReportServer"]; XmlNode n14 = node.Attributes["CacheTime"]; if (n2 != null && n3 != null && n4 != null) { string rgName = null; string dataSourceName = ProcessGlobals(n2.Value); string targetFolder = PathUtil.FormatPath(ProcessGlobals(n3.Value)); string reportServer = ProcessGlobals(n4.Value); int cacheTime = -1; if (n1 != null) { rgName = ProcessGlobals(n1.Value); } if (n14 != null) { cacheTime = int.Parse(ProcessGlobals(n14.Value)); } _reportGroups.Add( CreateReportGroup(rgName, targetFolder, dataSourceName, reportServer, SelectReports(node, targetFolder, cacheTime))); } } } // Executions XmlNodeList dbExecutionNodes = d.SelectNodes("//Settings/DBExecutions/DBExecution"); if (dbExecutionNodes != null) { foreach (XmlNode node in dbExecutionNodes) { XmlNode dataSourceName = node.Attributes["DataSourceName"]; if (dataSourceName != null) { _dbExecutions.Add(CreateDbExecution( ProcessGlobals(dataSourceName.Value), SelectDbFilePaths(node))); } } } }