Removing reports / report folder by SSRS (SQL SERVER REPORTING SERVICE)

Goal :

Remove the report folder from backstage.

Removing reports / report folder by SSRS (SQL SERVER REPORTING SERVICE)

Implement Steps:

1.       Create a C# console application project.

2.       Add one web reference into the project. [VS2010 : http://localhost:80/ReportServer/ReportService2010.asmx]

Removing reports / report folder by SSRS (SQL SERVER REPORTING SERVICE)

 

3.       Open the “Web References/WebServicelocalhost” folder from the project location directory and find out the “Reference.cs” file in there.

4.       Create a new console project then add the “References. cs” as a class file,   add the web reference project as a reference.

Removing reports / report folder by SSRS (SQL SERVER REPORTING SERVICE)

 

5.       Open the web reference project and change the internal keyword to public in the file of  \TempWebRef\TempWebRef\Properties “Settings.Designer.cs”.

public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {

6.       Open the “Reference.cs” file and change the namespace to a new definitely one.

 //WebServicelocalhost

namespace TempWebRef.LocalReportServiceRemoveGenReport { ...

7.       Create a static private method in the “Reference.cs “ class ,it is will be better write around the “DeleteItem” default method.

 

Removing reports / report folder by SSRS (SQL SERVER REPORTING SERVICE)Removing reports / report folder by SSRS (SQL SERVER REPORTING SERVICE)代码

8.    public void DeleteItem(string Item) {
9.                this.Invoke("DeleteItem"new object[] {
10.                            Item});
11.            }
12.    
13.            public static string DeleteReport(string _reportPath, string _reportServerURL)
14.            {
15.                string strReturn;
16.                strReturn = "success";
17.                try
18.                {
19.                    ReportingService2005 rs = new ReportingService2005();  // Declare one reference object .
20.                    _reportPath = "/GenevaReports/13Report"// Naming the report path you want to remove. And if you want to remove a folder , only change the path as the main folder name like ‘/GenevaReports’
21.                    _reportServerURL = "http://" + _reportServerURL + "/reportserver/ReportService2005.asmx"// Create the report server URL string which the reports belong to.
22.    
23.                    rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
24.                    rs.Url = _reportServerURL;
25.    
26.    
27.                    rs.DeleteItem(_reportPath); // Call the execution.
28.    
29.                    return strReturn;
30.                }
31.                catch (Exception xe)
32.                {
33.    
34.                    strReturn = xe.Message + _reportServerURL;
35.                    return strReturn;
36.                }
37.    

 

8.  Switch to another project and call the report deleting method like below.

string stemp = TempWebRef.LocalReportServiceRemoveGenReport.ReportingService2005.DeleteReport("TestReport","Server3");

 

 

 

 

转载于:https://www.cnblogs.com/zencorn/archive/2010/12/15/1906850.html