ReportingService2005.CancelBatch Metodo

Definizione

Annulla il batch avviato da una chiamata al metodo CreateBatch().

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

Esempio

Per compilare questo esempio di codice, è necessario fare riferimento all'Reporting Services WSDL (Web Service Description Language) e importare determinati spazi dei nomi. Per ulteriori informazioni, vedere compilazione ed esecuzione di esempi di codice. L'esempio di codice seguente annulla un batch, tenta di eseguirlo e Visualizza i dettagli dell'errore:

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;  
      }  
   }  
}  

Commenti

Nella tabella seguente vengono mostrate le informazioni sull'intestazione e sulle autorizzazioni relative a questa operazione.

Intestazioni SOAP (In) BatchHeaderValue

(Out) ServerInfoHeaderValue
Autorizzazioni necessarie L'utente deve essere un amministratore di database o quello configurato come account di esecuzione automatica. Per ulteriori informazioni, vedere account di esecuzione (modalità nativa SSRS).

È necessario specificare l'ID del batch che si desidera annullare prima di chiamare il CancelBatch metodo. Questa operazione può essere eseguita impostando la BatchHeaderValue proprietà del servizio Web ReportServer su un valore uguale all'ID batch generato al momento della creazione del batch.

Quando CancelBatch viene chiamato il metodo, non è più possibile eseguire le chiamate al metodo associate all'ID batch. Qualsiasi tentativo di eseguire un batch con un ID batch annullato genera un'eccezione SOAP con il codice di errore rsBatchNotFound .

Si applica a

Vedi anche