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
    
    
    
    
  • 相关阅读:
    用单循环链表实现约瑟夫问题。
    迅雷2014校园招聘笔试题
    JSP:JAVA Bean在JSP中的运用
    大学生学业指导类书目
    IOS详解TableView——对话聊天布局的实现
    jQuery EasyUI API 中文文档
    在Centos 5.4上安装Mysql5.5.10 (整理以前的工作文档)
    Centos环境下部署游戏服务器-SVN
    原本好好的程序,怎么电脑重启后就打不开了?
    UVA 10911 Forming Quiz Teams(dp + 集合最优配对问题)
  • 原文地址:https://www.cnblogs.com/kongshu-612/p/6509960.html
Copyright © 2011-2022 走看看