SQL Server Reporting Service - 一步部署 TFS 项目报表

上次介绍了 SQL Server Reporting Service 命令行部署报表的基本内容, 利用这些知识我们可以轻松的部署报表, 然而在 TFS 中, 每个项目都有它对应的报表, 这些报表如果要一个个的更新也是件痛苦的事情, 现在我也遇到了这个问题, 针对 TFS 开发了两张报表, 但是如何将这些报表应用到所有项目上呢? 结合之前的部署脚本知识, 我们可以使用下面方法实现:

首先建立一个批处理文件ImportWIT.bat, 用来更新某个项目的Work Item定义文件:

 

@ECHO OFF 

CALL "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 

witimport /t %1 /p %2 /f WorkItemDefinitions\Task.xml 
witimport /t %1 /p %2 /f WorkItemDefinitions\Bug.xml 
witimport /t %1 /p %2 /f WorkItemDefinitions\Scenario.xml 

rem /t %1 /p %2 
rem echo Hit any key to continue 
rem PAUSE

在WorkItemDefinitions目录下将所有对应Work Item定义文件放入:

然后建立一个Reports目录, 将所有需要的报表文件放入, 如下图:

然后创建一个脚本文件PublishReports.rss, 内容如下:

 

'============================================================================= 
'  File:      PublishSampleReports.rss 

'  Summary:  Demonstrates a script that can be used with RS.exe to 
'         publish the sample reports that ship with Reporting Services. 

'--------------------------------------------------------------------- 
' This file is part of Microsoft SQL Server Code Samples. 

'  Copyright (C) Microsoft Corporation.  All rights reserved. 

' This source code is intended only as a supplement to Microsoft 
' Development Tools and/or on-line documentation.  See these other 
' materials for detailed information regarding Microsoft code samples. 

' THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
' KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
' IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
' PARTICULAR PURPOSE. 
'============================================================================= 

' 1.0 Documentation 

' Read the following in order to familiarize yourself with the sample script. 

' 1.1 Overview 

' This sample script uses a script file (.rss) and the script environment to run 
' Web service operations on a specified report server. The script creates a folder 
' that you specify as a command-prompt variable using the 杤 switch, and then 
' publishes the sample reports that ship with Reporting Services to a report server. 
' Depending on the location of your sample reports, you may need to modify the 
' value of the filePath variable, which references the path to your sample reports. 

' 1.2 Script Variables 

' Variables that are passed on the command line with the -v switch: 

' (a) parentFolder - corresponds to the folder that the script creates and uses 
'     to contain your published reports 

' 1.3 Sample Command Lines 


' 1.3.1 Use the script to publish the sample reports to an AdventureWorks Sample Reports folder. 

'       rs -i PublishSampleReports.rss -s http://myserver/reportserver 


Dim definition As [Byte]() = Nothing 
Dim warnings As Warning() = Nothing 
Dim parentFolder As String = "" 
Dim parentPath As String = "/" + parentFolder 
Dim filePath As String = "Reports\" 

Public Sub Main()Sub Main() 

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials 

    ''Create the parent folder 
    'Try 
    '    rs.CreateFolder(parentFolder, "/", Nothing) 
    '    Console.WriteLine("Parent folder {0} created successfully", parentFolder) 
    'Catch e As Exception 
    '    Console.WriteLine(e.Message) 
    'End Try 

    ''Create the AdventureWorks shared data source 
    'CreateSampleDataSource("AdventureWorks", "SQL", "data source=(local);initial catalog=AdventureWorks") 
    'CreateSampleDataSource("AdventureWorksDW", "OLEDB-MD", _ 
    '    "data source=localhost;initial catalog=Adventure Works DW") 

    'Publish the sample reports 
    Dim sreader As New System.IO.StreamReader("ProjectInfo.ini") 
    Dim pName As String = "" 
    pName = sreader.ReadLine() 

    PublishReport("SSW Progress Report", pName) 
    PublishReport("SSW Release Plan", pName) 

