[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Management pack monitoring enables objects to be processed through custom logic and workflow. This provides your solution with a powerful way of creating the logic features of your management pack. The two components of the subscription system are the criteria and the action. When the subscription criteria have been matched, the action component of the subscription will execute.

To create a Windows workflow subscription

  1. Find the RePackaging.Library management pack.

  2. Create an instance of the subscription criteria, the InstanceTypeSubscription class, providing the management pack class identifier for the RePackaging.Request class.

  3. Create an instance of the subscription action, the WorkflowSubscription class, providing the previously created subscription criteria.

  4. Add parameters to the workflow subscription action.

  5. Use the management group to insert the new subscription action, linking it to the management pack class.

  6. Accept the changes to the management pack.

The following example uses the InstanceTypeSubscription criteria to trigger when a new RePackaging.Request object is created. The InstanceTypeSubscription class can also be used to trigger when the object was created, updated, or deleted.

C#  Copy Code
string managementPackName = "RePackaging.Library";
string managementClassName = "RePackaging.Request";

ManagementPackCriteria searchCrit = new ManagementPackCriteria("$Name='" + managementPackName + "'$");
foreach (var mp in mg.ManagementPacks.GetManagementPacks(searchCrit))
	InstanceTypeSubscription subCriteria = new InstanceTypeSubscription(OperationType.Add, mp.GetClass(managementClassName).Id, "");
	subCriteria.BatchSize = 100;
	subCriteria.PollingIntervalInSeconds = 60;

	WorkflowSubscription subAction = new WorkflowSubscription("WF_AcceptPackageRequest", "Accepts the package request.", subCriteria);
	subAction.AssemblyName = "WorkflowPackageRequest";
	subAction.WorkflowTypeName = "WorkflowPackageRequest.PackageInitial";
	subAction.Enabled = true;
	subAction.Parameters.Add(new KeyValuePair<string, IWorkflowParameterValueBase>("InternalID", new WorkflowParameterValue(WorkflowParameterType.GuidType, "$Data/BaseManagedEntityId$")));
	subAction.Parameters.Add(new KeyValuePair<string, IWorkflowParameterValueBase>("ClassGUID", new WorkflowParameterValue(WorkflowParameterType.GuidType, "$MPElement[Name='RePackaging.Request']$")));

	mg.Subscription.InsertSubscription(mp.Id, subAction);