【问题标题】:Deploying SSRS RDL files from VB.Net - Issue with shared datasources从 VB.Net 部署 SSRS RDL 文件 - 共享数据源问题
【发布时间】:2023-03-13 21:09:02
【问题描述】:

我目前正在开发一个实用程序来帮助自动化我们的报告部署过程。多个文件夹中的多个文件,发送到多个服务器。

我正在使用 reportservice2010.asmx Web 服务,并且我正在将我的文件部署到服务器 - 所以大部分都在那里。

我的问题是我有共享数据集和共享数据源,它们部署到单独的文件夹中,与报告文件夹分开。部署发生时,Web 服务在本地而不是在数据源文件夹中查找数据源,并给出如下错误:

The dataset ‘CostReduction’ refers to the shared data source ‘CostReduction’, which is not
published on the report server.  The shared data source ‘CostReduction’ must be published
before this report can run.

数据源/数据集已部署,报告功能正常,但我需要隐藏这些错误消息,因为它们可能隐藏其他实际错误。

我可以硬编码一个查找来检查数据源/集是否存在并通过它手动过滤它们,但这似乎非常低效。有什么方法可以告诉网络服务在哪里查找这些文件或其他人使用过的其他方法?

我不打算更改报告,因此从

读取数据源
/DataSources/DataSourceName 

因为有很多报告,而我们现有的项目不是这样配置的。

非常感谢。

【问题讨论】:

    标签: vb.net web-services reporting-services datasource ssrs-2008-r2


    【解决方案1】:

    我知道您使用的是 VB,但如果您使用网络上的一个翻译器将其从 C# 转换为 VB,也许这会给您一个线索。

    希望这会给你一个正确的方向。

    当特定文件夹(此处称为“父文件夹”)中的所有报表都使用相同的共享数据源时,我使用它将所有报表设置为相同的共享数据源(在本例中为“/数据源/Shared_New")

    using GetPropertiesSample.ReportService2010;
    using System.Diagnostics;
    using System.Collections.Generic;   //<== required for LISTS
    using System.Reflection;
    
    namespace GetPropertiesSample
    {
    class Program
    {
    static void Main(string[] args)
    {
        GetListOfObjectsInGivenFolder_and_ResetTheReportDataSource("0_Contacts");  //<=== This is the parent folder
    }
    
    private static void GetListOfObjectsInGivenFolder_and_ResetTheReportDataSource(string sParentFolder)
    {
        // Create a Web service proxy object and set credentials
        ReportingService2010 rs = new ReportingService2010();
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
        CatalogItem[] reportList = rs.ListChildren(@"/" + sParentFolder, true);
    
        int iCounter = 0;
    
        foreach (CatalogItem item in reportList)
        {
            iCounter += 1;
            Debug.Print(iCounter.ToString() + "]#########################################");
    
            if (item.TypeName == "Report")
            {
                Debug.Print("Report: " + item.Name);
                ResetTheDataSource_for_a_Report(item.Path, "/DataSources/Shared_New");   //<=== This is the DataSource that I want them to use
            }
        }
    }
    
    private static void ResetTheDataSource_for_a_Report(string sPathAndFileNameOfTheReport, string sPathAndFileNameForDataSource)
    {
        //from: http://stackoverflow.com/questions/13144604/ssrs-reportingservice2010-change-embedded-datasource-to-shared-datasource
    
        ReportingService2010 rs = new ReportingService2010();
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
        string reportPathAndName = sPathAndFileNameOfTheReport;
        //example of sPathAndFileNameOfTheReport  "/0_Contacts/207_Practices_County_CareManager_Role_ContactInfo";
    
        List<ReportService2010.ItemReference> itemRefs = new List<ReportService2010.ItemReference>();
        ReportService2010.DataSource[] itemDataSources = rs.GetItemDataSources(reportPathAndName);
    
        foreach (ReportService2010.DataSource itemDataSource in itemDataSources)
        {
            ReportService2010.ItemReference itemRef = new ReportService2010.ItemReference();
            itemRef.Name = itemDataSource.Name;
    
            //example of DataSource i.e. 'itemRef.Reference':    "/DataSources/SharedDataSource_DB2_CRM";
            itemRef.Reference = sPathAndFileNameForDataSource;
    
            itemRefs.Add(itemRef);
        }
    
        rs.SetItemReferences(reportPathAndName, itemRefs.ToArray());
    }
    

    }

    要调用它,我在“主要”方法中使用它:

     GetListOfObjectsInGivenFolder_and_ResetTheReportDataSource("0_Contacts");
    

    在这种情况下,“0_Contacts”是父文件夹,它本身位于根目录中,其中包含我想要将其数据源重置为新共享数据源的所有报告。然后该方法调用另一个方法“ResetTheDataSource_for_a_Report”,它实际上设置了报表的数据源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多