End Sub 

Public Sub CreateSampleDataSource()Sub CreateSampleDataSource(ByVal name As String, ByVal extension As String, ByVal connectionString As String) 
    'Define the data source definition. 
    Dim definition As New DataSourceDefinition() 
    definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated 
    definition.ConnectString = connectionString 
    definition.Enabled = True 
    definition.EnabledSpecified = True 
    definition.Extension = extension 
    definition.ImpersonateUser = False 
    definition.ImpersonateUserSpecified = True 
    'Use the default prompt string. 
    definition.Prompt = Nothing 
    definition.WindowsCredentials = False 

    Try 
        rs.CreateDataSource(name, parentPath, False, definition, Nothing) 
        Console.WriteLine("Data source {0} created successfully", name) 

    Catch e As Exception 
        Console.WriteLine(e.Message) 
    End Try 

End Sub 

Public Sub PublishReport()Sub PublishReport(ByVal reportName As String, ByVal projectName As String) 
    Try 
        Dim stream As FileStream = File.OpenRead(filePath + reportName + ".rdl") 
        definition = New [Byte](stream.Length) {} 
        stream.Read(definition, 0, CInt(stream.Length)) 
        stream.Close() 

    Catch e As IOException 
        Console.WriteLine(e.Message) 
    End Try 

    Try 

        parentPath = "/" + projectName 

        warnings = rs.CreateReport(reportName, parentPath, False, definition, Nothing) 

        If Not (warnings Is Nothing) Then 
            Dim warning As Warning 
            For Each warning In warnings 
                Console.WriteLine(warning.Message) 
            Next warning 

        Else 
            Console.WriteLine("Report: {0} published successfully with no warnings", reportName) 
        End If 

    Catch e As Exception 
        Console.WriteLine(e.Message) 
    End Try 
End Sub

根据上面的代码可以看到需要一个保存项目名的文件, 最后我们就创建一个ProjectInfo.ini文件, 该文件内容留空即可.

上述文件都船舰好了之后接着创建一个总体的脚本, 命名为Update.bat, 内容为:

@ECHO OFF 

copy nul ProjectInfo.ini /y 
echo %2>>ProjectInfo.ini 

RS -i "PublishReports.rss" -s "http://%1/ReportServer/" 
ImportWIT.bat %1 %2

 

以上就是所有需要创建的内容, 如下:

其中RS.EXE文件可以在SQL Server安装目录中找到.

接下来我们来执行升级某个Team Project的具体操作:

打开CMD, 输入如下命令:

update.bat [TFSServerName] [TeamProjectName]

 

这样就可以将一个Team Project中的工作项和报表更新成脚本中提到的内容.

完整升级包下载: http://files.cnblogs.com/WilsonWu/TFS_2008_SSWTemplateUpdateScript_ver1-1.zip

时间: 2024-07-29 00:14:39

SQL Server Reporting Service - 一步部署 TFS 项目报表的相关文章

SQL Server Reporting Service - 命令行部署脚本介绍

首先应公司老总要求写了英文版: http://www.cnblogs.com/WilsonWu/archive/2009/02/19/1394200.html 英文不好别笑话. 进入正题! 使用 SQL Server Reporting Service 的朋友应该都会遇到与此类似的问题, 尤其是在产品中, 比如我们有若干个报表形成的一个产品, 这些报表是需要用户部署在报表服务器上的才能使用的, 我们可以只给用户 RDL 报表文件和一个文档教程, 让他们自己上传, 自己配置数据源等等, 但是这样也

SQL Server Reporting Service - Deployment by command line

Chinese version: http://www.cnblogs.com/WilsonWu/archive/2009/02/19/1394198.html Some times when we use the SQL Server Reporting Service will get the same problem, if we have a product constituted by some reports, and there is a new release will be p

[收藏]利用SQL Server Reporting Services 从应用程序生成用户友好的报表

