摘要
Host Integration Server 包含 Visual Studio Designer,可建立 .hidx 檔案,供 HIS 執行時的各個元件與後端系統通訊。 透過 Studio Designer 建立 .hidx 檔案完全是手動操作。 然而,透過 PowerShell 自動產生 .hidx 檔案,可以在專案整個過程中節省時間。 累積更新 2 允許透過 PowerShell 建立與修改 .hidx 檔案。
請注意,必須使用 32 位元版本的 PowerShell,因為 32 位元 Visual Studio Designer 的元件會被呼叫。 若使用 64 位元版本的 PowerShell,會記錄類似以下錯誤訊息:
注意
'Microsoft.HostIntegration.Importer.PowerShell.NewHisWipHidxFile' 的類型初始化器拋出了例外。
其他資訊
此更新包含於 2016 年主機整合伺服器的 累積更新 2 中。
以下是可在 Visual Studio 中建立的主機整合專案類型:
- BizTalk 管線轉換
- 主機應用程式
- 主機檔案
- 訊息佇列
安裝完這個更新彙整後,你可以透過 PowerShell 為每種專案類型建立 .hidx 檔案。 我們建議你在嘗試使用 PowerShell 建立檔案之前,先有一些透過 Visual Studio Designer 建立 .hidx 檔案的經驗。
要使用 PowerShell,請開啟 32 位元Windows PowerShell ISE (x86) ,然後在檢視選單中選擇「顯示指令外掛」。 在 指令 標籤中,選擇 Microsoft.HostIntegration.Importer.PowerShell 模組,以顯示可用的 PowerShell 指令清單。
範例
要手動執行以下任務,請依照以下步驟進行:
- 建立一個進行中的 hidx 物件。
- 新增一個名為 GetAccounts 的方法。
- 新增一個 30 字元字串的輸入參數,名為 CustomerName。
- 新增一個名為 AccountNum 的 6 字元輸入字串參數。
- 新增一個輸出十進位參數,名為 Balance ,即 PIC S9 (7) V99。
- 將進行中的 hidx 物件存檔。 hidx 檔案儲存在 C:\Lab。 請注意,資料夾必須存在才能建立$WIPhidx物件。
要自動化這些任務,請在 PowerShell 中執行以下腳本:
$WIPhidx = New-HisWipHidxFile -ElmUserData -Name MyNamespace -Interface IMyInterface -
Description "My Description" -File C:\Lab\WIPSample.hidx
$WIPMethod = Add-HisHidxElement -InputObject $WIPhidx -Method -Name GetAccounts
$NameParameter = $WIPMethod | Add-HisHidxParameter -Name CustomerName -Atomic
$NameParameter.Direction = "In"
$NameParameter.DataType = "String"
$NameParameter.ConversionInformation.Size = 30
$AccountParameter = $WIPMethod | Add-HisHidxParameter -Name AccountNum -Atomic
$AccountParameter.Direction = "In"
$AccountParameter.DataType = "String"
$AccountParameter.ConversionInformation.Size = 6
$BalanceParameter = $WIPMethod | Add-HisHidxParameter -Name Balance -Atomic
$BalanceParameter.Direction = "Out"
$BalanceParameter.DataType = "Decimal"
$BalanceParameter.ConversionInformation.HostDataType = "PIC S9(n)V9(n) COMP-3"
$BalanceParameter.ConversionInformation.Precision = 7
$BalanceParameter.ConversionInformation.Scale = 2
$WIPhidx.Save()
註GitHub 上有更多範例 PowerShell 腳本。
參考資料
了解 Microsoft 用來描述軟體更新的 術語 。