예제 #1
0
        /// <summary>
        /// Add a custom tracking profile for this workflow
        /// </summary>
        private static void AddCustomTrackingProfile()
        {
            //get the default profile for the workflow
            TrackingProfileHelper helper
                = new TrackingProfileHelper(_connStringTracking);
            TrackingProfile profile = helper.RetrieveProfile(
                typeof(SharedWorkflows.TrackingRulesWorkflow));

            if (profile != null)
            {
                //add an activity track point that captures workflow
                //field values prior to the RuleSet execution
                ActivityTrackingLocation location = new ActivityTrackingLocation();
                location.ActivityTypeName = "PolicyActivity";
                location.ExecutionStatusEvents.Add(
                    ActivityExecutionStatus.Executing);
                ActivityTrackPoint point = new ActivityTrackPoint();
                point.Extracts.Add(new WorkflowDataTrackingExtract("field1"));
                point.Extracts.Add(new WorkflowDataTrackingExtract("field2"));
                point.Extracts.Add(new WorkflowDataTrackingExtract("field3"));
                point.Annotations.Add("Before RuleSet execution");
                point.MatchingLocations.Add(location);
                profile.ActivityTrackPoints.Add(point);

                //extract values for the same fields after RuleSet execution
                location = new ActivityTrackingLocation();
                location.ActivityTypeName = "PolicyActivity";
                location.ExecutionStatusEvents.Add(ActivityExecutionStatus.Closed);
                point = new ActivityTrackPoint();
                point.Extracts.Add(new WorkflowDataTrackingExtract("field1"));
                point.Extracts.Add(new WorkflowDataTrackingExtract("field2"));
                point.Extracts.Add(new WorkflowDataTrackingExtract("field3"));
                point.Annotations.Add("After RuleSet execution");
                point.MatchingLocations.Add(location);
                profile.ActivityTrackPoints.Add(point);

                //assign a new version that +1 greater than the last
                profile.Version = new Version(
                    profile.Version.Major, profile.Version.Minor + 1, 0);
                //apply the update to the tracking profile
                helper.UpdateProfile(
                    profile, typeof(SharedWorkflows.TrackingRulesWorkflow));
            }
        }