我正在为客户编写Reporting Services解决方案。我正在开发环境中开发此解决方案,并且无法访问客户站点。我正在寻找一种方法来打包我的Reporting Services解决方案。我想要一些类型的安装程序部署包,它将帮助他们在安装期间指定他们的生产数据源。
答案 0 :(得分:3)
没有内置的。
您需要的报告服务Web服务记录在ReportingService2005 Class。以下是操作的一些示例代码:
/// <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;
}