未加星标

Implement Continuous Delivery for SQL Server Reporting Service Reports

字体大小 | |
[数据库(mssql) 所属分类 数据库(mssql) | 发布者 店小二03 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

By:Nat Sundar || Related Tips: > Reporting Services Development

Problem

What is Continuous Delivery and how do I implement Continuous Delivery for SQL Server Reporting Services Reports?

Solution Continuous Delivery

As per Martin Fowler, " Continuous Delivery is a software development discipline where you build software in such a way that the software can be released to production at any time.

There are two key elements to implement Continuous Delivery:

DevOps Culture Deployment Automation Continuous Integration vs. Continuous Delivery

CI (Continuous Integration) refers to the process of integrating, building, and testing for development purpose. However CD (Continuous Delivery) will help us to prepare the artifacts for the purpose of production deployment.

Deployment Automation

Deployment automation helps applications to deploy into multiple environments. This solution improves the productivity of both the Development and Operation teams.

Advantages of Deployment Automation Repeatability - Deployment to multiple environments is done using the same process Insight - Deployment related errors can be identified early in the process Low Risk - Completely remove the bottleneck of key resources (Developers) for the deployment

Most of the application release automation tools allow configuring a script to deploy. We have already learned to develop a PowerShell script to deploy the data source in the previoustip. In this tip we will learn to deploy the datasets and the reports using a PowerShell script. This script can be integrated with any release automation tool to enable Continuous Delivery for SQL Server Reporting Service Reports.

Deploying Shared Datasets

As same as the data source, the dataset can also be read as an XML object. This XML object will have the details about the Query, Columns and the data source. PowerShell can create a dataset object in the Reporting Services proxy with the help of an XML object. The CreateCatalogItem function can be used to create a dataset on the Reporting Services proxy.

Once the dataset has been created, the data source reference has to be updated. The SetItemDataSource function will help us to link the data source for the given dataset.

The script below is used to read and deploy the dataset to a remote Reporting Services Server.

$ReportServerUri = "http://localhost/ReportServer_SQL2012/ReportService2010.asmx?wsdl";
$DataSetFile = "C:\mssqlTips\Tips\SSRS_Deployment_Using_ps_Part3\Reference\Scripts\AdventureWorks Sample Reports\Currency.rsd";
$DataSourceFolder = "/MSSQLTips/Data Sources";
$DataSetFolder = "/Datasets";
try{
#Create Proxy
$global:proxy = New-WebServiceProxy -Uri $ReportServerUri -UseDefaultCredential
-ErrorAction Stop;
If ($proxy -ne $null)
{
echo $global:proxy.ToString();
}
#$DataSetFile = Get-Content -Path $DataSetFilePath
$DataSetName = [System.IO.Path]::GetFileNameWithoutExtension($DataSetFile);
$stream = [System.IO.File]::ReadAllBytes( $DataSetFile);
$warnings =@();
#Create dataset item in the server
try{
$newDataSet = $proxy.CreateCatalogItem("DataSet,$DataSetName,$DataSetFolder,
$true,$stream,$null,[ref]$warnings); }catch{ throw $_.Exception; }
[xml]$XmlDataSetDefinition = Get-Content $DataSetFile;
$xmlDataSourceReference = $XmlDataSetDefinition.SharedDataSet.DataSet | where {$_ | get-member Query};
try{ $dataSetDataSources = $proxy.GetItemDataSources($($newDataSet.Path)); }
catch{ throw $_.Exception; }
foreach ($dataSetDataSource in $dataSetDataSources)
{ #Should only be one!
$proxyNamespace = $dataSetDataSource.GetType().Namespace;
$newDataSourceReference = New-Object ($proxyNamespace.DataSource);
$newDataSourceReference.Name = $dataSetDataSource.Name;
$newDataSourceReference.Item = New-Object ($proxyNamespace.DataSourceReference);
$newDataSourceReference.Item.Reference =
$DataSourceFolder/$($xmlDataSourceReference.Query.DataSourceReference);
$dataSetDataSource.item = $newDataSourceReference.Item;
try { $proxy.SetItemDataSources($DataSetFolder/$DataSetName, $newDataSourceReference);
}
catch{ throw $_.Exception; }
}
echo "Dataset has been deployed !;
}
catch {
$valProxyError = $_.Exception.Message;
echo $_.Exception.Message;
}

You will get this message (as shown in the image below) after successful execution.


Implement Continuous Delivery for SQL Server Reporting Service Reports

After successful deployment, the data set property can be seen as shown below.


Implement Continuous Delivery for SQL Server Reporting Service Reports
Deploying Reports

Reporting Services Reports can also be deployed the in same way as the data set. First the report will be created using the CreateCatalogItem function. If there are no shared datasets used in the report, then the report needs to be re-linked with the data sources.

The SetItemDataSource function will help us to link the data source for the given report.

The script below is used to read and deploy the data set to a remote Reporting Services Server.

$ReportServerUri = "http://localhost/ReportServer_SQL2012/ReportService2010.asmx?wsdl";
$ReportFile = "C:\MSSQLTips\Tips\SSRS_Deployment_Using_ps_Part3\Reference\ScriptsAdventureWorks Sample Reports\Employee Sales Summary SQL2008R2.rdl";
$DataSourceFolder = "/MSSQLTips/Data Sources";
$DataSetFolder = "/MSSQLTips/Datasets";
$ReportsFolder = "/MSSQLTips/Reports";
$reportDataSource = "AdventureWorks2008R2";
try{
#Create Proxy
$global:proxy = New-WebServiceProxy -Uri $ReportServerUri -UseDefaultCredential -ErrorAction Stop;
If ($proxy -ne $null)
{
echo $global:proxy.ToString()
}
$ReportName = [System.IO.Path]::GetFileNameWithoutExtension($ReportFile)
$stream = [System.IO.File]::ReadAllBytes( $ReportFile);
$warnings =@();
try{ $newReport = $proxy.CreateCatalogItem(Report,$ReportName,$ReportsFolder,$true,$stream,$null,[ref]$warnings);
}catch{ throw $_.Exception; }
#relink report to datasource
echo Updating Datasource references;
try{ $reportDataSources = $proxy.GetItemDataSources($ReportsFolder/$ReportName); }catch{ throw $_.Exception; }
foreach ($reportDataSource in $reportDataSources)
{
$serverDataSourceItem = $allitems | where {($_.TypeName -eq DataSource) -and ($_.Path -eq
$DataSourceFolder/$($reportDataSource.Name))};
$proxyNamespace = $reportDataSource.GetType().Namespace;
$newDataSourceReference = New-Object ($proxyNamespace.DataSource);
$newDataSourceReference.Name = $reportDatasource.Name;
$newDataSourceReference.Item = New-Object ($proxyNamespace.DataSourceReference);
#$newDataSourceReference.Item.Reference = $serverDataSourceItem.Path;
$newDataSourceReference.Item.Reference = "$DataSourceFolder/$($reportDataSource.Name)";
$reportDataSource.item = $newDataSourceReference.Item;
try{ $proxy.SetItemDataSources($ReportsFolder/$ReportName, $newDataSourceReference); }catch{ throw $_.Exception; }
}
echo Report has been deployed !;
}
catch {
$valProxyError = $_.Exception.Message;
echo $_.Exception.Message;
}

You will get this message (as shown in the image below) after successful execution.


Implement Continuous Delivery for SQL Server Reporting Service Reports

After successful deployment, the dataset property can be seen as shown below


Implement Continuous Delivery for SQL Server Reporting Service Reports
Deploying the Reporting Services Data Source, Dataset and Reports in Folder A typical Business Inte

本文数据库(mssql)相关术语:熊片数据库 mssql数据库 oracle数据库 pubmed数据库 access数据库 万方数据库

主题: SQLPowerShellXMLSQL Server
分页:12
转载请注明
本文标题:Implement Continuous Delivery for SQL Server Reporting Service Reports
本站链接:http://www.codesec.net/view/480457.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(mssql) | 评论(0) | 阅读(31)