ReportingService2005.CancelBatch 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
取消由调用 CreateBatch() 方法发起的批次。
public:
void CancelBatch();
public void CancelBatch();
member this.CancelBatch : unit -> unit
Public Sub CancelBatch ()
示例
要编译此代码示例,您必须引用 Reporting Services Web Service Description Language(WSDL)并导入特定的命名空间。 更多信息请参见编 译与运行代码示例。 以下代码示例取消批次,尝试执行,并显示错误细节:
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;
}
}
}
注解
下表显示了该操作的头部和权限信息。
| SOAP 头部 | (在) BatchHeaderValue (出局) ServerInfoHeaderValue |
| 所需的权限 | 用户必须是数据库管理员,或配置为无人值守执行账户的管理员。 更多信息请参见执行账户(SSRS原生模式)。 |
你必须在调用 CancelBatch 该方法前指定你想取消的批次的ID。 你可以通过将报告服务器 Web 服务的属性设置为 BatchHeaderValue 等于创建批处理时生成的批次 ID 来实现这一点。
当 CancelBatch 该方法被调用时,任何与批处理ID关联的方法调用都无法再执行。 任何尝试执行带有取消批次ID的批次都会导致带有错误代码 rsBatchNotFound的SOAP异常。