ReportingService2005.CancelBatch Méthode

Définition

Annule le lot initié par un appel à la méthode CreateBatch().

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

Exemples

Pour compiler cet exemple de code, vous devez référencer le langage WSDL (Web Service Description Language) Reporting Services et importer certains espaces de noms. Pour plus d’informations, consultez Compilation et exécution d’exemples de code. L’exemple de code suivant annule un lot, tente de l’exécuter et affiche les détails de l’erreur :

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

Remarques

Le tableau suivant présente les informations relatives aux en-têtes et aux autorisations sur cette opération.

En-têtes SOAP (In) BatchHeaderValue

(Out) ServerInfoHeaderValue
Autorisations requises L’utilisateur doit être un administrateur de base de données ou celui configuré comme compte d’exécution sans assistance. Pour plus d’informations, consultez Compte d’exécution (mode natif SSRS).

Vous devez spécifier l’ID du lot que vous souhaitez annuler avant d’appeler la CancelBatch méthode . Pour ce faire, définissez la BatchHeaderValue propriété du service Web Report Server sur une valeur égale à l’ID de lot qui a été généré lors de la création du lot.

Lorsque la CancelBatch méthode est appelée, tous les appels de méthode associés à l’ID de lot ne peuvent plus être exécutés. Toute tentative d’exécution d’un lot avec un ID de lot annulé entraîne une exception SOAP avec le code rsBatchNotFoundd’erreur .

S’applique à

Voir aussi