使用 Service Manager 撰寫自訂及撰寫類別Customize and author classes with Service Manager authoring

重要

此版本的 Service Manager 已達到終止支援,建議您 升級至 Service Manager 2019This version of Service Manager has reached the end of support, we recommend you to upgrade to Service Manager 2019.

類別是用來代表 Service Manager 中所使用之物件的主要元素。A class is the main element that is used to represent objects that are used in Service Manager. 類別可代表電腦、使用者、事件或表單。A class can represent a computer, a user, an incident, or a form.

代表較大專案的類別定義(例如 Service Manager 功能)通常會群組在一起。Class definitions that represent a larger element, such as a Service Manager feature, are often grouped together. 類別定義儲存在管理元件中,必須匯入 Service Manager 才能啟用 Service Manager 功能。Class definitions are stored in management packs that must be imported into Service Manager to enable Service Manager functionality.

類別的重要概念Key concepts for classes

Service Manager 中的物件是特定基類的 實例Objects in Service Manager are instances of a particular base class. 基底類別的所有執行個體均有共通的一組內容和共通行為。All instances of a base class have a common set of properties and common behavior.

如同所有管理組件元素,類別也具有「識別碼」 ** 和「顯示名稱」 ** 內容。Like all management pack elements, classes have ID and Display Name properties. 在此檔中,「識別碼」是指只在 Authoring Tool 中看到的類別唯一名稱,而「名稱」和「顯示名稱」則是指 - 出現在 Service Manager 主控台中的語言特定名稱。In this documentation, "ID" refers to the unique name of the class that is seen only in the Authoring Tool, while "Name" and "Display Name" refer to the language-specific name that appears in the Service Manager console.

注意

當您建立類別時,請務必確定類別名稱在管理組件之間是唯一的。When you are creating a class, always ensure that class names are unique among management packs. 可能的話,請使用在環境中有意義的類別名稱。If possible, use class names that are meaningful in your environment. 您可以使用 Service Manager Authoring Tool 的 [ 類別瀏覽器 ] 視窗中的搜尋功能,判斷類別名稱是否已存在。You can determine whether a class name already exists by using the search feature in the Class Browser window of the Service Manager Authoring Tool.

propertiesproperties

特定類別的所有執行個體均有一組共通的「內容」 **。All instances of a particular class share a common set of properties. 這些內容的值由使用者透過不同方法提供,而且可視不同的執行個體而異。The values for these properties are provided in various methods by users and can vary among different instances. 內容用來表示實際物件的詳細資料,例如唯一名稱、位置以及使用者可能有興趣或管理案例所需的其他詳細資料。Properties are used to represent details of the actual object, such as a unique name, location, and other details that may be interesting to the user or that are required for management scenarios.

金鑰屬性Key properties

「索引鍵內容」 ** 可唯一識別特定類別的每個執行個體。A key property uniquely identifies each instance of a particular class. 如果內容標示為索引鍵內容,每個類別執行個體的該內容必須具有唯一值,且值不能為 Null。If a property is marked as a key property, each instance of the class must have a unique value for that property, and the value cannot be null. 針對「受裝載類別」 **,只有具有相同裝載父系的所有類別執行個體的值才必須是唯一的。For hosted classes, the value must only be unique for all instances of the class that have the same hosting parent. 針對「非受裝載類別」 **,則管理組件中所有類別執行個體的值都必須是唯一的。For unhosted classes, it must be unique for all instances of the class in the management group. 本節稍後會進一步說明裝載關聯性。Hosting relationships are further described later in this section.

類別不一定都需要索引鍵內容。Classes do not always require a key property. 只有在單一父系預期有一個以上的類別執行個體時,才需要索引鍵內容。A key property is only required if more than one instance of a class is expected for a single parent. 如果只預期單一執行個體,就不需要索引鍵內容,不過您仍可加以定義。If only a single instance is expected, a key property is not required but may still be defined.

例如, SQL Database Engine 具有 實例名稱 的索引鍵內容,因為單一電腦可能安裝了一個以上的 Microsoft SQL Server 實例   。For example, SQL Database Engine has a key property of Instance Name because a single computer can have more than one instance of Microsoft SQL Server installed. 當有多個 SQL Database Engine執行個體時,每個執行個體必須具有不同的 Instance Name 值,才能清楚區分不同的物件。When there are multiple instances of SQL Database Engine, each instance must have a different value for Instance Name in order to clearly distinguish between the different objects. 相反地, IIS Web 伺服器 類別就不會定義索引鍵內容,因為任何電腦上只能安裝一個執行個體。The IIS Web Server class, by contrast, does not define a key property because there can be only one instance installed on any computer.

所有物件都有 [ 路徑名稱 ] 屬性,此屬性是從物件的索引鍵屬性(property),以及其裝載父系或父系的屬性(property)計算而來。All objects have a Path Name property that is calculated from the object's key property or properties and those of its hosting parent or parents. 針對非裝載物件, Path Name 會是類別本身的索引鍵內容。For unhosted objects, Path Name will be the key property of the class itself. Path Name 可用來唯一識別管理群組中類別的任何執行個體。Path Name can be used to uniquely identify any instance of a class in the management group.

基類和繼承Base classes and inheritance

