ReportingService2005.CancelBatch Método

Definición

Cancela el lote que fue iniciado por una llamada al método CreateBatch().

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

Ejemplos

Para compilar este ejemplo de código, debe hacer referencia al lenguaje de descripción del servicio web (WSDL) Reporting Services e importar determinados espacios de nombres. Para obtener más información, vea Compilar y ejecutar ejemplos de código. En el ejemplo de código siguiente se cancela un lote, se intenta ejecutarlo y se muestran los detalles del error:

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

Comentarios

En la siguiente tabla se muestra la información de encabezado y de permisos de esta operación.

Encabezados SOAP (In) BatchHeaderValue

(Out) ServerInfoHeaderValue
Permisos necesarios El usuario debe ser un administrador de base de datos o el configurado como la cuenta de ejecución desatendida. Para obtener más información, vea Cuenta de ejecución (modo nativo de SSRS) .

Debe especificar el identificador del lote que desea cancelar antes de llamar al CancelBatch método . Para ello, establezca la BatchHeaderValue propiedad del servicio web del servidor de informes en un valor igual al identificador de lote que se generó cuando se creó el lote.

Cuando se llama al CancelBatch método , las llamadas de método asociadas al identificador de lote ya no se pueden ejecutar. Cualquier intento de ejecutar un lote con un identificador de lote cancelado da como resultado una excepción SOAP con el código rsBatchNotFoundde error .

Se aplica a

Consulte también