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); }
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; }
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 CreateActivityTrackingLocations(XmlReader reader, ActivityTrackingLocationCollection activities) { if (null == reader) throw new ArgumentNullException("reader"); if (null == activities) throw new ArgumentNullException("activities"); if (reader.IsEmptyElement) return; string startName = reader.Name; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (0 == string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal)) { ActivityTrackingLocation location = new ActivityTrackingLocation(); CreateActivityTrackingLocation(reader, location); activities.Add(location); } break; case XmlNodeType.EndElement: if (0 == string.Compare(startName, reader.Name, StringComparison.Ordinal)) return; break; } } // // Only valid exit is on an EndElement that matches the element that is passed in. throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + startName + "."); }
private void CreateActivityTrackingLocation(XmlReader reader, ActivityTrackingLocation location) { if (null == reader) throw new ArgumentNullException("reader"); if (null == location) throw new ArgumentNullException("location"); if (0 != string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal)) throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "ActivityTrackingLocation."); if (reader.IsEmptyElement) return; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (0 == string.Compare(reader.Name, "TypeName", StringComparison.Ordinal)) { if (null != location.ActivityType) throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType); location.ActivityTypeName = reader.ReadString(); } else if (0 == string.Compare(reader.Name, "Type", StringComparison.Ordinal)) { if (null != location.ActivityTypeName) throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType); if (!reader.IsEmptyElement) { // // Schema validation will catch empty elements, just make sure // we don't pass GetType a null or empty string and continue. string type = reader.ReadString(); if ((null != type) && (type.Trim().Length > 0)) location.ActivityType = Type.GetType(type, true); } } else if (0 == string.Compare(reader.Name, "MatchDerivedTypes", StringComparison.Ordinal)) location.MatchDerivedTypes = reader.ReadElementContentAsBoolean(); else if (0 == string.Compare(reader.Name, "ExecutionStatusEvents", StringComparison.Ordinal)) CreateStatusEvents(reader, location.ExecutionStatusEvents); else if (0 == string.Compare(reader.Name, "Conditions", StringComparison.Ordinal)) CreateConditions(reader, location.Conditions); break; case XmlNodeType.EndElement: if (0 == string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal)) { // // If we don't have a type or name create the Activity type to track all activities if ((null == location.ActivityType) && (null == location.ActivityTypeName)) { location.ActivityType = typeof(Activity); location.MatchDerivedTypes = true; } return; } break; } } // // Something bad happened throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "ActivityTrackingLocation."); }
private void WriteActivityTrackingLocation(ActivityTrackingLocation loc, XmlTextWriter writer) { // // Validate this element's required fields if ((null == loc.ActivityType) && ((null == loc.ActivityTypeName) || (0 == loc.ActivityTypeName.Trim().Length))) throw new ArgumentException(ExecutionStringManager.MissingActivityType); writer.WriteStartElement("ActivityTrackingLocation"); writer.WriteStartElement("Activity"); if (null != loc.ActivityType) writer.WriteElementString("Type", loc.ActivityType.AssemblyQualifiedName); else writer.WriteElementString("TypeName", loc.ActivityTypeName); writer.WriteElementString("MatchDerivedTypes", loc.MatchDerivedTypes.ToString().ToLower(CultureInfo.InvariantCulture)); writer.WriteEndElement(); WriteEvents(loc.ExecutionStatusEvents, writer); if ((null != loc.Conditions) && (loc.Conditions.Count > 0)) WriteConditions(loc.Conditions, writer); writer.WriteEndElement(); }
private void WriteActivityTrackingLocation(ActivityTrackingLocation loc, XmlTextWriter writer) { if ((null == loc.ActivityType) && ((loc.ActivityTypeName == null) || (loc.ActivityTypeName.Trim().Length == 0))) { throw new ArgumentException(ExecutionStringManager.MissingActivityType); } writer.WriteStartElement("ActivityTrackingLocation"); writer.WriteStartElement("Activity"); if (null != loc.ActivityType) { writer.WriteElementString("Type", loc.ActivityType.AssemblyQualifiedName); } else { writer.WriteElementString("TypeName", loc.ActivityTypeName); } writer.WriteElementString("MatchDerivedTypes", loc.MatchDerivedTypes.ToString().ToLower(CultureInfo.InvariantCulture)); writer.WriteEndElement(); this.WriteEvents(loc.ExecutionStatusEvents, writer); if ((loc.Conditions != null) && (loc.Conditions.Count > 0)) { this.WriteConditions(loc.Conditions, writer); } writer.WriteEndElement(); }
private void CreateActivityTrackingLocation(XmlReader reader, ActivityTrackingLocation location) { if (reader == null) { throw new ArgumentNullException("reader"); } if (location == null) { throw new ArgumentNullException("location"); } if (string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal) != 0) { throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "ActivityTrackingLocation."); } if (!reader.IsEmptyElement) { while (true) { if (!reader.Read()) { throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "ActivityTrackingLocation."); } switch (reader.NodeType) { case XmlNodeType.Element: if (string.Compare(reader.Name, "TypeName", StringComparison.Ordinal) == 0) { if (null != location.ActivityType) { throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType); } location.ActivityTypeName = reader.ReadString(); break; } if (string.Compare(reader.Name, "Type", StringComparison.Ordinal) == 0) { if (location.ActivityTypeName != null) { throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType); } if (!reader.IsEmptyElement) { string typeName = reader.ReadString(); if ((typeName != null) && (typeName.Trim().Length > 0)) { location.ActivityType = Type.GetType(typeName, true); } } } else if (string.Compare(reader.Name, "MatchDerivedTypes", StringComparison.Ordinal) == 0) { location.MatchDerivedTypes = reader.ReadElementContentAsBoolean(); } else if (string.Compare(reader.Name, "ExecutionStatusEvents", StringComparison.Ordinal) == 0) { this.CreateStatusEvents(reader, location.ExecutionStatusEvents); } else if (string.Compare(reader.Name, "Conditions", StringComparison.Ordinal) == 0) { this.CreateConditions(reader, location.Conditions); } break; case XmlNodeType.EndElement: if (string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal) == 0) { if ((null == location.ActivityType) && (location.ActivityTypeName == null)) { location.ActivityType = typeof(Activity); location.MatchDerivedTypes = true; } return; } break; } } } }
private void CreateActivityTrackingLocations(XmlReader reader, ActivityTrackingLocationCollection activities) { if (reader == null) { throw new ArgumentNullException("reader"); } if (activities == null) { throw new ArgumentNullException("activities"); } if (!reader.IsEmptyElement) { string name = reader.Name; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal) == 0) { ActivityTrackingLocation location = new ActivityTrackingLocation(); this.CreateActivityTrackingLocation(reader, location); activities.Add(location); } break; case XmlNodeType.EndElement: goto Label_006A; } continue; Label_006A: if (string.Compare(name, reader.Name, StringComparison.Ordinal) == 0) { return; } } throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + name + "."); } }
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); }