ReportingService2005.CancelBatch Metodo

Definizione

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

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

Esempio

Per compilare questo esempio di codice, devi fare riferimento al Reporting Services Web Service Description Language (WSDL) e importare determinati namespace. Per maggiori informazioni, vedi Compiling and Conducting Code Examples. Il seguente esempio di codice annulla un lotto, tenta di eseguirlo e mostra i dettagli degli errori:

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

La tabella sottostante mostra informazioni sull'intestazione e sui permessi di questa operazione.

Intestazioni SOAP (Dentro) BatchHeaderValue

(Fuori) ServerInfoHeaderValue
Autorizzazioni necessarie L'utente deve essere un amministratore del database o quello configurato come account di esecuzione non sorvegliato. Per ulteriori informazioni, vedi Account di Esecuzione (SSRS Native Mode).

Devi specificare l'ID del batch che vuoi cancellare prima di chiamare il CancelBatch metodo. Puoi farlo impostando la BatchHeaderValue proprietà del servizio Web del Report Server a un valore pari all'ID del batch generato quando il batch è stato creato.

Quando il CancelBatch metodo viene chiamato, qualsiasi chiamata di metodo associata all'ID batch non può più essere eseguita. Qualsiasi tentativo di eseguire un batch con un ID batch cancellato porta a un'eccezione SOAP con il codice rsBatchNotFounddi errore .

Si applica a

Vedi anche