System Center 一般架構的變更
發行︰ 2016年7月
適用於: System Center 2012 SP1 - Service Manager、System Center 2012 R2 Service Manager、System Center 2012 - Service Manager
System Center 2012 – Service Manager 包含更新版本的 System Center 管理組件架構。 此架構現稱為 System Center 一般架構,其中包含一些用來強化現有功能及實現 Service Manager 功能的改良措施和新增內容。 本主題說明 System Center 一般架構的變更。
如需 Service Manager 管理組件的詳細資訊和更多 XML 範例,請參閱直接撰寫管理組件檔案以管理投影機。
內容和內容限制
一般架構能透過幾個新的內容類型來擴充類別。 這些內容類型包括二進位、列舉程式及自動遞增等類型。
此外,您還可以針對某些內容值定義限制。 例如,您可以針對字串內容值定義規則運算式限制。 在以下範例中,BuildingName 內容具有已定義的規則運算式限制,因此唯有包含 "Building" 一字並後接空格和數字的值才能被視為有效的值。
<ClassType ID="Lobby" Accessibility="Public" Base="System!System.Entity">
<Property ID="Id" Type="int" Key="true" />
<Property ID="BuildingName" Type="string" RegEx="Building [0-9]+" />
</ClassType>
映像
由於映像並不儲存於管理組件中, 因此管理組件的 <PresentationTypes> 區段不再包含 <Images>、<Image> 或 <ImageData> 標記。 請改用映像資源。
<Resources>
<Image ID="TestLibrary.Resources.Image1" Accessibility="Public" FileName="image.png"/>
</Resources>
列舉
一般架構支援列舉。 列舉是以樹狀結構排列的值,您可以利用它們來限制內容或屬性的值。
每個列舉都有必要的唯一 ID 屬性和選用的 Parent 屬性。
在下列範例中,XBoxState 列舉的定義包含三個可能的值:Running、Stopped 及 Error。
<EnumerationTypes>
<EnumerationValue ID="XBoxState" Accessibility="Public"/>
<EnumerationValue ID="XBoxState.Running" Parent="XBoxState" Accessibility="Public"/>
<EnumerationValue ID="XBoxState.Stopped" Parent="XBoxState" Accessibility="Public"/>
<EnumerationValue ID="XBoxState.Error" Parent="XBoxState" Accessibility="Public" />
<EnumerationValue ID="XBoxState.Error.RROD" Parent="XBoxState.Error" Accessibility="Public" />
</EnumerationTypes>
在下列範例中,Xbox 類別會定義 enum 類型的 XBoxState 內容。
<ClassType ID="XBox" Accessibility="Public" Base="System!System.ConfigItem" Hosted="true">
<Property ID="Id" Type="int" Key="true" />
<Property ID="Name" Type="string" />
<Property ID=“State" Type="enum" EnumType=“XBoxState" />
</ClassType>
關聯性
在一般架構中,關聯性定義的功能已經過強化。RelationshipType 類型現在具有 Source 和 Target 子元素,並含有可當作顯示名稱的 ID 內容。 此外,您可以定義來源和目標的最小和最大基數 (例如,一對一或零對多關聯性)。
管理組件驗證程序並未強制要求基數,不過它能用來協助定義管理組件的使用者介面。 例如,您可以藉由檢查基數來判斷要以文字方塊或清單來呈現欄位。
![]() |
---|
|
如果您從管理組件新增關聯性類型,使用者必須具有足夠的權限來更新關聯性類型之來源和目標類別執行個體的所有內容,才能建立新關聯性類型的執行個體。
在以下範例定義 HasXboxes 類型和 Lobby 類型之間的裝載關聯性 (稱為 Xbox)。 在此關聯性定義中,每個 Lobby 類型都能擁有多個 Xbox 類型。
<RelationshipType ID="HasXBboxes" Accessibility="Public" Base="System!System.Hosting">
<Source ID="Source" Type="Lobby" />
<Target ID="Target" Type="Xbox" MinCardinality="0" MaxCardinality="9999" />
</RelationshipType>
組合類別
組合類別代表管理組件中多個相關類型的彙總,與在 Microsoft SQL Server 資料庫中定義且能傳回多個資料表之資料的檢視相似。 組合類別能在一次資料庫作業中儲存及擷取所有彙總資料,也能簡化管理組件之使用者介面的定義作業。
以下範例能定義事件管理檢視的投影。 此投影能將數種與事件相關的相異元件組合成一個單位,簡化表單和資料庫作業的複雜度。
<TypeProjections>
<TypeProjection ID="System.WorkItem.Incident.View.ProjectionType"
Accessibility="Public" Type="Incident!System.WorkItem.Incident">
<Component Alias="AffectedUser"
Path="$Target/Path[Relationship='SMCore!System.WorkItemCreatedForUser']$"/>
<Component Alias="AssignedUser" Path="$Target/Path[Relationship='SMCore!System.WorkItemAssignedToUser']$"/>
</TypeProjection>
<TypeProjection ID="System.WorkItem.Incident.View.DCMProjectionType" Accessibility="Public" Type="Incident!System.WorkItem.Incident.DCMIncident">
<Component Alias="AffectedUser" Path="$Target/Path[Relationship='SMCore!System.WorkItemCreatedForUser']$"/>
<Component Alias="AssignedUser" Path="$Target/Path[Relationship='SMCore!System.WorkItemAssignedToUser']$"/>
<!--Baseline and Configuration Item Information-->
<Component Alias="AffectedComputer" Path="$Target/Path[Relationship='Incident!System.WorkItem.Incident.DCMIncident.Refers.NonComplianceComputer']$"/>
</TypeProjection>
<TypeProjection ID="System.WorkItem.ChangeRequestViewProjection" Accessibility="Public" Type="System.WorkItem.ChangeRequest">
<Component Alias="AssignedTo" Path="$Target/Path[Relationship='SMCore!System.WorkItemAssignedToUser']$"/>
</TypeProjection>
<TypeProjection ID="System.WorkItem.ChangeRequestProjection" Accessibility="Public" Type="System.WorkItem.ChangeRequest">
<Component Alias="Activity" Path="$Target/Path[Relationship='SMActivity!System.WorkItemContainsActivity']$">
<Component Alias="ActivityAssignedTo" Path="$Target/Path[Relationship='SMCore!System.WorkItemAssignedToUser']$"/>
<Component Alias="ActivityRelatedWorkItem" Path="$Target/Path[Relationship='SMCore!System.WorkItemRelatesToWorkItem']$">
<Component Alias="ActivityRelatedWorkItemAssignedTo" Path="$Target/Path[Relationship='SMCore!System.WorkItemAssignedToUser']$"/>
</Component>
<Component Alias="ActivityRelatedConfigItem" Path="$Target/Path[Relationship='SMCore!System.WorkItemRelatesToConfigItem']$"/>
<Component Alias="ActivityAboutConfigItem" Path="$Target/Path[Relationship='System!System.WorkItemAboutConfigItem']$"/>
<Component Alias="ActivityFileAttachment" Path="$Target/Path[Relationship='System!System.WorkItemHasFileAttachment']$">
<Component Alias="ActivityFileAttachmentAddedBy" Path="$Target/Path[Relationship='System!System.FileAttachmentAddedByUser']$"/>
</Component>
<Component Alias="Reviewer" Path="$Target/Path[Relationship='SMActivity!System.ReviewActivityHasReviewer']$">
<Component Alias="User" Path="$Target/Path[Relationship='SMActivity!System.ReviewerIsUser']$"/>
<Component Alias="VotedBy" Path="$Target/Path[Relationship='SMActivity!System.ReviewerVotedByUser']$"/>
</Component>
</Component>
<Component Alias="CreatedBy" Path="$Target/Path[Relationship='SMCore!System.WorkItemCreatedByUser']$"/>
<Component Alias="AssignedTo" Path="$Target/Path[Relationship='SMCore!System.WorkItemAssignedToUser']$"/>
<Component Alias="CreatedFor" Path="$Target/Path[Relationship='SMCore!System.WorkItemCreatedForUser']$"/>
<Component Alias="RelatedWorkItem" Path="$Target/Path[Relationship='SMCore!System.WorkItemRelatesToWorkItem']$">
<Component Alias="RelatedWorkItemAssignedTo" Path="$Target/Path[Relationship='SMCore!System.WorkItemAssignedToUser']$"/>
</Component>
<Component Alias="RelatedConfigItem" Path="$Target/Path[Relationship='SMCore!System.WorkItemRelatesToConfigItem']$"/>
<Component Alias="AboutConfigItem" Path="$Target/Path[Relationship='System!System.WorkItemAboutConfigItem']$"/>
<Component Alias="FileAttachment" Path="$Target/Path[Relationship='System!System.WorkItemHasFileAttachment']$">
<Component Alias="FileAttachmentAddedBy" Path="$Target/Path[Relationship='System!System.FileAttachmentAddedByUser']$"/>
</Component>
</TypeProjection>
<TypeProjection ID="System.FileAttachmentProjection" Accessibility="Public" Type="System!System.FileAttachment">
<Component Alias="FileAttachmentAddedBy" Path="$Target/Path[Relationship='System!System.FileAttachmentAddedByUser']$"/>
</TypeProjection>
</TypeProjections>
主控台工作
一般架構中的主控台工作已獲得擴充。 在先前的版本中,主控台工作是指向應用程式目錄和執行檔名稱的簡單指標。 在經過實作後,主控台工作現已成為 Microsoft .NET Framework 組件中的處理常式程式碼。 處理常式程式碼會參考裝載程式碼的組件、處理常式名稱,以及能以引數形式傳遞給處理常式的具名值清單。
以下範例定義 Some.Handler.Name 組件中的 MyLibrary.Resources.Assembly 處理常式。 另定義處理常式參數清單和參數的值。
<ConsoleTask ID="MyLibrary.ConsoleTasks.T1"
Accessibility="Public"
Target="System!System.Entity"
Enabled="true"
RequireOutput="true">
<Assembly>MyLibrary.Resources.Assembly1</Assembly>
<Handler>Some.Handler.Name</Handler>
<Parameters>
<Argument Name="Application">cmd.exe</Argument>
<Argument Name="WorkingDirectory">%TEMP%</Argument>
<Argument>test1</Argument>
<Argument>test2</Argument>
</Parameters>
</ConsoleTask>
資源
二進位資料並未直接儲存在管理組件中。 不過,有關二進位資源的中繼資料會儲存在管理組件中,而實際的二進位資料則儲存在外部的資源檔案中。 中繼資料包括唯一識別碼、檔案名稱、建立日期、修改日期及存取資訊。
二進位資料包括一般資源、映像、組件、報表定義及表單。 以下範例指出一般 XML 資源、組件資源及報表資源。
<Resources>
<Resource ID="TestLibrary.Resources.Test1" Accessibility="Public" FileName="res1.xml"/>
<Resource ID="TestLibrary.Resources.Test2" Accessibility="Public" FileName="res2.xml"/>
<Assembly ID="TestLibrary.Resources.Assembly1" Accessibility="Public" QualifiedName="Baz, Version=1.0.0.0" FileName="baz.dll"/>
<Assembly ID="TestLibrary.Resources.Assembly2" Accessibility="Public" QualifiedName="Yoyo, Version=1.0.0.0" FileName="yoyo.dll">
<Dependency ID="TestLibrary.Resources.Assembly1"/>
</Assembly>
<ReportResource ID="TestLibrary.Resources.Report1" Accessibility="Public" MIMEType="text/xml" FileName="res1.xml"/>
<Image ID="TestLibrary.Resources.Image1" Accessibility="Public" FileName="image.png"/>
</Resources>
表單
表單是在管理組件中定義的。 您可以使用表單檢視和修改類型或組合類別的單一執行個體。
表單的基礎為 Windows Presentation Framework (WPF),其定義位於組件中。 包含管理組件之表單實作的組件和類別收編於管理組件的資源區段中。 如同使用全新一般架構之管理組件中的所有二進位資源,管理組件本身不含表單的二進位資料。 管理組件中只包含已指定的資源資訊清單。
您可以在管理組件中指定自己的表單設定資訊。 在下列範例中,Configuration 區段包含 ShowXboxes 內容。 管理組件驗證程序不會評估這項設定資訊,它只會經過表單實作的解譯。
<Forms>
<Form ID="LobbyForm" Target="Projection" Assembly="FormAssembly“ TypeName="MyFormClass">
<Configuration>
<ShowXboxes>yes</ShowXboxes>
</Configuration>
</Form>
</Forms>