部署Reporting Services解决方案

时间:2012-07-23 21:51:17

标签: reporting-services ssrs-2008 sql-server-2012

我正在为客户编写Reporting Services解决方案。我正在开发环境中开发此解决方案,并且无法访问客户站点。我正在寻找一种方法来打包我的Reporting Services解决方案。我想要一些类型的安装程序部署包,它将帮助他们在安装期间指定他们的生产数据源。

1 个答案:

答案 0 :(得分:3)

没有内置的。

  1. 您需要创建一个dll项目并编写自定义安装程序 行动。有关,请参阅Walkthrough: Creating a Custom Action 示例
  2. 您的dll需要包含一个Web服务引用 http://SsrsServer.mydomain.tld/ReportServer/ReportService2005.asmx。 见How to: Add a Reference to a Web Service
  3. 您需要向安装程序添加自定义对话框以询问 报告服务器部署位置。有关示例,请参阅Walkthrough: Using a Custom Action to Create a Database at Installation 如何创建和使用自定义对话框。
  4. 您需要一个自定义对话框来获取报告所在的文件夹     部署。
  5. 您需要以编程方式更改您的Web服务引用 目的地。
  6. 您需要进行适当的Web服务调用才能创建 的数据源。
  7. 您需要进行适当的Web服务调用才能创建 报告。
  8. 您需要将报告绑定到DataSource。
  9. 您需要的报告服务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;
        }