Пример #1
0
        internal static void CreateAndInsertTrackingProfile()
        {
            TrackingProfile profile = new TrackingProfile();

            ActivityTrackPoint activityTrack = new ActivityTrackPoint();
            ActivityTrackingLocation activityLocation = new ActivityTrackingLocation(typeof(Activity));
            activityLocation.MatchDerivedTypes = true;
            IEnumerable<ActivityExecutionStatus> statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable<ActivityExecutionStatus>;
            foreach (ActivityExecutionStatus status in statuses)
            {
                activityLocation.ExecutionStatusEvents.Add(status);
            }

            activityTrack.MatchingLocations.Add(activityLocation);
            profile.ActivityTrackPoints.Add(activityTrack);
            profile.Version = version;

            WorkflowTrackPoint workflowTrack = new WorkflowTrackPoint();
            WorkflowTrackingLocation workflowLocation = new WorkflowTrackingLocation();
            IEnumerable<TrackingWorkflowEvent> eventStatuses = Enum.GetValues(typeof(TrackingWorkflowEvent)) as IEnumerable<TrackingWorkflowEvent>;
            foreach (TrackingWorkflowEvent status in eventStatuses)
            {
                workflowLocation.Events.Add(status);
            }

            workflowTrack.MatchingLocation = workflowLocation;
            profile.WorkflowTrackPoints.Add(workflowTrack);

            TrackingProfileSerializer serializer = new TrackingProfileSerializer();
            StringWriter writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
            serializer.Serialize(writer, profile);
            String trackingprofile = writer.ToString();
            InsertTrackingProfile(trackingprofile);
        }
Пример #2
0
        static TrackingProfile GetProfileWithWorkflowDataExtract()
        {
            //Create Tracking Profile
            TrackingProfile trackingProfile = new TrackingProfile();
            trackingProfile.Version = new Version("1.0.0");

            //Create Activity Track Point
            ActivityTrackPoint activityTrackPoint = new ActivityTrackPoint();

            //Create matchingActivityTrackingLocation 
            ActivityTrackingLocation matchingActivityTrackingLocation = new ActivityTrackingLocation();
            //Set ActivityName = "activityName"
            matchingActivityTrackingLocation.ActivityTypeName = "activityName";
            //Add all possible ActivityExecutionStatus to the matchingActivityTrackingLocation Events
            IEnumerable<ActivityExecutionStatus> statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable<ActivityExecutionStatus>;
            foreach (ActivityExecutionStatus status in statuses)
            {
                matchingActivityTrackingLocation.ExecutionStatusEvents.Add(status);
            }

            //Create matchingActivityTrackingCondition where memberName = memberValue
            ActivityTrackingCondition matchingActivityTrackingCondition = new ActivityTrackingCondition("memberName", "memberValue");
            matchingActivityTrackingCondition.Operator = ComparisonOperator.Equals;

            //Add matchingActivityTrackingCondition to activityTrackingLocation
            matchingActivityTrackingLocation.Conditions.Add(matchingActivityTrackingCondition);

            //Add matchingActivityTrackingCondition to the matching locations for activityTrackPoint
            activityTrackPoint.MatchingLocations.Add(matchingActivityTrackingLocation);

            //Create excludedActivityTrackingLocation 
            ActivityTrackingLocation excludedActivityTrackingLocation = new ActivityTrackingLocation();
            //Set ActivityName = "activityName"
            excludedActivityTrackingLocation.ActivityTypeName = "activityName";
            //Add Compensating ActivityExecutionStatus to the excludedActivityTrackingLocation Events
            excludedActivityTrackingLocation.ExecutionStatusEvents.Add(ActivityExecutionStatus.Compensating);

            //Add excludedActivityTrackingCondition to the excluded locations for activityTrackPoint
            activityTrackPoint.ExcludedLocations.Add(excludedActivityTrackingLocation);

            //Create workflowDataTrackingExtract to extract Workflow data "Name"
            WorkflowDataTrackingExtract workflowDataTrackingExtract = new WorkflowDataTrackingExtract();
            workflowDataTrackingExtract.Member = "Name";

            //Add workflowDataTrackingExtract to activityTrackPoint
            activityTrackPoint.Extracts.Add(workflowDataTrackingExtract);

            //Annotate activityTrackPoint with 
            activityTrackPoint.Annotations.Add("Track Point Annotations");

            //Add ActivityTrackPoints to trackingProfile 
            trackingProfile.ActivityTrackPoints.Add(activityTrackPoint);

            return trackingProfile;
        }
