我正在为客户编写 Reporting Services 解决方案。我正在我的开发环境中开发此解决方案,并且无权访问客户站点。我正在寻找一种方法来打包我的 Reporting Services 解决方案。我想要某种类型的安装程序部署包,它可以帮助他们在安装期间指定他们的生产数据源。
问问题
1803 次
1 回答
3
没有一个内置的。
- 您需要创建一个 dll 项目并编写自定义安装程序操作。有关示例,请参阅演练:创建自定义操作。
- 您的 dll 将需要包含对 http://SsrsServer.mydomain.tld/ReportServer/ReportService2005.asmx的 Web 服务引用。请参阅如何:添加对 Web 服务的引用。
- 您需要向安装程序添加一个自定义对话框,以询问报表服务器部署位置。有关如何创建和使用自定义对话框的示例,请参阅演练:在安装时使用自定义操作创建数据库。
- 您需要一个自定义对话框来获取将部署报告的文件夹。
- 您需要以编程方式更改 Web 服务引用的目标。
- 您需要进行适当的 Web 服务调用来创建数据源。
- 您需要进行适当的 Web 服务调用来创建报告。
- 您需要将报表绑定到数据源。
您将需要的报告服务 Web 服务记录在ReportingService2005 类中。以下是操作的一些示例代码:
/// <summary>
/// Gets the reporting service SOAP client with the specified report server URL.
/// </summary>
/// <param name="reportServerUrl">The report server URL.</param>
/// <returns>An instance of the reporting service SOAP client.</returns>
internal static ReportingService2005SoapClient GetReportingService2005(Uri reportServerUrl)
{
EndpointAddress endPoint = new EndpointAddress(reportServerUrl);
ReportService2005.ReportingService2005SoapClient soapClient = new ReportService2005.ReportingService2005SoapClient("ReportingService2005Soap", endPoint);
soapClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
return soapClient;
}
/// <summary>
/// Creates the data source.
/// </summary>
/// <param name="reportServerUri">The report server URI.</param>
/// <param name="parentPath">The parent path.</param>
/// <param name="itemName">Name of the item.</param>
/// <param name="dataSourceDefinition">The data source definition.</param>
internal static void CreateDataSource(Uri reportServerUri, string parentPath, string itemName, string description, DataSourceDefinition dataSourceDefinition)
{
using (ReportingService2005SoapClient reportingService = GetReportingService2005(reportServerUri))
{
ServerInfoHeader serverInfo = null;
try
{
Property[] props = CreateDescriptionProperty(description);
serverInfo = reportingService.CreateDataSource(null, itemName, parentPath, true, dataSourceDefinition, props);
}
catch (FaultException ex)
{
Trace.WriteLine(string.Format("CreateDataSource {0}/{1}: {2}", parentPath, itemName, ex.Message));
}
}
}
/// <summary>
/// Creates the report.
/// </summary>
/// <param name="reportServerUri">The report server URI.</param>
/// <param name="parentPath">The parent path.</param>
/// <param name="itemName">Name of the item.</param>
/// <param name="reportDefinition">The report definition.</param>
internal static void CreateReport(Uri reportServerUri, string parentPath, string itemName, string description, byte[] reportDefinition)
{
Warning[] warnings;
using (ReportingService2005SoapClient reportingService = GetReportingService2005(reportServerUri))
{
ServerInfoHeader serverInfo = null;
try
{
Property[] props = CreateDescriptionProperty(description);
serverInfo = reportingService.CreateReport(null, itemName, parentPath, true, reportDefinition, props, out warnings);
}
catch (FaultException ex)
{
Trace.WriteLine(string.Format("CreateReport {0}/{1}: {2}", parentPath, itemName, ex.Message));
}
}
}
/// <summary>
/// Set the report or model data sources on the reporting server from the provided data source map entries.
/// </summary>
/// <param name="reportServerUri">The report server URI.</param>
/// <param name="itemPath"></param>
/// <param name="dataSourceMapEntries"></param>
internal static void SetItemDataSourceMap(Uri reportServerUri, string itemPath, Dictionary<string, string> dataSourceMapEntries)
{
DataSource[] dataSources = (from dataSourceMapEntry in dataSourceMapEntries
where !string.IsNullOrEmpty(dataSourceMapEntry.Value)
select ConvertDataSourceMapEntry(dataSourceMapEntry)).ToArray();
using (ReportingService2005SoapClient reportingService = GetReportingService2005(reportServerUri))
{
ServerInfoHeader serverInfo = null;
try
{
serverInfo = reportingService.SetItemDataSources(null, itemPath, dataSources);
}
catch (FaultException ex)
{
Trace.WriteLine(string.Format("SetItemDataSourceMap {0} {1}", itemPath, ex.Message));
}
}
}
/// <summary>
/// Convert a data source map entry into a report server data source object.
/// </summary>
/// <param name="dataSourceMapEntry"></param>
/// <returns></returns>
private static DataSource ConvertDataSourceMapEntry(KeyValuePair<string, string> dataSourceMapEntry)
{
DataSource dataSource = new DataSource();
DataSourceReference dataSourceReference = new DataSourceReference();
dataSource.Name = dataSourceMapEntry.Key;
dataSourceReference.Reference = dataSourceMapEntry.Value;
dataSource.Item = dataSourceReference;
return dataSource;
}
于 2012-07-23T22:56:59.463 回答