2017-10-20 112 views
0

我想我的Reportingservices2010 SOAP APISSRS CreateFolder C#命令中的錯誤?

測試場景是我試圖創建一個文件夾中遇到的錯誤在CreateFolder命令(名爲銷售儀表)在同一父文件夾(可以讓說銷售)作爲報告也被稱爲銷售儀表板

當文件夾尚不存在時,命令用「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; 
      } 
     } 
    } 

我想看看我是否能有助於修復,但沒有GitHub庫爲C#SSRS的東西。任何想法都是解決方法?

+0

您是否使用報告管理器創建文件夾? – newGuy

+0

@newGuy不,我正在用上面的c#代碼創建文件夾。 gui不受影響。這看起來像RS'CreateFolder'方法中的錯誤 – CPorteous

+0

這不是一個錯誤。這很正常。那些*不是*磁盤文件夾,它們是* URL *。你*不能*具有相同的URL引用不同類型的資源。 URL'Sales%20Dashboard'不能同時引用「文件夾」*和*報告。只*不*使用相同的名字 –

回答

1

API正在返回正確的錯誤,因爲這是Reporting Services的一般限制:同一文件夾中的項目必須具有唯一的名稱(不管項目類型)。

+0

感謝Riccardo,我只是測試了這一點,我也無法手動創建這些。我感覺這是可能的。謝謝(你的)信息。 – CPorteous