/// <summary> /// Initializes a new instance of the <see cref="BinaryFilesGroup"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="targetFolder">The target folder.</param> /// <param name="dataSourceName">Name of the data source.</param> /// <param name="reportServer">The report server.</param> /// <param name="reports">The reports.</param> public BinaryFilesGroup(string name, string targetFolder, string reportServer, BinaryFile[] reports) { _Name = name; _TargetFolder = targetFolder; //if (dataSourceName != null) //{ // if (Settings.DataSources.ContainsKey(dataSourceName)) // { // _DataSource = (DataSource)Settings.DataSources[dataSourceName]; // } //} if (reportServer != null) { if (Settings.ReportServers.ContainsKey(reportServer)) { _ReportServerInfo = (ReportServerInfo)Settings.ReportServers[reportServer]; } } if (targetFolder != null && targetFolder.Length > 0) { _TargetFolder = targetFolder.Trim(); } if (reports != null && reports.Length > 0) { _BinaryFiles = reports; } }
/// <summary> /// Initializes a new instance of the <see cref="DataSource"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="userName">The user name.</param> /// <param name="password">The password.</param> /// <param name="credentialRetrieval">The credential retrieval enum.</param> /// <param name="windowsCredentials">if set to <c>true</c> [windows credentials].</param> /// <param name="connectionString">The connection string.</param> /// <param name="publish">if set to <c>true</c>, publish.</param> /// <param name="overwrite">if set to <c>true</c>, overwrite.</param> /// <param name="targetFolder">The target folder.</param> /// <param name="reportServer">The report server.</param> public DataSource(string name, string userName, string password, string credentialRetrieval, bool windowsCredentials, string connectionString, bool publish, bool overwrite, string targetFolder, string reportServer) { _Name = name; _UserName = userName; _Password = password; _RSConnectionString = connectionString; _Publish = publish; _Overwrite = overwrite; if (targetFolder != null && targetFolder.Length > 0) { _TargetFolder = targetFolder.Trim(); } if (reportServer != null) { if (Settings.ReportServers.ContainsKey(reportServer)) { _ReportServer = (ReportServerInfo)Settings.ReportServers[reportServer]; } } _CredentialRetrieval = ReportCredential.Integrated; if (credentialRetrieval != null) { try { _CredentialRetrieval = (ReportCredential)Enum.Parse(typeof(ReportCredential), credentialRetrieval, true); } catch (ArgumentException e) { Logger.LogException("DataSource", e.Message); } } _WindowsCredentials = windowsCredentials; }
/// <summary> /// Initializes a new instance of the <see cref="ReportGroup"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="targetFolder">The target folder.</param> /// <param name="dataSourceName">Name of the data source.</param> /// <param name="reportServer">The report server.</param> /// <param name="reports">The reports.</param> public ReportGroup(string name, string targetFolder, string dataSourceName, string reportServer, Report[] reports) { _Name = name; _TargetFolder = targetFolder; if (dataSourceName != null) { if (Settings.DataSources.ContainsKey(dataSourceName)) { _DataSource = (DataSource)Settings.DataSources[dataSourceName]; } } if (reportServer != null) { if (Settings.ReportServers.ContainsKey(reportServer)) { _ReportServer = (ReportServerInfo)Settings.ReportServers[reportServer]; } } if (targetFolder != null && targetFolder.Length > 0) { _TargetFolder = targetFolder.Trim(); } if (reports != null && reports.Length > 0) { _Reports = reports; } }
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)); }
public static bool TryCreate(ReportServerInfo reportServer, out IWSWrapper result, out Exception exception) { ReportingService2005 proxy = new ReportingService2005() { Url = reportServer.GetServiceUrl(SERVICE_NAME), Timeout = reportServer.Timeout ?? -1, Credentials = reportServer.CreateCredentials(SERVICE_NAME) }; try { proxy.ListSecureMethods(); result = new WSWrapper2005(proxy); exception = null; return(true); } catch (Exception e) { proxy.Dispose(); result = null; exception = e; return(false); } }
private static void ReadSettings(XmlDocument d) { // Globals XmlNodeList list5 = d.SelectNodes("//Settings/Globals/Global"); _GlobalVariables = new StringDictionary(); if (list5 != null) { foreach (XmlNode node in list5) { XmlNode key = node.Attributes["Name"]; if (key != null) { if (_GlobalVariables.ContainsKey(key.Value)) { _GlobalVariables[key.Value] = node.InnerText; } else { _GlobalVariables.Add(key.Value, node.InnerText); } } } } // ReportServers XmlNodeList list6 = d.SelectNodes("//Settings/ReportServers/ReportServer"); if (list6 != null) { _ReportServers = new Hashtable(); foreach (XmlNode node in list6) { 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; ReportServerInfo rsInfo = new ReportServerInfo(name, protocol, ProcessGlobals(rsHost.Value), ProcessGlobals(rsPath.Value), timeout, userName, password); if (_ReportServers.ContainsKey(name)) { _ReportServers[name] = rsInfo; } else { _ReportServers.Add(name, rsInfo); } } } } } // DataSources XmlNodeList list1 = d.SelectNodes("//Settings/DataSources/DataSource"); if (list1 != null) { _DataSources = new Hashtable(); _DBConnections = new StringDictionary(); foreach (XmlNode node in list1) { string name = null; string userName = null; string password = null; string credentialRetrieval = null; string connectionString = null; string targetFolder = null; string reportServer = null; bool publish = false; bool overwrite = false; bool windowsCredentials = false; XmlNode n1 = node.Attributes["Name"]; if (n1 != null) { name = n1.Value; XmlNode n2 = node.Attributes["Publish"]; XmlNode n3 = node.SelectSingleNode("ConnectionString"); XmlNode n4 = node.Attributes["Overwrite"]; XmlNode n5 = node.SelectSingleNode("UserName"); XmlNode n6 = node.SelectSingleNode("Password"); XmlNode n7 = node.SelectSingleNode("CredentialRetrieval"); XmlNode n8 = node.SelectSingleNode("WindowsCredentials"); XmlNode n9 = node.Attributes["TargetFolder"]; XmlNode n10 = node.Attributes["ReportServer"]; if (n2 != null) { publish = (n2.Value.ToLower() == "true"); } if (n3 != null) { connectionString = ProcessGlobals(n3.InnerText); } if (n4 != null) { overwrite = (n4.Value.ToLower() == "true"); } if (n5 != null) { if (n5.InnerText.Trim().Length > 0) { userName = ProcessGlobals(n5.InnerText); } } if (n6 != null) { password = ProcessGlobals(n6.InnerText); } if (n7 != null) { credentialRetrieval = ProcessGlobals(n7.InnerText); } if (n8 != null) { windowsCredentials = (n8.InnerText.ToLower() == "true"); } if (n9 != null) { targetFolder = ProcessGlobals(n9.Value); } if (n10 != null) { reportServer = ProcessGlobals(n10.Value); } if (_DataSources.ContainsKey(name)) { _DataSources[name] = new DataSource(name, userName, password, credentialRetrieval, windowsCredentials, connectionString, publish, overwrite, targetFolder, reportServer); _DBConnections[name] = ((DataSource)_DataSources[name]).ConnectionString; } else { _DataSources.Add(name, new DataSource(name, userName, password, credentialRetrieval, windowsCredentials, connectionString, publish, overwrite, targetFolder, reportServer)); _DBConnections.Add(name, ((DataSource)_DataSources[name]).ConnectionString); } } } } // Reports XmlNodeList list7 = d.SelectNodes("//Settings/Reports/ReportGroup"); int k = 0; if (list7 != null) { _ReportGroups = new ReportGroup[list7.Count]; foreach (XmlNode node in list7) { string rgName = null; string targetFolder = null; string dataSourceName = null; string reportServer = null; int cacheTime = -1; Report[] reports = null; 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) { dataSourceName = ProcessGlobals(n2.Value); targetFolder = ProcessGlobals(n3.Value); reportServer = ProcessGlobals(n4.Value); if (n1 != null) { rgName = ProcessGlobals(n1.Value); } if (n14 != null) { cacheTime = int.Parse(ProcessGlobals(n14.Value)); } XmlNodeList list2 = node.SelectNodes("Report"); int i = 0; if (list2 != null) { reports = new Report[list2.Count]; foreach (XmlNode node1 in list2) { string rpName = null; string collapsedHeight = null; int reportCacheTime = cacheTime; XmlNode n11 = node1.SelectSingleNode("FilePath"); if (n11 != null) { XmlNode n12 = node1.Attributes["Name"]; XmlNode n13 = node1.Attributes["CollapsedHeight"]; XmlNode n15 = node1.Attributes["CacheTime"]; if (n12 != null) { rpName = ProcessGlobals(n12.Value); } if (n13 != null) { collapsedHeight = ProcessGlobals(n13.Value); } if (n15 != null) { reportCacheTime = int.Parse(ProcessGlobals(n15.Value)); } reports[i] = new Report(rpName, string.Format("{0}{1}", Settings.CurrentDirectory, n11.InnerText), collapsedHeight, reportCacheTime); } i++; } } _ReportGroups[k] = new ReportGroup(rgName, targetFolder, dataSourceName, reportServer, reports); } k++; } } //BinaryFiles XmlNodeList list8 = d.SelectNodes("//Settings/BinaryFiles/BinaryFilesGroup"); int kk = 0; if (list8 != null) { _BinaryFilesGroup = new BinaryFilesGroup[list8.Count]; foreach (XmlNode node in list8) { string rgName = null; string targetFolder = null; //string dataSourceName = null; string reportServer = null; int cacheTime = -1; BinaryFile[] reports = null; 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 (n3 != null && n4 != null) { // dataSourceName = ProcessGlobals(n2.Value); targetFolder = ProcessGlobals(n3.Value); reportServer = ProcessGlobals(n4.Value); if (n1 != null) { rgName = ProcessGlobals(n1.Value); } if (n14 != null) { cacheTime = int.Parse(ProcessGlobals(n14.Value)); } XmlNodeList list2 = node.SelectNodes("BinaryFile"); int ik = 0; if (list2 != null) { reports = new BinaryFile[list2.Count]; foreach (XmlNode node1 in list2) { string rpName = null; string collapsedHeight = null; int reportCacheTime = cacheTime; XmlNode n11 = node1.SelectSingleNode("FilePath"); if (n11 != null) { XmlNode n12 = node1.Attributes["Name"]; XmlNode n13 = node1.Attributes["CollapsedHeight"]; XmlNode n15 = node1.Attributes["CacheTime"]; if (n12 != null) { rpName = ProcessGlobals(n12.Value); } if (n13 != null) { collapsedHeight = ProcessGlobals(n13.Value); } if (n15 != null) { reportCacheTime = int.Parse(ProcessGlobals(n15.Value)); } reports[ik] = new BinaryFile(rpName, string.Format("{0}{1}", Settings.CurrentDirectory, n11.InnerText), collapsedHeight, reportCacheTime); } ik++; } } _BinaryFilesGroup[kk] = new BinaryFilesGroup(rgName, targetFolder, reportServer, reports); } k++; } } // Executions XmlNodeList list3 = d.SelectNodes("//Settings/DBExecutions/DBExecution"); int j = 0; if (list3 != null) { _DBExecutions = new DBExecution[list3.Count]; foreach (XmlNode node in list3) { XmlNode dataSourceName = node.Attributes["DataSourceName"]; if (dataSourceName != null) { StringCollection files = null; XmlNodeList list4 = node.SelectNodes("DBFilePath"); if (list4 != null) { files = new StringCollection(); foreach (XmlNode node1 in list4) { files.Add(ProcessGlobals(node1.InnerText)); } } _DBExecutions[j] = new DBExecution(ProcessGlobals(dataSourceName.Value), files); } j++; } } }
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))); } } } }