ReportingService2005.CancelBatch 方法

定義

取消由呼叫 CreateBatch() 方法所起始的批次。

public:
 void CancelBatch();
public void CancelBatch ();
member this.CancelBatch : unit -> unit
Public Sub CancelBatch ()

範例

若要編譯這個程式碼範例,您必須參考 Reporting Services 的 Web 服務描述語言 (WSDL) 並匯入某些命名空間。 如需詳細資訊,請參閱 編譯和執行程式碼範例。 下列程式碼範例會取消批次、嘗試執行它,並顯示錯誤詳細資料:

Imports System  
Imports System.Web.Services.Protocols  

Class Sample  
   Public Shared Sub Main()  
      Dim rs As New ReportingService2005()  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials  

      Dim bh As New BatchHeader()  
      bh.BatchID = rs.CreateBatch()  
      rs.BatchHeaderValue = bh  
      rs.CreateFolder("New Folder1", "/", Nothing)  
      rs.CreateFolder("New Folder2", "/", Nothing)  
      rs.CreateFolder("New Folder3", "/", Nothing)  

      Console.WriteLine("Cancelling current batch operation.")  

      ' Cancel the current batch.  
      Try  
         rs.CancelBatch()  

      Catch e As SoapException  
         Console.WriteLine(e.Detail.InnerXml.ToString())  
      End Try  

      Try  
         ' Generates an error because the batch has already been cancelled.  
         rs.ExecuteBatch()  
         Console.WriteLine("The batch executed successfully.")  

      Catch e As SoapException  
         Console.WriteLine(e.Detail.InnerXml.ToString())  
         Console.WriteLine("The batch was not executed.")  

      Finally  
         rs.BatchHeaderValue = Nothing  
      End Try  
   End Sub 'Main  
End Class 'Sample  
using System;  
using System.Web.Services.Protocols;  

class Sample  
{  
   public static void Main()  
   {  
      ReportingService rs = new ReportingService2005();  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;  

      BatchHeader bh = new BatchHeader();  
      bh.BatchID = rs.CreateBatch();  
      rs.BatchHeaderValue = bh;  
      rs.CreateFolder("New Folder1", "/", null);  
      rs.CreateFolder("New Folder2", "/", null);  
      rs.CreateFolder("New Folder3", "/", null);  

      Console.WriteLine("Cancelling current batch operation.");  

      // Cancel the current batch.  
      try  
      {  
         rs.CancelBatch();  
      }  

      catch (SoapException e)  
      {  
         Console.WriteLine(e.Detail.InnerXml.ToString());  
      }  

      try  
      {  
         // Generates an error because the batch has already been cancelled.  
         rs.ExecuteBatch();  
         Console.WriteLine("The batch executed successfully.");  
      }  

      catch (SoapException e)  
      {  
         Console.WriteLine(e.Detail.InnerXml.ToString());  
         Console.WriteLine("The batch was not executed.");  
      }  

      finally  
      {  
         rs.BatchHeaderValue = null;  
      }  
   }  
}  

備註

下表顯示標頭以及有關這項作業的權限資訊。

SOAP 標頭 (In) BatchHeaderValue

(Out) ServerInfoHeaderValue
必要權限 使用者必須是資料庫管理員,或是設定為自動執行帳戶的使用者。 如需詳細資訊,請參閱 (SSRS 原生模式) 的執行帳戶

您必須在呼叫方法之前,指定要取消之批次的識別碼 CancelBatch 。 您可以將 BatchHeaderValue 報表伺服器 Web 服務的屬性設為等於建立批次時所產生之批次識別碼的值,來執行這項操作。

CancelBatch呼叫方法時,不會再執行與批次識別碼相關聯的任何方法呼叫。 嘗試以取消的批次識別碼執行批次時,會產生包含錯誤碼的 SOAP 例外狀況 rsBatchNotFound

適用於

另請參閱