Пример #3
0
        private static void CreateAndInsertTrackingProfile()
        {
            TrackingProfile profile = new TrackingProfile();

            // Create an activity track point, used for tracking data from Code Activities.
            ActivityTrackPoint codeActivityTrackPoint = new ActivityTrackPoint();

            // Create an ActivityTrackingLocation to be added to the track point.
            ActivityTrackingLocation codeActivityTrackingLocation = new ActivityTrackingLocation("CodeActivity");
            codeActivityTrackingLocation.MatchDerivedTypes = true;
            // Add the location "Closed" event to track.
            codeActivityTrackingLocation.ExecutionStatusEvents.Add(ActivityExecutionStatus.Closed);
            codeActivityTrackPoint.MatchingLocations.Add(codeActivityTrackingLocation);

            // Create a WorkflowDataTrackingExtract for extracting data from the Balance property. 
            WorkflowDataTrackingExtract balanceWorkflowTrackingExtract = new WorkflowDataTrackingExtract();
            balanceWorkflowTrackingExtract.Member = "Balance";

            // Create an activity track point, used for tracking data in the custom activity "ServiceCharge".
            ActivityTrackPoint customActivityTrackPoint = new ActivityTrackPoint();
            ActivityTrackingLocation customActivityTrackingLocation = new ActivityTrackingLocation("ServiceCharge");
            // Create an ActivityTrackingLocation to be added to the track point
            customActivityTrackingLocation.ExecutionStatusEvents.Add(ActivityExecutionStatus.Closed);
            customActivityTrackPoint.MatchingLocations.Add(customActivityTrackingLocation);

            // Create an ActivityDataTrackingExtract for extracting Fee property data from the ServiceCharge activity.
            ActivityDataTrackingExtract feeActivityTrackingExtract = new ActivityDataTrackingExtract();
            feeActivityTrackingExtract.Member = "Fee";
            
            // Add extracts to the activity tracking points.
            codeActivityTrackPoint.Extracts.Add(balanceWorkflowTrackingExtract);
            customActivityTrackPoint.Extracts.Add(feeActivityTrackingExtract);

            profile.ActivityTrackPoints.Add(codeActivityTrackPoint);
            profile.ActivityTrackPoints.Add(customActivityTrackPoint);
            profile.Version = new Version("3.0.0.0");

            // Serialize the profile.
            TrackingProfileSerializer serializer = new TrackingProfileSerializer();
            StringWriter writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
            serializer.Serialize(writer, profile);
            String trackingprofile = writer.ToString();
            InsertTrackingProfile(trackingprofile);
        }
        // Profile creation
        private static TrackingProfile GetProfile()
        {
            // Create a Tracking Profile
            var profile = new TrackingProfile();
            profile.Version = new Version("3.0.0");

            // Add a TrackPoint to cover all activity status events
            var activityTrackPoint = new ActivityTrackPoint();
            var activityLocation = new ActivityTrackingLocation(typeof(Activity));
            activityLocation.MatchDerivedTypes = true;
            var wLocation = new WorkflowTrackingLocation();

            var statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable<ActivityExecutionStatus>;
            foreach (ActivityExecutionStatus status in statuses)
            {
                activityLocation.ExecutionStatusEvents.Add(status);
            }

            activityTrackPoint.MatchingLocations.Add(activityLocation);
            profile.ActivityTrackPoints.Add(activityTrackPoint);

            // Add a TrackPoint to cover all workflow status events
            var workflowTrackPoint = new WorkflowTrackPoint();
            workflowTrackPoint.MatchingLocation = new WorkflowTrackingLocation();
            foreach (TrackingWorkflowEvent workflowEvent in Enum.GetValues(typeof(TrackingWorkflowEvent)))
            {
                workflowTrackPoint.MatchingLocation.Events.Add(workflowEvent);
            }
            profile.WorkflowTrackPoints.Add(workflowTrackPoint);

            // Add a TrackPoint to cover all user track points
            var userTrackPoint = new UserTrackPoint();
            var userLocation = new UserTrackingLocation();
            userLocation.ActivityType = typeof(Activity);
            userLocation.MatchDerivedActivityTypes = true;
            userLocation.ArgumentType = typeof(object);
            userLocation.MatchDerivedArgumentTypes = true;
            userTrackPoint.MatchingLocations.Add(userLocation);
            profile.UserTrackPoints.Add(userTrackPoint);

            return profile;
        }
        private void WriteActivityTrackPoint(ActivityTrackPoint point, XmlTextWriter writer)
        {
            if (null == point)
                throw new ArgumentNullException("point");
            //
            // Validate this element's required fields
            if ((null == point.MatchingLocations) || (0 == point.MatchingLocations.Count))
                throw new ArgumentException(ExecutionStringManager.NoMatchingLocations);

            writer.WriteStartElement("ActivityTrackPoint");

            writer.WriteStartElement("MatchingLocations");
            //
            // Write the locations that should be matched
            // At least one non null location is required.
            int count = 0;
            foreach (ActivityTrackingLocation location in point.MatchingLocations)
            {
                if (null != location)
                {
                    WriteActivityTrackingLocation(location, writer);
                    count++;
                }
            }

            if (0 == count)
                throw new ArgumentException(ExecutionStringManager.NoMatchingLocations);

            writer.WriteEndElement();
            //
            // Write the locations that should not be matched (these override the locations to match)
            // Excludes are not required.
            if ((null != point.ExcludedLocations) && (point.ExcludedLocations.Count > 0))
            {
                writer.WriteStartElement("ExcludedLocations");

                foreach (ActivityTrackingLocation location in point.ExcludedLocations)
                {
                    if (null != location)
                        WriteActivityTrackingLocation(location, writer);
                }

                writer.WriteEndElement();
            }
            //
            // Write annotations, not a required field
            WriteAnnotations(point.Annotations, writer);
            //
            // Write extracts, not a required field
            WriteExtracts(point.Extracts, writer);

            writer.WriteEndElement();
        }
        private void CreateActivityTrackPoint(XmlReader reader, TrackingProfile profile)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == profile)
                throw new ArgumentNullException("profile");

            if (0 != string.Compare(reader.Name, "ActivityTrackPoint", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "ActivityTrackPoint.");

            if (reader.IsEmptyElement)
                return;

            ActivityTrackPoint point = new ActivityTrackPoint();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                            CreateAnnotations(reader, point.Annotations);
                        else if (0 == string.Compare(reader.Name, "MatchingLocations", StringComparison.Ordinal))
                            CreateActivityTrackingLocations(reader, point.MatchingLocations);
                        else if (0 == string.Compare(reader.Name, "ExcludedLocations", StringComparison.Ordinal))
                            CreateActivityTrackingLocations(reader, point.ExcludedLocations);
                        else if (0 == string.Compare(reader.Name, "Extracts", StringComparison.Ordinal))
                            CreateExtracts(reader, point.Extracts);
                        //
                        // Xsd validation will catch unknown elements

                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "ActivityTrackPoint", StringComparison.Ordinal))
                        {
                            profile.ActivityTrackPoints.Add(point);
                            return;
                        }
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "ActivityTrackPoint.");
        }
            internal ActivityTrackPointCacheItem(ActivityTrackPoint point, List<ActivityExecutionStatus> events, bool hasConditions)
            {
                if (null == point)
                    throw new ArgumentNullException("point");
                if (null == events)
                    throw new ArgumentNullException("events");

                Point = point;
                Events = events;
                HasLocationConditions = hasConditions;
            }
 internal ActivityTrackPointCacheItem(ActivityTrackPoint point, List<ActivityExecutionStatus> events, bool hasConditions)
 {
     if (point == null)
     {
         throw new ArgumentNullException("point");
     }
     if (events == null)
     {
         throw new ArgumentNullException("events");
     }
     this.Point = point;
     this.Events = events;
     this.HasLocationConditions = hasConditions;
 }
        private void CreateActivityTrackPoint(XmlReader reader, TrackingProfile profile)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }
            if (string.Compare(reader.Name, "ActivityTrackPoint", StringComparison.Ordinal) != 0)
            {
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "ActivityTrackPoint.");
            }
            if (!reader.IsEmptyElement)
            {
                ActivityTrackPoint item = new ActivityTrackPoint();
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            if (string.Compare(reader.Name, "Annotations", StringComparison.Ordinal) == 0)
                            {
                                this.CreateAnnotations(reader, item.Annotations);
                                break;
                            }
                            if (string.Compare(reader.Name, "MatchingLocations", StringComparison.Ordinal) == 0)
                            {
                                this.CreateActivityTrackingLocations(reader, item.MatchingLocations);
                                break;
                            }
                            if (string.Compare(reader.Name, "ExcludedLocations", StringComparison.Ordinal) == 0)
                            {
                                this.CreateActivityTrackingLocations(reader, item.ExcludedLocations);
                            }
                            else if (string.Compare(reader.Name, "Extracts", StringComparison.Ordinal) == 0)
                            {
                                this.CreateExtracts(reader, item.Extracts);
                            }
                            break;

                        case XmlNodeType.EndElement:
                            goto Label_00FB;
                    }
                    continue;
                Label_00FB:
                    if (string.Compare(reader.Name, "ActivityTrackPoint", StringComparison.Ordinal) == 0)
                    {
                        profile.ActivityTrackPoints.Add(item);
                        return;
                    }
                }
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "ActivityTrackPoint.");
            }
        }
 private void WriteActivityTrackPoint(ActivityTrackPoint point, XmlTextWriter writer)
 {
     if (point == null)
     {
         throw new ArgumentNullException("point");
     }
     if ((point.MatchingLocations == null) || (point.MatchingLocations.Count == 0))
     {
         throw new ArgumentException(ExecutionStringManager.NoMatchingLocations);
     }
     writer.WriteStartElement("ActivityTrackPoint");
     writer.WriteStartElement("MatchingLocations");
     int num = 0;
     foreach (ActivityTrackingLocation location in point.MatchingLocations)
     {
         if (location != null)
         {
             this.WriteActivityTrackingLocation(location, writer);
             num++;
         }
     }
     if (num == 0)
     {
         throw new ArgumentException(ExecutionStringManager.NoMatchingLocations);
     }
     writer.WriteEndElement();
     if ((point.ExcludedLocations != null) && (point.ExcludedLocations.Count > 0))
     {
         writer.WriteStartElement("ExcludedLocations");
         foreach (ActivityTrackingLocation location2 in point.ExcludedLocations)
         {
             if (location2 != null)
             {
                 this.WriteActivityTrackingLocation(location2, writer);
             }
         }
         writer.WriteEndElement();
     }
     this.WriteAnnotations(point.Annotations, writer);
     this.WriteExtracts(point.Extracts, writer);
     writer.WriteEndElement();
 }
