Idioma

ReportingService2005.CancelBatch Método

Definição

Cancela o lote iniciado por uma chamada ao CreateBatch() método.

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

Exemplos

Para compilar esse exemplo de código, você deve consultar a Linguagem de Descrição de Web Service (WSDL) do Reporting Services e importar certos namespaces. Para mais informações, veja Exemplos de Código Compilando e Executando. O exemplo de código a seguir cancela um lote, tenta executá-lo e exibe detalhes de erro:

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

Comentários

A tabela abaixo mostra informações sobre cabeçalhos e permissões sobre esta operação.

Cabeçalhos SOAP (Em) BatchHeaderValue

(Fora) ServerInfoHeaderValue
Permissões necessárias O usuário deve ser um administrador de banco de dados ou aquele configurado como conta de execução não atendida. Para mais informações, veja Conta de Execução (Modo Nativo SSRS).

Você deve especificar o ID do lote que deseja cancelar antes de chamar o CancelBatch método. Você pode fazer isso definindo a BatchHeaderValue propriedade do serviço Web do Servidor de Relatórios para um valor igual ao ID do lote gerado quando o lote foi criado.

Quando o CancelBatch método é chamado, quaisquer chamadas de método associadas ao ID do lote não podem mais ser executadas. Qualquer tentativa de executar um lote com um ID de lote cancelado resulta em uma exceção SOAP com o código rsBatchNotFoundde erro .

Aplica-se a

Confira também