zoukankan      html  css  js  c++  java
  • ReportServer Tutorial

    This Document is a walk trough of how to set up a Report Server For newbies

    SoftWare Environment

    SQLServer Express 2014

    1. Link.

    2. When you install the SQLServer 2014, make sure if report server is checked. it is checked defaultly.

    3. Open Reporting Services Configuration Manager just like SQLServer Manager Studio. There are two URLs needed to be noted.
      that is WebServiceURL and ReportManagerURL. The second one is used to manager you report template. The first One is used to generating the
      report for client like winform ReportViewer.

    4. By Default, we need to open IE with runAsAdministrator feature to access to the manager website. if we hope to bypass this limit, we can follow this link to assign the necessary privilege.


    Manager Report Server with PowerShell

    1. instance a object of ReportServer
    $ReportUrl = "http://xxx/ReportServer/ReportService2010.asmx?wsdl"
    $rs = New-WebServiceProxy -Uri $reportUrl -UseDefaultCredential -Namespace "SSRS"
    
    1. Now we can rock over it by using this guide

    2. refer link here

    Code Snap:

    param(
        [Parameter(Mandatory=$false)]
        [string]$ReportServerUrL = "http://xxx:xxx/ReportServer/ReportService2010.asmx?wsdl",
       # [string]$ReportServerUrL = "http://localhost/ReportServer/ReportService2010.asmx?wsdl",
    
        [Parameter(Mandatory=$false)]
        [string]$LocalRDLFilePath = "xxxReportsSSRSReports",
    
        [Parameter(Mandatory=$false)]
        [string]$ReportFolderPath = "/AgencyNoticeReports",
    
        [Parameter(Mandatory=$false)]
        [string]$SharedDataSourcePath = "/AgencyNoticeReports/Agency"
    )
    Function Get-ReportServerInstance
     {
         param(
    
         [Parameter(Mandatory=$true)]
         [string]$ReportUrl,
    
         [Parameter(Mandatory=$false)]
         [string]$Namespace
         )
     
         return New-WebServiceProxy -Uri $ReportUrl -UseDefaultCredential -Namespace $Namespace
     }
    
     Function Delete-ItemsByPath
     {
         param(
             [Parameter(Mandatory=$true)]
             [object]$RS,
    
             [Parameter(Mandatory=$true)]
             [string]$Path,
    
             [Parameter(Mandatory=$false)]
             [bool]$IsRecurse=$false
         )
         $RS.DeleteItem($Path)
         if($IsRecurse){$RS.ListChildren($Path,$IsRecurse) | %{$RS.DeleteItem($_.Path)}}
     }
    
     Function Upload-ReportToRemoteServer
     {
         param(
             [Parameter(Mandatory=$true)]
             [object]$RS,
    
             [Parameter(Mandatory=$true)]
             [string]$RDLFilePath,
    
             [Parameter(Mandatory=$true)]
             [string]$ReportServerPath
         )
         Resolve-Path -Path $RDLFilePath
         $RDLFile = Get-Item -Path $RDLFilePath
         $reportName = [System.IO.Path]::GetFileNameWithoutExtension($RDLFile.Name)
         $bytes = [System.IO.File]::ReadAllBytes($RDLFile.FullName)
         $warnings=$null
         $report = $rs.CreateCatalogItem(
            "Report",         # Catalog item type
            $reportName,      # Report name
            $ReportServerPath,# Destination folder
            $true,            # Overwrite report if it exists?
            $bytes,           # .rdl file contents
            $null,            # Properties to set.
            [ref]$warnings)   # Warnings that occured while uploading.
        $warnings | %{  Write-Output ("Warning: {0}" -f $_.Message)}
     }
    
     Function Create-ReportFolder
     {
         Param(
             [Parameter(Mandatory=$true)]
             [object]$RS,
    
             [Parameter(Mandatory=$true)]
             [string]$FolderName,
    
             [Parameter(Mandatory=$false)]
             [string]$ParentFolderPath="/"
         )
         $RS.CreateFolder($FolderName,$ParentFolderPath,$null)
     }
    
     Function Test-ItemByPath
     {
         Param(
             [Parameter(Mandatory=$true)]
             [object]$RS,
    
             [Parameter(Mandatory=$true)]
             [string]$Path
         )
         Return ($Rs.ListChildren("/",$true) | ?{$_.Path -eq $Path}) -ne $null
     }
    
     Function Update-DataSource
     {
         Param(
             [Parameter(Mandatory=$true)]
             [object]$RS,
    
             [Parameter(Mandatory=$true)]
             [string]$SharedDataSourcePath,
    
             [Parameter(Mandatory=$true)]
             [string]$ReportFolderPath
         )
         $RS.ListChildren($ReportFolderPath,$false) |?{$_.TypeName -eq "Report"} | %{
               $referencedDataSourceName = (@($rs.GetItemReferences($_.Path, "DataSource")))[0].Name
                # Change the datasource for the report to $SharedDataSourcePath
                # Note that we can access the types such as DataSource with the prefix 
                # "SSRS" only because we specified that as our namespace when we 
                # created the proxy with New-WebServiceProxy.
                $dataSource = New-Object SSRS.DataSource
                $dataSource.Name = $referencedDataSourceName      
                # Name as used when designing the Report
                $dataSource.Item = New-Object SSRS.DataSourceReference
                $dataSource.Item.Reference = $SharedDataSourcePath # Path to the shared data source as it is deployed here.
                $rs.SetItemDataSources($_.Path, [SSRS.DataSource[]]$dataSource)
        }
     }
    
    
    $Rs = Get-ReportServerInstance -ReportUrl $ReportServerUrL  -Namespace "SSRS"
    if((Test-ItemByPath -RS $RS -Path $ReportFolderPath) -eq $false)
    {
        Create-ReportFolder -RS $RS -FolderName $ReportFolderPath.remove(0,1)
    }
    Resolve-Path $LocalRDLFilePath
    Get-ChildItem -Path $LocalRDLFilePath | ?{$_.Name -like "*.rdl"} | %{Upload-ReportToRemoteServer -RS $RS -RDLFilePath $_.FullName -ReportServerPath $ReportFolderPath }
    Update-DataSource -RS $RS -SharedDataSourcePath $SharedDataSourcePath -ReportFolderPath $ReportFolderPath
    
    
    
    
  • 相关阅读:
    面试准备——springboot相关
    面试准备——mybatis相关
    面试准备——struts2和springmvc的区别
    面试准备——Struts2相关问题
    面试准备——springmvc面试题
    面试准备——spring面试题
    面试准备——数据库优化问题
    面试准备——JVM相关
    面试准备——数据结构
    面试准备——多线程
  • 原文地址:https://www.cnblogs.com/kongshu-612/p/6509960.html
Copyright © 2011-2022 走看看