每個類別都必須指定「基底類別」 ** ,這可識別新類別將用來「特殊化」 ** 的現有類別。Every class must specify a base class that identifies an existing class that the new class will specialize. Service Manager 隨附的管理元件程式庫包含數個類別,可用來做為管理元件中自訂類別的基底。The management pack libraries that are included with Service Manager contain several classes that can be used as the base for custom classes in management packs. 管理組件通常會至少有一個類別繼承自程式庫類別,並可能有其他類別繼承自相同管理組件中的類別。A management pack will typically have at least one class inheriting from a library class and potentially other classes inheriting from classes in the same management pack.

您可以使用 Windows   Server 作業系統管理元件來說明基類的概念。The concept of a base class can be illustrated with the Windows Server Operating System management pack. 此管理組件包含代表電腦上所安裝邏輯磁碟的類別。This management pack includes classes representing logical disks installed on the computer. 下圖顯示 windows   Server   2003 邏輯磁片windows   server   2008 邏輯磁片的類別。The following illustration shows the classes Windows Server 2003 Logical Disk and Windows Server 2008 Logical Disk. 這些類別都是以 Windows server Library 管理元件檔案中定義的**邏輯磁片 ( 伺服器 ) **為基礎。These classes are both based on Logical Disk (Server) that is defined in the Microsoft.Windows.Server.Library management pack file. 邏輯磁片 (伺服器 ) 接著是以邏輯磁片為基礎,其本身是以邏輯裝置為基礎,以此類推于邏輯硬體邏輯實體和最後一個實體Logical Disk (Server) is in turn based on Logical Disk, which itself is based on Logical Device, and so on through Logical Hardware, Logical Entity, and finally Entity. 所有類別都可以沿著類似的繼承路徑,而且最後一定會到達 實體,即類別結構的根。All classes can trace a similar inheritance path and will always end up at Entity, which is the root of the class structure. 這是唯一沒有基底類別的類別,而所有其他類別最終都是繼承自該類別。This is the only class that does not have a base class, and all other classes eventually inherit from it.

類別之間屬性的繼承Inheritance of properties between classes

類別之間屬性的繼承

實體 具有單一內容,名為 Display NameEntity has a single property, named Display Name. 繼承自 實體的所有類別都會繼承此內容。This property is inherited by all classes inheriting from Entity. 所有類別最終都是繼承自 實體All classes eventually inherit from Entity. 這就是為什麼所有類別都具有 Display Name 內容。That is why all classes have a Display Name property. 在此範例中的類別,要等到 邏輯裝置開始才具有內容,其定義了 NameDescriptionDeviceIDNo other classes in this example have properties until Logical Device, which defines Name, Description, and DeviceID. DeviceID 是以索引鍵內容指定。DeviceID is specified as the key property. 邏輯磁片和**邏輯磁片 ( 伺服器 ) **都會繼承這些屬性。These properties are all inherited by Logical Disk and Logical Disk (Server). 邏輯磁片 (接著 ) ,伺服器會新增其他屬性大小磁片磁碟機類型檔案系統Logical Disk (Server) then adds the additional properties Size, Drive Type, and File System. -作業系統版本特定的最底層類別,會繼承在繼承樹狀結構中這些類別之上的整個屬性集。The bottom-level classes that are specific to the version of the operating system inherit the entire set of properties provided by those classes above them in the inheritance tree.

類別類型Class types

大多數類別都具有一或多個實際執行個體,這些類別稱為「實體類別」 **。Most classes have one or more actual instances and are known as concrete classes. 「抽象類別」** 和「單一類別」 ** are special kinds of classes that behave differently 和「單一類別」 are used for particular scenarios.Abstract classes and singleton classes are special kinds of classes that behave differently and are used for particular scenarios.

抽象類別Abstract classes

抽象類別沒有執行個體,存在的目的僅是作為其他類別的基底類別使用。Abstract classes have no instances and exist only to act as a base class for other classes. 子類別會繼承抽象類別層級定義的所有內容和關聯性,因此不必再次定義。All properties and relationships that are defined at the abstract class level are inherited by child classes and do not have to be defined again. 管理組件程式庫中定義的大多數類別都是抽象類別,因為這些類別僅提供作為自訂管理組件中定義之類別的基底類別。Most of the classes that are defined in management pack libraries are abstract, since they are only provided to act as base classes for classes that are defined in custom management packs.

當類別的所有進一步特殊化項目之間可以定義一組共通的內容、關聯性或群組時,就可以使用抽象類別。Abstract classes are used where there is a common set of properties, relationships, or grouping that can be defined across all further specializations of a class. 在上述範例中, windows   Server   2003 邏輯磁片windows   server   2008 邏輯磁片 上方顯示的所有類別都是抽象的。In the previous example, all of the classes shown above Windows Server 2003 Logical Disk and Windows Server 2008 Logical Disk are abstract. 它們只存在於要繼承的較低 - 層級類別。They exist only for the lower-level classes to inherit from.

單一類別Singleton classes

當類別只有一個執行個體時,會使用「單一類別」** 。Singleton classes are used when there is one and only one instance of a class. 類別就是執行個體,而且永遠存在。The class is the instance, and it always exists. 單一類別會隨管理組件安裝時建立。The single instance is being created when the management pack is installed. 同樣地,單一類別不需要索引鍵內容,因為它永遠只會有一個單一執行個體。Similarly, a key property is not required for a singleton class, because it will only ever have a single instance. 單一類別通常用於 群組 類別,因為在整個管理群組中只需要此類別的單一執行個體。A common use of singleton classes is for the Groups class, because there is only a single instance of this class required throughout the management group.

