SSRS CreateFolder C#命令中的错误?

时间:2017-10-20 13:27:51

标签: c# reporting-services

我认为我在Reportingservices2010 SOAP API中遇到了CreateFolder命令中的错误

测试场景是我尝试在同一个Parent文件夹中创建一个文件夹(名为 Sales Dashboard )(例如销售)作为报告命名为销售仪表板

使用" AlreadyExists"完成命令。文件夹尚不存在时出现异常。看起来该方法没有检查目录项类型。

这是我的代码:

 public static void createFolders(string targetURL, string folderName, string parentPath, string description, string visible)
    {
        //Build Authentication
        ReportingService2010 rs = new ReportingService2010();
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
        rs.Url = targetURL;

        //Declare properties
        Property descriptionProp = new Property();
        Property visibleProp = new Property();
        Property[] props = new Property[2];

        descriptionProp.Name = "Description";
        descriptionProp.Value = description;
        visibleProp.Name = "Visible";
        visibleProp.Value = visible;
        props[0] = descriptionProp;
        props[1] = visibleProp;

        try
        {
            rs.CreateFolder(folderName, parentPath, props);
        }
        catch(Exception ex)
        {
            if(ex.Message.Contains("AlreadyExists"))
            {
                //do nothing?
            }
            else
            {
                throw;
            }
        }
    }

我想知道我是否可以提供修复,但C#SSRS没有GitHub回购。对解决方法的任何想法?

1 个答案:

答案 0 :(得分:1)

API返回正确的错误,因为这是对Reporting Services的一般限制:同一文件夹中的项目必须具有唯一的名称(无论项目类型如何)。