Policy 类

The Policy object represents a Policy-Based Management policy. A policy represents the relationship between a target object and a condition.

继承层次结构

System. . :: . .Object
  Microsoft.SqlServer.Management.Sdk.Sfc. . :: . .SfcInstance
    Microsoft.SqlServer.Management.Dmf..::..Policy

命名空间:  Microsoft.SqlServer.Management.Dmf
程序集:  Microsoft.SqlServer.Dmf(在 Microsoft.SqlServer.Dmf.dll 中)

语法

声明
<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey := "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")> _
<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey := "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")> _
Public NotInheritable Class Policy _
    Inherits SfcInstance _
    Implements ISfcCreatable, ICreatable, ISfcDroppable, IDroppable,  _
    ISfcAlterable, IAlterable, ISfcRenamable, IRenamable, ISfcValidate
用法
Dim instance As Policy
[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
public sealed class Policy : SfcInstance, 
    ISfcCreatable, ICreatable, ISfcDroppable, IDroppable, ISfcAlterable, 
    IAlterable, ISfcRenamable, IRenamable, ISfcValidate
[StrongNameIdentityPermissionAttribute(SecurityAction::LinkDemand, PublicKey = L"0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
[StrongNameIdentityPermissionAttribute(SecurityAction::LinkDemand, PublicKey = L"0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
public ref class Policy sealed : public SfcInstance, 
    ISfcCreatable, ICreatable, ISfcDroppable, IDroppable, ISfcAlterable, 
    IAlterable, ISfcRenamable, IRenamable, ISfcValidate
[<SealedAttribute>]
[<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")>]
[<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")>]
type Policy =  
    class
        inherit SfcInstance
        interface ISfcCreatable
        interface ICreatable
        interface ISfcDroppable
        interface IDroppable
        interface ISfcAlterable
        interface IAlterable
        interface ISfcRenamable
        interface IRenamable
        interface ISfcValidate
    end
public final class Policy extends SfcInstance implements ISfcCreatable, ICreatable, ISfcDroppable, IDroppable, ISfcAlterable, IAlterable, ISfcRenamable, IRenamable, ISfcValidate

Policy 类型公开以下成员。

构造函数

  名称 说明
公共方法 Policy() () () () Initializes a new instance of the Policy class.
公共方法 Policy(PolicyStore, String) Initializes a new instance of the Policy class.

页首

属性

  名称 说明
受保护属性 AbstractIdentityKey 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共属性 AutomatedPolicyEvaluationMode Gets or sets the evaluation mode.
公共属性 CategoryId Gets the ID value that uniquely identifies the category that is associated with the policy.
公共属性 Condition Gets or sets the condition.
公共属性 CreateDate Gets the date and time when the policy was created.
公共属性 CreatedBy Gets the policy store authentication credentials of the user who created the policy.
公共属性 DateModified Gets the date and time when the policy was last modified.
公共属性 Description Gets or sets the textual description of the policy.
公共属性 Enabled Gets or set the Boolean value that specifies whether the policy is enabled.
公共属性 EvaluationHistories Gets the evaluation histories collection.
公共属性 HasScript Gets the Boolean value that specifies whether the policy has a script.
公共属性 HelpLink Gets or sets a URN to additional help information for the policy.
公共属性 HelpText Gets or sets the display name for the help text.
公共属性 ID Gets the ID value that uniquely identifies the policy.
公共属性 IdentityKey Gets the key that identifies the policy.
公共属性 IsSystemObject Determines whether the Policy object is a Object.
公共属性 Metadata Returns metadata about the instance and its domain. (从 SfcInstance 继承。)
公共属性 ModifiedBy Gets the policy store authentication credentials of the user who last modified the policy.
公共属性 Name Gets the name of the Policy object.
公共属性 ObjectSet Gets or sets the set of objects that are associated with the policy.
公共属性 Parent Gets or sets the PolicyStore that is the parent of the policy object.
公共属性 PolicyCategory Gets or sets the category that is associated with the policy.
公共属性 Properties Returns a collection instance properties. (从 SfcInstance 继承。)
受保护属性 PropertyStorageProvider 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共属性 RootCondition Gets or sets the name of the root condition for this policy.
公共属性 ScheduleUid Gets or sets the Guid that identifies the SQL Server Agent schedule that checks on the policy.
受保护属性 State Returns the state of the SfcInstance object. (从 SfcInstance 继承。)
公共属性 Urn Returns the uniform resource name of the SfcInstance object. (从 SfcInstance 继承。)

页首

方法

  名称 说明
公共方法 Alter Updates any Policy object property changes on the instance of SQL Server.
受保护方法 AlterImpl 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 CheckObjectCreated 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 CheckObjectState 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 Create Creates management policy item.
受保护方法 CreateIdentityKey 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 CreateImpl 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 Discover Discovers conditions in the ObjectSet and adds them to the ISfcDependencyDiscoveryObjectSink identified by the sink parameter. (覆盖 SfcInstance. . :: . .Discover(ISfcDependencyDiscoveryObjectSink)。)
公共方法 Drop Removes the policy from the instance of SQL Server.
受保护方法 DropImpl 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 Equals (从 Object 继承。)
公共方法 Evaluate(AdHocPolicyEvaluationMode, array<ISfcConnection> [] () [] []) Evaluates the Policy object and applies policy to the data in identified by the targetConnections parameter.
公共方法 Evaluate(AdHocPolicyEvaluationMode, array<Object> [] () [] []) Immediately executes the policy against the specified target objects by using the specified evaluation mode.
公共方法 Evaluate(AdHocPolicyEvaluationMode, SfcQueryExpression, array<ISfcConnection> [] () [] []) Evaluates the Policy object and applies policy to the data in identified by the targetConnections parameter.
受保护方法 Finalize (从 Object 继承。)
受保护方法 GetChildCollection 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 GetDomain 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 GetHashCode (从 Object 继承。)
公共方法静态成员 GetObjectFactory Gets the object factory for the object.
公共方法 GetPropertySet Returns the set of properties for the SfcInstance object. (从 SfcInstance 继承。)
公共方法 GetType (从 Object 继承。)
受保护方法 GetTypeMetadataImpl Indicates the domains that override by returning the right TypeMetadata class directly. 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 InitializeUIPropertyState 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 MarkForDropImpl Returns a value that indicates the existing objects to be dropped. 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 MarkRootAsConnected 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 MemberwiseClone (从 Object 继承。)
受保护方法 MoveImpl Indicates the new parent object to move in an instance. 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 OnPropertyMetadataChanges Invoked whenever the effective value of any SfcInstance metadata is updated. (从 SfcInstance 继承。)
受保护方法 OnPropertyValueChanges Invoked whenever the effective value of any SfcInstance property is updated. (从 SfcInstance 继承。)
受保护方法 PostAlter 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 PostCreate Indicates the default implementor that creates the execution result. 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 PostDrop 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 PostMove 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 PostRename 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 ProduceConfigureScript Gets the condition of a Policy object.
公共方法 Refresh Refreshes the object's properties by reading them from the server. (从 SfcInstance 继承。)
公共方法 Rename Renames the policy.
受保护方法 RenameImpl 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
受保护方法 ResetKey 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 ScriptAlter Alters the script that is used to create the policy.
公共方法 ScriptAlterWithObjectSet Alters a previously created ISfcScript object of the Policy object.
公共方法 ScriptCreate Creates a script that is used to create the policy.
公共方法 ScriptCreateWithDependencies Creates the ISfcScript object of the Policy object.
公共方法 ScriptCreateWithObjectSet Creates the ISfcScript object of the ObjectSet.
公共方法 ScriptDrop Drops the script that is used to create the policy.
公共方法 ScriptDropWithObjectSet Drops the ISfcScript object of the ObjectSet.
公共方法 Serialize Serializes the instance to XML. (从 SfcInstance 继承。)
公共方法 ToString Returns a string representation of the instance Urn. (从 SfcInstance 继承。)
受保护方法 UpdateUIPropertyState 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 UsesFacet Determines whether the facet identified by the parameter is contained by the Condition.
受保护方法 Validate() () () () Indicates the basic child object's validation. 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共方法 Validate(String) Validates a Policy object as specified by the mode parameter.

页首

事件

  名称 说明
公共事件 ConnectionProcessingFinished Represents the event activated when connection processing completes.
公共事件 ConnectionProcessingStarted Represents the event activated when connection processing begins.
公共事件 PolicyEvaluationFinished Represents the event activated when policy evaluation completes.
公共事件 PolicyEvaluationStarted Represents the event activated when policy evaluation begins.
受保护事件 propertyChanged 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共事件 PropertyChanged CLS-compliant event for property changes. (从 SfcInstance 继承。)
受保护事件 propertyMetadataChanged 不要在您的代码中直接引用此成员。它支持 SQL Server 基础结构。 (从 SfcInstance 继承。)
公共事件 PropertyMetadataChanged CLS-compliant event for property metadata changes. (从 SfcInstance 继承。)
公共事件 TargetProcessed Represents the event activated when policy target is processed.

页首

字段

  名称 说明
公共字段静态成员 HelpLinkStringMaxLength Specifies the maximum length of the link to help text.
公共字段静态成员 HelpTextStringMaxLength Specifies the maximum length of the help text.

页首

显式接口实现

  名称 说明
显式接口实现私有方法 ISfcRenamable. . :: . .Rename Renames the instance of Policy identified by the key parameter.
显式接口实现私有方法 ISfcRenamable. . :: . .ScriptRename Renames a script in the policy.
显式接口实现私有方法 ISfcValidate. . :: . .Validate Validates a Policy object.

页首

注释

A policy represents the relationship between an individual object or a target set of objects and a condition.

A target is an entity on an instance of SQL Server. It could be the instance of SQL Server, or a component of it, such as a database or a table.

A condition is a relationship between a facet and a Boolean expression that determine the state of the facet. A facet is a dimension of a target. For example, the target could be an instance of SQL Server, the facet is Database Mail, the expression specifies that it is installed on the instance and the condition is that Database Mail is installed. Thus, the policy is that Database Mail is installed on the specified instance of SQL Server.

The evaluation mode of the policy determines how and when the policy is checked and enforced.

Using the Policy object, you can manage the following characteristics of a policy:

  • Condition

  • Evaluation mode

  • Schedule

  • Target set filter using XPath expression

  • A job on evaluation success

  • A job on evaluation failure

  • A policy group

示例

C#

Policy p = new Policy(ps, policyName);
p.AutomatedPolicyEvaluationMode = execMode;
p.Condition = condition.Name;
p.ScheduleUid = schedule.ScheduleUid;
if (execMode != AutomatedPolicyEvaluationMode.None) p.Enabled = true;
p.Create();

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。不保证所有实例成员都是线程安全的。