類別延伸Class extensions

若要自訂類別,您可以將新內容加到現有類別定義來延伸它。To customize a class, you can extend it by adding new properties to the existing class definition. 新內容現在會包含在該類別的所有已存在的執行個體中,以及將建立的任何新執行個體中。The new properties will now be included in all instances of that class that already exist, and in any new instances that will be created. 抽象類別無法延伸。An abstract class cannot be extended.

關聯性Relationships

類別之間會定義「關聯性」** ,以指出某類別的特定執行個體與其他類別的特定執行個體之間的關聯。Relationships are defined between classes to indicate an association between a particular instance of one class and the particular instance of another. 關聯性有三種類型,將分別在下列各節詳細說明:There are three types of relationships, and they are detailed in the following sections:

  • 裝載關聯性Hosting relationship

  • 內含項目關聯性Containment relationship

  • 參考關聯性Reference relationship

類別關聯性影響物件的方式如下。Class relationships affect objects in the following ways.

關聯性類型Relationship type 索引鍵內容和存在性Key property and existence 可用屬性Available properties
HostingHosting 管理群組中類別的所有執行個體的索引鍵內容值都必須是唯一的。The value of the key property must be unique for all instances of the class in the management group. 不過,針對受裝載類別,則只有具有相同裝載父系的所有物件的索引鍵內容值才必須是唯一的。For hosted classes however, the key property value must be unique only for all objects that have the same hosting parent.

若要唯一識別裝載物件,需要物件和物件父系的索引鍵屬性,而且裝載類別的索引鍵會是裝載類別索引鍵屬性和託管類別索引鍵屬性的組合。To uniquely identify a hosted object, the key property of both the object and the object's parent are required and the key of the hosted class will be the combination of both the hosting class key property, and the hosted class key property.

受裝載類別的存在相依於裝載類別的存在。The existence of a hosted class depends on the existence of the hosting class.
以類別為目標的任何工作流程都可以存取該類別的屬性,以及其任何裝載父系的屬性 ( ) 。Any workflow that is targeted at a class have access to that class's properties in addition to the properties of any of its hosting parent(s).

例如,使用 SQL   2008 資料庫引擎 類別做為目標的工作流程中的腳本可能需要安裝 SQL Server 2008 實例的電腦名稱稱。For example, a script in a workflow using the SQL 2008 DB Engine class as its target might require the name of the computer on which the instance of SQL Server 2008 is installed. 由於物件只能有一個裝載父系,因此我們知道裝載 SQL   2008 資料庫引擎 類別之任何特定實例的電腦。Because an object can have only one hosting parent, we know the computer that hosts any particular instance of the SQL 2008 DB Engine class. 工作流程腳本可以存取目標物件的屬性,以及該目標的裝載父系的屬性。The workflow script can access the properties of the targeted object and the properties of that target's hosting parent.
ContainmentContainment 索引鍵內容和存在性並非相依於容器物件。Key property and existence are not dependent on container object. 以類別為目標的任何工作流程都可以存取該類別的屬性,以及其任何容器父系的屬性 ( ) 。Any workflow that is targeted at a class have access to that class's properties in addition to the properties of any of its container parent(s).

例如,工作流程中以事件類別為目標的腳本可以存取容器佇列類別的屬性。For example, a script in a workflow targeting an incident class, can access the properties of the container queue's class.
參考Reference 索引鍵內容和存在性並非相依於參考的物件。Key property and existence are not dependent on referenced object. 以類別為目標的任何工作流程只能存取該類別的屬性。Any workflow that is targeted at a class have access only to that class's properties.

參考關聯性Reference relationship

「參考關聯性」 ** 是最一般的關聯性類型。The reference relationship is the most general relationship type. 當父類別和子類別並非相依於彼此時,就會使用參考關聯性;例如,資料庫可以參考其複寫的另一個資料庫。A reference relationship is used when the parent and child classes are not dependent on one another; for example, a database could reference another database that it is replicating. 資料庫並非彼此相依,因此物件可以單獨存在。One database is not dependent on the other, and the objects exist separately.

內含項目關聯性Containment relationship

「內含項目關聯性」 ** 類型的限制少於裝載關聯性。The containment relationship type is less restrictive than the hosting relationship. 它會宣告類別與其他類別相關,但對彼此來說並非必要的。It declares that one class is related to another class, although one is not required for the other. 不同于裝載關聯性,內含專案關聯性是多 - 對多關聯性 - 。Unlike a hosting relationship, a containment relationship is many-to-many. 這表示一個物件可以內含多個物件,而單一物件可以由多個其他物件所內含。This means that one object can contain multiple objects, and a single object can be contained by multiple other objects. 例如,一個群組可以包含多個物件,而單一物件可以是多個群組的成員。For example, one group can contain multiple objects, and a single object can be a member of multiple groups.

內含項目關聯性通常用於群組成員資格,在這種情況中,物件是透過群組和成員物件之間的內含項目關聯性包含在群組中。Containment relationships are typically used for group membership where objects are included in a group through a containment relationship between the group and the member object.