server|services|程序 利用 SQL Server Reporting Services 从应用程序生成用户友好的报表 发布日期: 09/03/2004 | 更新日期: 09/03/2004John C. Hancock   http://www.microsoft.com/china/msdn/library/data/sqlserver/SQLServerReportServ.mspx本文讨论:•Reporting•设计和部署报表•使用 Reporting Services 的

微软Sql server analysis service数据挖掘技术

原文:微软Sql server analysis service数据挖掘技术 最新在一个项目中要求用到微软SSAS中的数据挖掘功能,虽然以前做项目的时候也经常用到SSAS中的多维数据集 (就是CUBE),但是始终没有对SSAS中的数据挖掘功能进行过了解.所以借着项目需求这股东风最近了解了下SSAS的数据挖掘,这里先写一篇博客做一个简要的归纳.   说到数据挖掘,我们首先需要知道SSAS数据挖掘能干什么,为什么需要进行数据挖掘.我们先来看一个例子假设我们数据库中现在有一张表叫CustomersBo

SSRS (SQL Server Report Service) 在IE9, IE10下显示不全的解决办法

原文:SSRS (SQL Server Report Service) 在IE9, IE10下显示不全的解决办法 在做项目的过程中遇到SSRS与IE9, IE10不兼容的情况,具体表现为报表页面在IE9 和 IE10下面只显示三分之一,靠左显示,下方有滚动条,右三分之二为空白.查看源代码后发现,上面一个<tr>里只有一个<td>,并colspan=3, 下面报表内容区域的<tr>有三个<td>但前两个是hidden的.最初是想把表格结构调整下,去掉前面hid

基于SQL Server 2008 Service B“.NET研究”roker构建企业级消息系统

1.引言 Microsoft 在SQL Server 2005引入了服务代理 (Service Broker 简称SSB) 为技术支持代理设计模式和面向消息的中间件 (MOM) 的原则.Service Broker在SQL Server 2008上得到完善, SQL Server Service Broker 为消息和队列应用程序提供 SQL Server 数据库引擎本机支持. 这使开发人员可以轻松地创建使用数据库引擎组件在完全不同的数据库之间进行通信的复杂应用程序.开发人员可以使用 Servi

一起谈.NET技术,基于SQL Server 2008 Service Broker构建企业级消息系统

1.引言 Microsoft 在SQL Server 2005引入了服务代理 (Service Broker 简称SSB) 为技术支持代理设计模式和面向消息的中间件 (MOM) 的原则.Service Broker在SQL Server 2008上得到完善, SQL Server Service Broker 为消息和队列应用程序提供 SQL Server 数据库引擎本机支持. 这使开发人员可以轻松地创建使用数据库引擎组件在完全不同的数据库之间进行通信的复杂应用程序.开发人员可以使用 Servi

SQL Server 2008的升级和部署问题

本文是以问答的形式来介绍SQL Server 2008的升级与部署,希望通过本文能给大家一些提高和帮助.     Q:现在我所在的公司正在使用SQL 2005这个版本,那么SQL 从05升级到SQL 08的PDS(数据保护系统)过程中,我们最好选择什么方法呢?那么在升级到SQL 08后,SSIS(生成高性能数据集成解决方案平台)会不会有所提高呢? A:其实从SQL 2000里面的DPS升级到SQL 2005里面的DPS升级是一样的,我们推荐的方法仍然是重写,因为SQL 2005跟SQL 2008

充分利用SQL Server Reporting Services图表

本文适用于Microsoft SQL Server 2005 Reporting Services 简介 本白皮书讲述如何在 Microsoft SQL Server Reporting Services 报表中设计图表.本文分为几部分 并引用特定的报表示例:它们包含在示例项目下载中. 第一部分为数据准备,此部分主要包括有关准备数据的特定信息.技巧和见解.第二部分为图表标签 ,此部分讲述如何应用标签设置来改进图表和控制视觉外观和效果. 示例图表和报表部分讲述如何充分利用 SQL Server R