Пример #11
0
 /// <summary>
 /// Toggles (removes or adds) a trackpoint for a given activity
 /// </summary>
 /// <param name="activity"></param>
 public void ToggleActivityTrackPoint(Activity activity)
 {
     ActivityTrackPoint trackPoint = GetTrackPointForActivity(activity);
     //If a trackpoint is tracking this activity type, remove it
     if (trackPoint != null)
     {
         TrackingProfile.ActivityTrackPoints.Remove(trackPoint);
     }
     //Otherwise, add a new one
     else
     {
         trackPoint = new ActivityTrackPoint();
         trackPoint.MatchingLocations.Add(new ActivityTrackingLocation(activity.GetType()));
         TrackingProfile.ActivityTrackPoints.Add(trackPoint);
     }
 }
Пример #12
0
        private static void CreateAndInsertTrackingProfile()
        {
            TrackingProfile profile = new TrackingProfile();

            ActivityTrackPoint trackPoint = new ActivityTrackPoint();
            ActivityTrackingLocation location = new ActivityTrackingLocation(typeof(Activity));
            location.MatchDerivedTypes = true;

            IEnumerable<ActivityExecutionStatus> statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable<ActivityExecutionStatus>;
            foreach (ActivityExecutionStatus status in statuses)
            {
                location.ExecutionStatusEvents.Add(status);
            }

            trackPoint.MatchingLocations.Add(location);
            profile.ActivityTrackPoints.Add(trackPoint);
            profile.Version = new Version("3.0.0.0");

            
            // Adding a user track point to the tracking profile
            UserTrackPoint utp = new UserTrackPoint();
            
            // Adding a user location to the track point 
            UserTrackingLocation ul = new UserTrackingLocation(typeof(string), typeof(CodeActivity));
            ul.MatchDerivedActivityTypes = true;
            utp.MatchingLocations.Add(ul);
            profile.UserTrackPoints.Add(utp);
            
            
            // Serialize the profile
            TrackingProfileSerializer serializer = new TrackingProfileSerializer();
            StringWriter writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
            serializer.Serialize(writer, profile);
            string trackingprofile = writer.ToString();
            InsertTrackingProfile(trackingprofile);
        }