裝載關聯性Hosting relationship

類別間限制最多的關聯性要屬「裝載」 ** 關聯性。The most restrictive relationship between classes is the hosting relationship. 由其他類別所裝載的類別稱為「受裝載類別」 **,而該類別的執行個體稱為「受裝載物件」 **。A class hosted by another class is called a hosted class, and an instance of the class is called a hosted object. 如果類別不是由其他類別所裝載,則稱為「非受裝載類別」 **,而該類別的執行個體稱為「非受裝載物件」 **。If a class is not hosted by another, it is called an unhosted class, and an instance of the class is called an unhosted object.

當一個物件由其他物件所裝載時,該物件的存在依賴其裝載父系。When one object is hosted by another, that object relies on its hosting parent for its very existence. 如果裝載父系移除,則受裝載子系會一併移除。If the hosting parent is removed, the hosted child will also be removed. 例如,邏輯磁碟無法在沒有安裝它的電腦的情況下存在。For example, a logical disk cannot exist without the computer that it is installed on.

受裝載物件只能有一個裝載父系,但一個父系可裝載多個子系。A hosted object can have only one hosting parent, but one parent can host multiple children. 例如,特定磁碟只能安裝在單一電腦上,但一部電腦可安裝多個磁碟。For example, a particular disk can be installed on only a single computer, but one computer can have several disks installed.

SQL Server 管理組件提供了另一個裝載關聯性範例。The SQL Server management pack provides another example of hosting relationships. Windows 電腦 類別、 SQL 2008 DB 引擎 類別和 SQL 2008 DB 類別之間的裝載關聯性顯示如下。The hosting relationship between the Windows Computer class, the SQL 2008 DB Engine class, and the SQL 2008 DB class is shown here.

SQL   Server   2008 類別的裝載關聯性Hosting relationships for SQL Server 2008 classes

SQL Server 2008 類別的裝載關聯性

SQL   2008 資料庫引擎類別代表   安裝在特定電腦上 SQL Server 2008 的實例。The SQL 2008 DB Engine class represents an instance of SQL Server 2008 installed on a particular computer. 由於資料庫只能安裝在單一資料庫引擎上,因此 sql   2008 資料庫引擎 類別會裝載 sql   2008 db 類別。Because a database can be installed on only a single database engine, the SQL 2008 DB Engine class hosts the SQL 2008 DB class. 管理群組中可有同名的多個資料庫,但安裝在特定 SQL Server 類別執行個體的任何資料庫必須具有唯一名稱。There can be several databases with the same name in a management group, but any databases installed on a particular instance of the SQL Server class must have a unique name. 資料庫引擎又由 Windows 電腦 類別所裝載。The database engine, in turn, is hosted by the Windows Computer class. 管理群組中可有同名的多個 SQL Server 執行個體。There can be several SQL Server instances with the same name in a management group. 在特定電腦上的每個執行個體則必須具有唯一名稱。Each one on a particular computer must have a unique name.

由於有兩個裝載關聯性,每個資料庫的路徑名稱會是電腦名稱接著執行個體名稱,然後再接著資料庫名稱。Because there are two hosting relationships, the path name for each database will be the computer name followed by the instance name followed by the database name. 下圖顯示範例。An example is shown in the following diagram.

範例資料庫裝載關聯性Sample database hosting relationships

範例資料庫裝載關聯性

類別的一般指導方針和最佳作法General guidelines and best practices for classes

當您在 Service Manager Authoring Tool 中自訂類別時,請使用下列指導方針和最佳作法。Use the following guidelines and best practices when you are customizing classes in the Service Manager Authoring Tool.

型別定義的命名慣例Naming conventions for type definitions

Service Manager 架構模型命名慣例是以 .NET 命名空間命名慣例為基礎。The Service Manager schema model naming convention is based on the .NET namespaces naming convention.

基本命名慣例Basic naming conventions

基本命名慣例是 CompanyName.TechnologyArea.ProductName.FunctionalityArea.Name,其中:The basic naming convention is CompanyName.TechnologyArea.ProductName.FunctionalityArea.Name, where:

  • ProductName 是選用項;如果定義與任何特定產品無關,請使用此項目。ProductName is optional; use it if the definition is independent of any specific product.

  • FunctionalityArea 是選用項;如果定義可套用到不同區域,請使用此項目。FunctionalityArea is optional; use it if the definition can apply to different areas.

  • Name 反映的是類別的意義,不是繼承階層。Name reflects the meaning of the class, not the inheritance hierarchy.

範例: Microsoft.AD.PrinterMicrosoft.Windows.ComputerSystem.Knowledge.ArticleSystem.WorkItem.IncidentSystem.StarRating.AverageExamples: Microsoft.AD.Printer, Microsoft.Windows.Computer, System.Knowledge.Article, System.WorkItem.Incident, and System.StarRating.Average.

System 命名空間The System namespace

System 命名空間參照的是與 Microsoft 和 Windows 無關的定義。The System namespace refers to definitions that are independent of Microsoft and Windows. 這通常適用於 Windows 應用程式或 Unix 應用程式相依的基底定義。This usually applies to the base definitions that either Windows applications or Unix applications depend on. 這些基底定義應該與公司無關。These base definitions should be company independent.

