2012-03-22 83 views
8

我們希望將我們的SSRS 2008 R2項目整合到我們的自動構建過程中。目前TeamCity每週三次構建並部署我們的C#代碼庫。我們希望將SSRS報告項目添加到該項目中。 RDL文件當前位於Subversion源代碼控制庫中。使用TeamCity部署SSRS 2008 R2報告項目

回答

4

您可以使用Report Server Web Service來實現此目的。它有CreateItem上傳報告給Reporting Service的方法。

若要在上傳您需要爲您的ReportService2010.asmx端點創建proxy class然後用RDL文件創建C#項目是這樣的:

ReportingService2010 reportingService = new ReportingService2010(); 
reportingService.Url = url + "/ReportService2010.asmx"; 
reportingService.Credentials = new System.Net.NetworkCredential(username, password, domain); 
Microsoft.SqlServer.ReportingServices2010.Warning[] warnings = null;    

using (FileStream reportStream = new FileStream("c:\\report.rdl", 
     FileMode.Open, FileAccess.Read)) 
{ 
    using (MemoryStream ms = new MemoryStream()) 
    { 
     reportStream.CopyTo(ms); 
     CatalogItem report = reportingService.CreateCatalogItem(
      "Report", 
      "Report1", 
      "/", 
      true, 
      ms.ToArray(), 
      null, 
      out warnings); 
    } 
}