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 原生模式)。 |
你必須先指定你想取消的批次 ID,才能呼叫該 CancelBatch 方法。 你可以將報表伺服器網路服務的屬性設定 BatchHeaderValue 為與建立批次時產生的批次 ID 相等的值來達成。
當 CancelBatch 該方法被呼叫時,任何與批次 ID 相關的方法呼叫將無法再執行。 任何嘗試執行批次時,使用已取消的批次 ID 都會觸發帶有錯誤代碼 rsBatchNotFound的 SOAP 例外。