使用資料驅動型配接器 (DDA)
發行︰ 2016年11月
適用於: Dynamics 365 (online)、Dynamics 365 (on-premises)、Dynamics CRM 2013、Dynamics CRM 2015、Dynamics CRM 2016
資料驅動型配接器 (DDA) 是 託管應用程式工具套件 (HAT) 一般使用的配接器。 這些配接器是一般組件,只處理與 UI 的互動,而不包含商務程序。Unified Service Desk SDK 隨附的 DDA,提供一般目標函數,可讓您託管及存取許多應用程式。 不過,您可能視應用程式類型需要額外的功能。 有不同方式可擴充現有功能,例如建立新 DDA (以及在複合 DDA 中使用它與外部 DDA) 以及擴充現有 DDA。
本節內容
資料驅動型配接器的類型
建立 DDA
擴充現有 DDA
繫結
在自訂應用程式配接器中使用 DDA
資料驅動型配接器的類型
共有四種類型的 DDA:
建立 DDA
繼承 DataDrivenAdapterBase 類別就可以建立新 DDA。
此類別有可多載的建構函式。
擴充現有 DDA
在上一節中,我們看見如何建立 DDA。 不過,如果您的自訂是名義上,您可以使用現有 DDA 和根據需求擴充它。
您可以使用下列類別擴充現有 UII DDA:
WinDataDrivenAdapter:會依據 WinDDA 建立配接器。
WebDataDrivenAdapter:會依據 WebDDA 建立配接器。
JavaDataDrivenAdapter:會依據 JavaDDA 建立配接器。
UIADataDrivenAdapter:會依據 UIADDA 建立配接器。
所有上述的類別從 DataDrivenAdapterBase 類別衍生。
繫結
資料驅動型配接器使用資料,名為繫結,定義其識別託管應用程式 UI 元件的方法。 例如,繫結可以包含文件物件模型 (DOM) 路徑,來描述網頁上的元素。 下列範例顯示具有內嵌 DDA 繫結樹狀子目錄的應用程式初始化字串。 這是一般範例,但指出在 Windows 繫結中用來實作 Acc 控制項的模式。
注意
為清楚起見,已移除某些設定參數。
<initstring>
<interopAssembly>
<URL>path to executable</URL>
<Arguments>test argument</Arguments>
<WorkingDirectory>c:\</WorkingDirectory>
<hostInside/>
</interopAssembly>
<!—- notice there is no custom application adapter specified here-->
<displayGroup>None</displayGroup>
<optimumSize x="800" y="600"/>
<minimumSize x="640" y="480"/>
<DataDrivenAdapterBindings>
<Type>typeName, assemblyName</Type>
<Controls>
<AccControl name="combobox1">
<Path>
<FindWindow>
<ControlID>1003</ControlID>
</FindWindow>
</Path>
</AccControl>
</Controls>
</DataDrivenAdapterBindings>
</initstring>
如果您使用 HAT 軟體工廠,便會建立 InitString。 應用程式接著會從軟體工廠部署至伺服器。
如果使用管理 UI 直接新增託管應用程式,您不需要建立完整 InitString。 您只需要指定 <DataDrivenAdapterBindings> 區段和新增至 [Automation Xml] 索引標籤。
在自訂應用程式配接器中使用 DDA
雖然 DDA 最初設想是支援 託管應用程式工具套件 (HAT) 內部自動化,但是自訂配接器也可以使用它們,取得實用的結果。 下列程式碼範例,取自自訂配接器,說明自訂配接器如何使用 DDA,並說明 DDA 的一般優點。 正如範例說明,使用 DDA 允許程式碼及設定資訊分隔。
DataDrivenAdapter Dda;
public overrIDe bool Initialize()
{
Dda=DataDrivenAdapter.CreateInstance(ApplicationInitString,ApplicationObject);
return (Dda != null);
}
public overrIDe bool DoAction(Action action, ref string data)
{
if (action.Name == "AddToHistory")
{
Dda.ExecuteControlAction("combobox1");
Dda.SetControlValue("textbox1", data);
Dda.ExecuteControlAction("button1");
}
}
DDA 設定,內嵌在應用程式的 InitString 中,會是 XML,如下列範例所示。
<DataDrivenAdapterBindings>
<Type> Microsoft.UII.HostedApplicationToolkit.DataDrivenAdapter.WinDataDrivenAdapter, Microsoft.UII.HostedApplicationToolkit.DataDrivenAdapter</Type>
<Controls>
<AccControl name="combobox1">
<Path>
<FindWindow>
<ControlID>1003</ControlID>
</FindWindow>
</Path>
</AccControl>
<AccControl name="textbox1">
<Path>
<FindWindow>
<ControlID>1001</ControlID>
</FindWindow>
</Path>
</AccControl>
<AccControl name="button1">
<Path>
<FindWindow>
<ControlID>1002</ControlID>
</FindWindow>
</Path>
</AccControl>
</Controls>
</DataDrivenAdapterBindings>
<Type/> 元素指示 UII 動態具現化以 type, assembly 格式指定的類型,進而允許自訂 DDA 載入以及使用。<Controls/> 元素包含設定控制項清單,以所載入 DDA 需要的方式指定。
另請參閱
Unified Service Desk 2.0
© 2017 Microsoft. 著作權所有,並保留一切權利。 著作權