請使用下列適用於 System 首碼的指導方針:Use the following guidelines for the System prefix:

  • System.Computer 代表任何類型的電腦,而非廠商特定的電腦。System.Computer represents any type of computer, and it is not vendor specific.

  • 如果您預期其他人會在該命名空間之上定義架構,請使用 System 首碼。Use the System prefix if you expect others to define schemas on top of that namespace.

  • 請注意,雖然大部分的 Windows 應用程式都是System以這項定義為依據,但大部分的 windows 應用程式都不會以 System 為開頭 ( )Note that Microsoft.Windows.Computer does not start with System, although most Windows applications (regardless of the vendor that defines it) rely on this definition.

命名類別的最佳作法Best practices for naming classes

在命名類別時,請使用下列最佳作法:Use the following best practices when you are naming classes:

  • 請勿建立兩個不同的類別 ( ,即使它們位在兩個不同的管理元件中 ) ,也會導致針對兩個類別的不同物件儲存相同的索引鍵值。Do not create two separate classes (even if they are in two different management packs) that would result in identical key values being stored for different objects of the two classes.

  • 擴充類別時,請務必確認類別擴充名稱在各管理組件間具有唯一性。When you are extending a class, always ensure that the class extension names are unique across management packs. 如果可能,請使用有意義的類別擴充名稱。If possible, use meaningful class extension names.

  • 擴充類別時,請勿使用該類別中已使用的識別碼來定義內容。When you are extending a class, do not define a property with an ID that is already in use in that class.

  • 請勿在自訂類別的內容名稱中使用句號。Do not use periods in names of properties of a custom class.

  • 如果您在撰寫 cube 時新增自訂命名計算,請在命名計算的名稱前面加上 NC _ 。If you add a custom named calculation when you author a cube, preface the name of the named calculation with NC_. 如此即可降低使用已存在之內容名稱的可能性。This will reduce the possibility of using a name of a property that already exists.

請勿建立太多類別Do not create too many classes

建立過多類別可能會產生無謂且無價值的複雜性。Creating too many classes can result in needless complexity with minimal value. 理想的規則是使用最少的類別來達成所需的結果。A good rule is to use the least number of classes to achieve the desired results. 除了抽象類別以外,如果類別並非要當作任何工作流程的目標或要用來儲存資料,可能就不應該建立該類別。Other than abstract classes, if a class is not going to be the target of any workflow or be used to store data, it probably should not be created. 另外,如果有兩個類別非常類似,請考慮使用單一類別來代表兩者 (或許可透過使用能夠容納任何差異值的內容)。Also, if two classes are similar, consider using a single class for both of them, possibly by using a property that can hold the values for any differences.

請勿使用經常更新的屬性Do not use properties that update frequently

內容值在第一次填入後應該很少變更。Property values should change rarely after they are first populated. 常見屬性值變更的可能原因是自訂連接器,或是以程式設計方式更新 Service Manager 資料庫的任何其他自訂。A possible cause for frequent property value changes is a custom connector or any other customization that programmatically updates the Service Manager database. 這些案例都可能會造成內容值更新頻率過高,例如每 10 到 15 分鐘 (或更少) 便需處理大量物件。These scenarios can potentially cause property values to update too frequently, such as every 10 to 15 minutes or less for a large number of objects.

這種經常變更內容值的狀況可能會對工作流程的效能造成些許影響,也可能帶來其他效能影響。Such frequent changes to property values might slightly impact the performance of the workflows, and they might have other performance impacts. 這是因為系統會持續在歷程記錄中追蹤這些變更。This is because the system keeps track of those changes in history. 另外,依據發生變更的內容而定,這些變更也可能會增加大量需要由資料倉儲處理及儲存的資料。Also, depending on the property being changed, these changes can add a significant amount of data to be processed and stored by the data warehouse.

不要擴充抽象類別Do not extend an abstract class

在 Service Manager 中,您無法擴充抽象類別。In Service Manager, you cannot extend an abstract class. 如果您需要擴充抽象類別,可以執行下列其中一個動作;If you need to extend an abstract class, you can do either of the following:

  • 使用您要新增的內容建立新類別,然後建立新類別和抽象類別間的關聯性。Create a new class with the properties you want to add, and then create a relationship between the new class and the abstract class.

  • 擴充衍生自抽象類別的每個相關實體類別。Extend each of the relevant concrete classes that derive from the abstract class.

改善工作專案類別的簡易搜尋Improve simple search for work item classes

當您定義衍生自 "system.string" 類別的自訂類別時,建議您以下列格式儲存該類別的 DisplayName 屬性: WorkItem.ID <SPACE> 工作專案。 TitleWhen you define a custom class that is derived from the "System.WorkItem" class, we recommend that you store the DisplayName property of that class in the following format: WorkItem.ID<SPACE>WorkItem.Title.

這可改善簡易搜尋。This improves simple search. 簡易搜尋只會搜尋 DisplayName 內容,而透過將 Title 內容值和 ID 內容值明確包含在 DisplayName 內容值中,簡易搜尋的結果便可獲得改善。Simple search searches only the DisplayName property, and by explicitly including the Title property value and the ID property value in the DisplayName property value, the results of simple search are improved. 這是因為使用者可以按照標題中的字詞或是按照識別碼進行搜尋。This is because the user can search either by a word in the title or by ID.

