OrchestrationBinding (BizTalk Server 範例)
協調流程繫結範例會示範使用 Microsoft.BizTalk.ExplorerOM 系統管理物件來設定及管理協調流程。
必要條件
此範例需要執行位於Samples Path> \Orchestrations\HelloWorld 目錄中的 setup.bat < 來部署 HelloWorld 範例。
您必須擁有BizTalk Server系統管理許可權,才能使用此範例中的系統管理物件。
Windows PowerShell 指令碼範例需要 Windows PowerShell 執行原則來允許指令碼執行。 如需詳細資訊,請參閱 檢查執行原則。
此範例的用途
本範例示範如何使用 Microsoft.BizTalk.ExplorerOM 命名空間中的系統管理物件來管理協調流程。 此範例會使用 ExplorerOM 物件示範下列作業:
使用Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer 類別連接到 BizTalk 管理資料庫。
變更 Microsoft.BizTalk.ExplorerOM.BtsOrchestration 類別的 狀態 屬性以停止和啟動協調流程。
變更 Microsoft.BizTalk.ExplorerOM.BtsOrchestration 類別的 狀態 屬性,登錄及取消登錄協調流程。
使用 Microsoft.BizTalk.ExplorerOM.BtsOrchestration 類別上的 連接埠 集合,繫結及解除繫結協調流程。
此範例的位置
這個範例位於下列 SDK 位置:
<範例路徑>\管理員\ExplorerOM\OrchestrationBinding
下表顯示此範例中的檔案,並描述其用途。
檔案 | Description |
---|---|
OrchestrationBinding.cs | 此範例中示範之作業的 Visual C# 原始程式檔。 |
OrchestrationBinding.sln、OrchestrationBinding.csproj、OrchestrationBinding.suo | 此範例的方案和專案檔。 |
建置此範例
請確定您已完成建置和初始化 HelloWorld 範例的步驟。 這些步驟是在HelloWorld (BizTalk Server 範例) 中提供。
在 Visual Studio 中,開啟 Solution 檔案 OrchestrationBinding.sln。
在 [建置] 功能表上,按一下 [建置方案]。
執行這個範例
開啟命令視窗並巡覽至下列資料夾:
<範例路徑>\管理員\ExplorerOM\OrchestrationBinding\bin\Debug
執行 OrchestrationBinding.exe 檔案並遵循範例所提供的指示。
Windows PowerShell 指令碼範例
下列 Windows PowerShell 指令碼可以用來示範 ExplorerOM 類別的相同功能。
Function RefreshPrompt($oldstatus,$newstatus)
{
Write-Host Orchestration Status should now be `"$oldstatus`"
Write-Host Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
if ($newstatus)
{
Write-Host Pressing `<Enter`> now will $newstatus the orchestration using ExplorerOM`.`.`.
Read-Host
Write-Host "=== Please wait, attempting to $newstatus the orchestration... ===`r`n"
}
else
{
write-host `r`n
}
}
#===================#
#=== Main Script ===#
#===================#
#=== Make sure the ExplorerOM assembly is loaded ===#
[void] [System.reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
#=== Connect to the BizTalk Management database ===#
$Catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$Catalog.ConnectionString = "SERVER=.;DATABASE=BizTalkMgmtDb;Integrated Security=SSPI"
#=== This sample expects the HelloWorld sample orchestration to be using the ===#
#=== default name "Biztalk Application 1" ===#
$HelloWorldApp = $Catalog.Applications["Biztalk Application 1"]
$orch = $HelloWorldApp.orchestrations["Microsoft.Samples.BizTalk.HelloWorld.HelloSchedule"]
#==================================================================#
#=== Register a trap handler to discard changes on exceptions ===#
#=== Execution will continue in the event we need to re-enlist, ===#
#=== re-bind, or restart the orchestration. ===#
#==================================================================#
$ErrorActionPreference="silentlycontinue"
trap { "Exception encountered:`r`n"; $_; "`r`nDiscarding Changes and continuing execution...`r`n";$Catalog.DiscardChanges();}
write-host `r`nMake sure the "HelloWorld" sample application is deployed and running.
write-host By default it will be listed in the BizTalk Server Administration Console
write-host with the application name: `"BizTalk.Application.1`"`r`n
#==========================================================#
#=== Change orchestration state from Started to stopped ===#
#==========================================================#
RefreshPrompt Started stop
$orch.Status = [Microsoft.BizTalk.ExplorerOM.OrchestrationStatus] "Enlisted"
$Catalog.SaveChanges()
#=============================================================#
#=== Change orchestration state from stopped to unenlisted ===#
#=============================================================#
RefreshPrompt Stopped unenlist
$orch.Status = [Microsoft.BizTalk.ExplorerOM.OrchestrationStatus] "Unenlisted"
$Catalog.SaveChanges()
#=============================================================#
#=== Change orchestration state from unenlisted to unbound ===#
#=============================================================#
RefreshPrompt Unenlisted unbind
$orch.Ports["SendInvoicePort"].SendPort = $null
$orch.Ports["ReceivePOPort"].ReceivePort = $null;
$orch.Host = $null
$Catalog.SaveChanges()
#==================================================================#
#=== Change orchestration state from unbound back to unenlisted ===#
#==================================================================#
RefreshPrompt Unenlisted`(Unbound`) re-bind
$orch.Ports["SendInvoicePort"].SendPort = $Catalog.SendPorts["HelloWorldSendPort"]
$orch.Ports["ReceivePOPort"].ReceivePort = $Catalog.ReceivePorts["HelloWorldReceivePort"]
$orch.Host = $Catalog.Hosts["BizTalkServerApplication"]
$Catalog.SaveChanges()
#==================================================================#
#=== Change orchestration state from unenlisted back to stopped ===#
#==================================================================#
RefreshPrompt Unenlisted enlist
$orch.Status = [Microsoft.BizTalk.ExplorerOM.OrchestrationStatus] "Enlisted"
$Catalog.SaveChanges()
#===============================================================#
#=== Change orchestration state from stopped back to started ===#
#===============================================================#
RefreshPrompt Stopped restart
$orch.Status = [Microsoft.BizTalk.ExplorerOM.OrchestrationStatus] "Started"
$Catalog.SaveChanges()
RefreshPrompt Started
以下是執行 Windows PowerShell 指令碼的輸出範例。
PS C:\> .\OrchestrationBind.ps1
Make sure the HelloWorld sample application is deployed and running.
By default it will be listed in the BizTalk Server Administration Console
with the application name: "BizTalk.Application.1"
Orchestration Status should now be "Started"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will stop the orchestration using ExplorerOM...
=== Please wait, attempting to stop the orchestration... ===
Orchestration Status should now be "Stopped"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will unenlist the orchestration using ExplorerOM...
=== Please wait, attempting to unenlist the orchestration... ===
Orchestration Status should now be "Unenlisted"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will unbind the orchestration using ExplorerOM...
=== Please wait, attempting to unbind the orchestration... ===
Orchestration Status should now be "Unenlisted(Unbound)"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will re-bind the orchestration using ExplorerOM...
=== Please wait, attempting to re-bind the orchestration... ===
Orchestration Status should now be "Unenlisted"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will enlist the orchestration using ExplorerOM...
=== Please wait, attempting to enlist the orchestration... ===
Orchestration Status should now be "Stopped"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
Pressing <Enter> now will restart the orchestration using ExplorerOM...
=== Please wait, attempting to restart the orchestration... ===
Orchestration Status should now be "Started"
Press F5 in the Orchestrations view of BizTalk Server Administration Console to refresh and verify
另請參閱
管理員-ExplorerOM (BizTalk Server 範例資料夾) HelloWorld (BizTalk Server 範例)