是否有人知道允许我将许多RDL文件部署到许多SSRS服务器的工具?
最多50个报告到20多个服务器。每个ssrs服务器都具有相同的结构。
感谢您的帮助
汉斯
答案 0 :(得分:5)
好消息,有几种方法可以做到这一点,这里有一个从低级别到高级别的列表:
创建使用SSRS Web服务的自定义应用程序
您可以使用Reporting Services Web服务执行此任务但除非您有其他方式未涵盖的特定需求,否则我不会推荐它。
原因是它需要一些时间,而且没有必要重新发明轮子。
有2个可用的Web服务,要管理报表服务器项,您需要ReportingService2010或ReportingService2005,具体取决于您的Reporting Service实例。
有关如何使用这些网络服务的更多详细信息here。
手动脚本
您可以编写脚本(.rss)并使用RS.exe导入它们 此工具基于前面提到的Web服务。
rs.exe实用程序处理您在输入文件中提供的脚本。 使用此实用程序自动执行报表服务器部署和 管理任务。
请注意,SQL Server 2008 R2 +支持Sharepoint模式。
这是一篇MSDN文章解释,提供了更多细节:
Sample Reporting Services rs.exe Script to Migrate Content between Report Servers
使用工具生成脚本
这是我最喜欢的一个,已经从服务器A编写了几个工具来编写脚本项并将其恢复到服务器B,其中一个是RSScripter。 您可以找到有关如何使用它的教程here。
在内部,它使用RS.exe
,GUI的步骤是:
还有来自Microsoft的Reporting Service Migration Tool,它似乎有一些额外的功能,但我从未测试过它。
答案 1 :(得分:0)
您可以编写自己的程序来执行此操作,如下所示:
private static string UploadReportFiles(string[] args)
{
string results = String.Empty;
string filesFolder = String.Empty;
string fileName = String.Empty;
if (args.Count() > 14)
{
try
{
//args[0] - Command
//args[1] - Switch Should be /S Server Name
string serverName = args[2];
//args[3] - Switch Should be /U User Name
string userName = args[4];
//args[5] - Switch Should be /P User Password
string password = args[6];
//args[7] - Switch Should be /M Server Manager Folder
string managerFolder = args[8];
//args[9] - Switch Should be /R Server Reports Folder
string reportFolder = args[10];
//args[11] - Switch Should be /D Server Data Sources Folder
string dataSourceFolder = args[12];
//args[13] - Switch Should be /F Files Folder
filesFolder = args[14];
ReportingService2005 rs = new ReportingService2005();
string url = <ProjectNamespace>.Properties.Settings.Default.RDLManager_ReportService_ReportingService2005.Replace("localhost", serverName).Replace("ReportServer", managerFolder);
rs.Url = url;
NetworkCredential networkCredential = new NetworkCredential(userName, password);
rs.Credentials = networkCredential;
CatalogItem[] rootItems = rs.ListChildren("/", false);
IEnumerable<string> rootNames = from x in rootItems.AsEnumerable()
select x.Name;
if (!rootNames.Contains(reportFolder))
{
rs.CreateFolder(reportFolder, "/", null);
}
CatalogItem[] items = rs.ListChildren("/" + reportFolder, false);
IEnumerable<string> itemNames = from x in items.AsEnumerable()
select x.Name;
string[] reportFiles = Directory.GetFiles(filesFolder);
foreach (string file in reportFiles)
{
string returnMessage = String.Empty;
try
{
if (file.EndsWith(".rdl") && !file.Contains("Backup"))
{
FileInfo fi = new FileInfo(file);
fileName = fi.Name.Replace(".rdl", "");
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
string reportFilePath = Path.Combine(filesFolder, fileName);
using (FileStream fs = new FileStream(reportFilePath + ".rdl", FileMode.Open))
{
// Read the source file into a byte array.
byte[] bytes = new byte[fs.Length];
int numBytesToRead = (int)fs.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = fs.Read(bytes, numBytesRead, numBytesToRead);
// Break when the end of the file is reached.
if (n == 0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
numBytesToRead = bytes.Length;
string reportName = fileName.Replace(".rdl", "");
Warning[] publishErrors;
if (itemNames.Contains(reportName))
{
System.Console.WriteLine("Uploading Report File - " + fileName);
string report = "/" + reportFolder + "/" + reportName;
DataSource[] existingDataSources = null;
DataSource existingDataSource = null;
existingDataSources = rs.GetItemDataSources(report);
if (null != existingDataSources)
{
existingDataSource = existingDataSources[0];
}
publishErrors = rs.SetReportDefinition(report, bytes);
DataSource[] publishedDataSources = null;
publishedDataSources = rs.GetItemDataSources(report);
if (null != existingDataSource)
{
List<DataSource> replacementDataSources = new List<DataSource>();
DataSourceReference dsr = new DataSourceReference();
string dataSourcePath = "/" + dataSourceFolder + "/" + existingDataSource.Name;
dsr.Reference = dataSourcePath;
foreach (DataSource publishedDataSource in publishedDataSources)
{
DataSource ds = new DataSource();
ds.Item = (DataSourceDefinitionOrReference)dsr;
ds.Name = publishedDataSource.Name;
replacementDataSources.Add(ds);
}
rs.SetItemDataSources(report, replacementDataSources.ToArray());
}
}
else
{
publishErrors = rs.CreateReport(reportName, "/" + reportFolder, true, bytes, null);
fileName = fileName + " - NEW REPORT UPDATE DATASOURCE MANUALLY!";
System.Console.WriteLine("Uploading Report File - " + fileName);
}
if (null != publishErrors)
{
foreach (Warning w in publishErrors)
{
if (w.Severity != "Warning")
{
returnMessage = "Warning: ";
returnMessage = returnMessage + w.Message;
}
}
}
}
}
}
catch (SoapException ex)
{
returnMessage = "Error Uploading File:" + fileName + " Exception:" + ex.Detail.InnerXml.ToString();
}
catch (IOException ex)
{
returnMessage = "Error Uploading File:" + fileName + " Exception:" + ex.Message;
}
catch (Exception ex)
{
returnMessage = "Error Uploading File:" + fileName + " Exception:" + ex.Message;
}
string logLineItem = "Uploaded " + fileName + " to " + serverName + ". " + returnMessage;
LogItem.LogMessage(logLineItem, filesFolder);
}
results = "Upload Complete!";
}
catch (SoapException ex)
{
results = "Error Uploading Files Exception:" + ex.Detail.InnerXml.ToString();
}
catch (IOException ex)
{
results = "Error Uploading Files Exception:" + ex.Message;
}
catch (Exception ex)
{
results = "Error Uploading Files Exception:" + ex.Message;
}
}
else
{
ShowHelpText();
}
if (!String.IsNullOrEmpty(filesFolder))
{
LogItem.LogMessage(results, filesFolder);
}
return results;
}