在 Authoring tool 中流覽類別Browse a class in the Authoring tool

您可以使用 Service Manager Authoring Tool 中的 [ 類別瀏覽器 ] 窗格來流覽類別和其屬性。You can use the Class Browser pane in the Service Manager Authoring Tool to browse classes and their properties. 當您流覽類別時,您可以將屬性從 [ 類別瀏覽器 ] 窗格拖曳到撰寫窗格中正在撰寫的表單,以將控制項加入至表單。While you are browsing classes, you can add a control to a form by dragging properties from the Class Browser pane to a form that is being authored in the authoring pane.

[ 類別瀏覽器 ] 窗格可以從 Library 資料夾中的任何管理元件,以及在 Authoring Tool 中開啟的任何管理元件顯示類別。The Class Browser pane can display classes from any management pack that is in the Library folder and from any management pack that has been opened in the Authoring Tool. 當您選取類別時,[ 類別瀏覽器 ] 窗格會顯示特別針對該類別定義的屬性,以及系統所產生的內部屬性。When you select a class, the Class Browser pane displays the properties that are specifically defined for that class and the internal properties that are generated by the system. 程式庫資料夾預設位於下列位置: C: \ Program Files ( X86 ) \ Microsoft System Center \ Service Manager Authoring \ Library。By default, the Library folder is in the following location: C:\Program Files (x86)\Microsoft System Center\Service Manager Authoring\Library.

當您在 [ 類別瀏覽器 ] 窗格中選取管理元件時,會顯示所選管理元件中的所有類別,而且您可以展開要查看其屬性的類別。When you select a management pack in the Class Browser pane, all the classes from the selected management pack are displayed, and you can expand the class for which you want to view properties. 當您選取 [ 所有管理元件] 時,會顯示 [程式庫] 資料夾中所有管理元件的所有類別。When you select All Management Packs, all the classes from all the management packs in the Library folder are displayed. 每當您變更管理元件的選取專案時,都必須重新整理 [ 類別瀏覽器 ] 窗格。Whenever you change the selection of the management pack, you must refresh the Class Browser pane.

若要瀏覽類別To browse a class

  1. 如果在 Authoring Tool 中看不到 [ 類別瀏覽器 ] 窗格,請按一下 [ View],然後按一下 [ 類別瀏覽器]。If the Class Browser pane is not visible in the Authoring Tool, click View, and then click Class Browser.

  2. 在 [ 類別瀏覽器 ] 窗格的 [管理元件] 清單中,選取包含您要流覽之類別的管理元件。In the Class Browser pane, in the management pack list, select the management pack that contains the class that you want to browse. 例如,選取 [ 系統程式庫 ] 管理元件。For example, select the System Library management pack.

  3. 找出您想要查看的類別,例如 [ 電腦 ] 類別,然後執行下列動作:Locate the class that you want to view, such as the Computer class, and then do the following:

    • 若要查看類別的詳細資料,例如 [ 描述 ] 和 [ 內部名稱],請以滑鼠右鍵 - 按一下類別,然後按一下 [ 詳細資料]。To view the details of the class, such as Description and Internal Name, right-click the class, and then click Details.

    • 若要查看類別屬性的清單,例如 [ 顯示名稱 ] 和 [ 資產狀態],請在 [ 類別瀏覽器 ] 窗格中展開類別。To view the list of class properties, such as Display Name and Asset Status, expand the class in the Class Browser pane. 若要進一步查看屬性的詳細資料,請以滑鼠右鍵 - 按一下屬性,然後按一下 [ 詳細資料]。To further view details of a property, right-click the property, and then click Details.

    • 若要開啟包含類別定義的管理元件,請以滑鼠右鍵 - 按一下類別,然後按一下 [ View]。To open the management pack that contains the definition of the class, right-click the class, and then click View.

在 Authoring tool 中編輯類別的詳細資料Edit details of a class in the Authoring tool

您可以使用 Service Manager Authoring Tool 來檢視類別的內容並編輯詳細資料 (例如類別的名稱或描述)。You can use the Service Manager Authoring Tool to view the properties of a class and to edit the details, such as the name or description, of a class.

在 [ 管理元件瀏覽器] 中,您可以選取類別,並在 [ 詳細資料 ] 窗格中查看其詳細資料。In the Management Pack Explorer, you can select a class and view its details in the Details pane. 如果您選取在未密封管理組件中定義的類別,就可以變更該類別的名稱和描述。If you select a class that is defined in an unsealed management pack, you can change the name and description of that class.

若要變更類別的名稱或描述To change the name or description of a class

  1. 在桌面上,按一下 [ 開始]。On your desktop, click Start.

  2. 按一下 [ Service Manager Authoring Tool],然後等待 Authoring Tool 開啟。Click Service Manager Authoring Tool, and wait for the Authoring Tool to open.

  3. 確定 [ 管理元件瀏覽器 ] 和 [ 詳細資料 ] 窗格都已開啟。Ensure that both the Management Pack Explorer and the Details panes are open.

  4. 按一下 [檔案 ],然後按一下 [****開啟]。Click File, and then click Open.

  5. 在 [ 開啟 檔案] 對話方塊中,選取包含您要變更之類別的未密封管理元件,然後按一下 [ 開啟]。In the Open File dialog box, select an unsealed management pack that contains the class that you want to change, and then click Open. 例如,Woodgrove.AutomatedActivity.AddComputerToGroupMP.xml 範例管理元件中開啟 Authoring Tool 安裝資料夾 \ 範例 \ 。For example, open the Authoring Tool installation folder \Samples\Woodgrove.AutomatedActivity.AddComputerToGroupMP.xml sample management pack.

  6. 在 [ 管理元件瀏覽器] 中,展開包含您要變更之類別的管理元件。In the Management Pack Explorer, expand the management pack that contains the class that you want to change.

  7. 展開 [ 類別],然後找出並選取您要變更的類別。Expand Classes, and then locate and select the class that you want to change.

  8. 選取 [ 名稱 ] 或 [ 描述 ] 屬性的值,然後輸入新值。Select the value of the Name or Description property, and then enter the new value. 您無法選取不能變更的值。Values that cannot be changed are unavailable.

  9. 在 [ Management Pack Explorer] 中,以滑鼠右鍵 - 按一下包含已變更類別的管理元件,然後按一下 [ 儲存]。In the Management Pack Explorer, right-click the management pack that contains the changed class, and then click Save.

在 Authoring tool 中使用繼承建立類別Create a class using inheritance in the Authoring tool

在 Service Manager Authoring Tool 中,您可以建立從現有基底類別繼承之內容和關聯性的類別。In the Service Manager Authoring Tool, you can create a class that inherits properties and relationships from an existing base class. 接著您可以修改或新增內容和關聯性到新的類別。You can then modify or add properties and relationships to the new class.

在定義類別繼承的第一個步驟中,請選擇要作為內容和關聯性繼承來源的基底類別。As the first step of defining class inheritance, choose the base class from which to inherit properties and relationships. 在 Authoring Tool 中,您可以使用下列其中一種方法來選擇基類:In the Authoring Tool, you can choose the base class by using one of the following methods:

  • 使用捷徑從基礎設定項目類別繼承內容和關聯性。Use a shortcut to inherit properties and relationships from the base configuration item class.

  • 使用捷徑從基礎工作項目類別繼承內容和關聯性。Use a shortcut to inherit properties and relationships from the base work item class.

  • 先選取基底類別,然後再開始定義繼承。First select the base class, and then start defining the inheritance.

  • 開始定義繼承,但不選取特定的基底類別。Start defining inheritance without a specific base class selection.

    下列程式描述在 Authoring Tool 中定義類別繼承的所有方法。The following procedures describe all the methods for defining class inheritance in the Authoring Tool.

若要先以設定項目類別或工作項目類別作為基底類別To start with the configuration item class or the work item class as a base class

  1. 如果在 Authoring Tool 中看不到 管理元件 explorer ,請按一下 [ View],然後按一下 [ management pack explorer]。If the Management Pack Explorer is not visible in the Authoring Tool, click View, and then click Management Pack Explorer.

  2. 在 [ 管理元件瀏覽器] 中,選取 [],然後展開 [任何管理元件]。In the Management Pack Explorer, select and then expand any management pack.

  3. 以滑鼠右鍵 - 按一下 [ 類別],然後按一下 [ 建立設定專案類別 ] 或 [ 建立工作專案類別]。Right-click Classes, and then click Create Configuration Item Class or Create Work Item Class.

  4. 如果您是從密封的管理元件建立類別,請在 [ 目標管理元件 ] 對話方塊中,選取未密封的管理元件來儲存類別自訂,然後按一下 [確定]If you are creating a class from a sealed management pack, in the Target Management Pack dialog box, select an unsealed management pack to store the class customization, and then click OK.

    注意

    如果您是從未密封的管理組件建立類別,則這個類別自訂將會儲存在該選取的管理組件中。If you are creating a class from an unsealed management pack, this class customization is saved in that selected management pack.

  5. 在 [ 建立類別 ] 對話方塊中,指定新類別的內部名稱,然後按一下 [ 建立]。In the Create Class dialog box, specify the internal name for the new class, and then click Create.

    在撰寫窗格中,您現在可以檢視新類別的內容清單。In the authoring pane, you can now view the list of properties of the new class. 如果您建立的是設定項目類別,將會列出設定項目類別的所有內容。If you are creating a configuration item class, all properties of the configuration item class are listed. 如果您建立的是工作項目類別,則會顯示工作項目類別的所有內容。If you are creating a work item class, all properties of the work item class are displayed.

  6. 按一下 [ 建立屬性 ] 或 [ 建立關聯 性],為類別定義新的屬性和新的關聯性。Click Create property or Create relationship to define new properties and new relationships for the class.

若要先選取基底類別To start with a selected base class

  1. 如果在 Authoring Tool 中看不到 管理元件 explorer ,請按一下 [ View],然後按一下 [ management pack explorer]。If the Management Pack Explorer is not visible in the Authoring Tool, click View, and then click Management Pack Explorer.

  2. 在 [ 管理元件瀏覽器] 中,找出並以滑鼠右鍵 - 按一下新類別將繼承屬性和關聯性的基類。In the Management Pack Explorer, locate and then right-click the base class from which the new class will inherit properties and relationships. 選取 [從此 類別繼承]。Select Inherit from this class.

  3. 在 [ 繼承新類別 ] 對話方塊中,輸入類別的內部名稱。In the Inherit New Class dialog box, enter an internal name for the class.

    在 [撰寫中] 窗格中,[ 類別屬性和關聯 性] 清單會顯示基類的屬性。In the authoring pane, the Class properties and relationship list displays the properties of the base class.

  4. 您現在可以按一下 [ 建立屬性 ] 或 [ 建立關聯 性],將屬性或關聯性新增至新的類別。You can now click Create property or Create relationship to add properties or a relationship to the new class.

若要先不選取基底類別To start without a selected base class

  1. 如果在 Authoring Tool 中看不到 管理元件 explorer ,請按一下 [ View],然後按一下 [ management pack explorer]。If the Management Pack Explorer is not visible in the Authoring Tool, click View, and then click Management Pack Explorer.

  2. 在 [ 管理元件瀏覽器] 中,選取 [],然後展開 [任何管理元件]。In the Management Pack Explorer, select and then expand any management pack.

  3. 以滑鼠右鍵 - 按一下 [ 類別],然後按一下 [ 建立其他類別]。Right-click Classes, and then click Create other class.

  4. 在 [ 基類 ] 對話方塊中,選取要從中繼承屬性和關聯性的基類。In the Base class dialog box, select the base class to inherit properties and relationships from.

    (選用) 如果您知道所要使用的基底類別是在哪個管理組件定義,可以篩選對應的管理組件,然後選取用於此自訂的基底類別。Optionally, if you know in which management pack the base class that you want to use is defined, you can filter on the respective management pack, and then select the base class for this customization.

    按一下 [確定]。Click OK.

  5. 如果您選取要從中繼承屬性和關聯性的基類位於密封的管理元件中,請在 [ 目標管理 元件] 對話方塊中,選取未密封的管理元件來儲存類別自訂,然後按一下 [確定]If the base class that you selected to inherit properties and relationships from is in a sealed management pack, in the Target Management Pack dialog box, select an unsealed management pack to store the class customization, and then click OK.

    如果您選取的內容和關聯性繼承來源基底類別包含在未密封的管理組件中,則這個類別自訂將會儲存在該選取的管理組件中。If the base class that you selected to inherit properties and relationships from is in an unsealed management pack, this class customization will be saved in that selected management pack.

  6. 在 [ 建立類別 ] 對話方塊中,指定這個類別的內部名稱,然後按一下 [ 建立]。In the Create class dialog box, specify the internal name for this class, and then click Create.

    在撰寫窗格中,您現在可以檢視新類別的內容清單。In the authoring pane, you can now view the list of properties of the new class. 這份清單包含您所選取之基底類別的所有內容。This list includes all the properties of the base class that you selected.

在 Authoring tool 中擴充類別Extend a class in the Authoring tool

您可以透過將內容和關聯性新增到類別定義的方式,擴充 Service Manager Authoring Tool 中的類別。You can extend a class in the Service Manager Authoring Tool by adding properties and relationships to the definition of the class. 擴充類別會影響該類別的所有現有執行個體:該類別的所有執行個體全都會更新為包含新的內容和關聯性。Extending a class affects all existing instances of that class: all instances of that class will be updated to include the new properties and relationships.

若要擴充類別To extend a class

  1. 如果在 Authoring Tool 中看不到 [ 管理元件瀏覽器 ] 窗格,請按一下 [ View],然後按一下 [ management pack explorer]。If the Management Pack Explorer pane is not visible in the Authoring Tool, click View, and then click Management Pack Explorer.

  2. 在 [ 管理元件瀏覽器 ] 窗格中,找出並以滑鼠右鍵 - 按一下您要擴充的類別,然後按一下 [ 擴充類別]。In the Management Pack Explorer pane, locate and right-click the class that you want to extend, and then click Extend class.

  3. 在 [ 目標管理元件 ] 對話方塊中,選取要儲存類別延伸的未密封管理元件,然後按一下 [確定]In the Target Management Pack dialog box, select an unsealed management pack to store the class extension, and then click OK.

  4. [撰寫中] 窗格中 [類別] 索引標籤的 [類別屬性] 和 [關聯性] 清單會顯示類別的屬性和關聯性。The Class properties and relationship list on the Extension of class tab in the authoring pane displays the properties and the relationships of the class. 請依下列方式建立新的屬性和關聯性:Create new properties and relationships as follows:

    1. 按一下 [ 建立屬性];在 [ 建立屬性 ] 對話方塊的 [ 內部名稱 ] 中,輸入新屬性的名稱;然後按一下 [ 建立]。Click Create property; in the Create property dialog box, type a name in Internal name for the new property; and then click Create.

    2. 按一下 [ 建立關聯性];在 [ 建立關聯 性] 對話方塊的 [ 內部名稱 ] 中,輸入新關聯性的名稱。然後按一下 [ 建立]。Click Create relationship; in the Create relationship dialog box, type a name in Internal name for the new relationship; and then click Create.

    注意

    擴充類別時,請勿使用該類別中已使用的識別碼來定義內容。When you are extending a class, do not define a property with an ID that is already in use in that class.

  5. 在 [ 類別內容和關聯 性] 清單中找出並選取新的屬性或關聯性,然後視需要在 [ 詳細資料 ] 窗格中修改其屬性。Locate and select the new property or relationship in the Class properties and relationship list, and modify its properties in the Details pane as needed.

後續步驟Next steps