private void CreateUserTrackPoint(XmlReader reader, TrackingProfile profile) { if (null == reader) throw new ArgumentNullException("reader"); if (null == profile) throw new ArgumentNullException("profile"); if (0 != string.Compare(reader.Name, "UserTrackPoint", StringComparison.Ordinal)) throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "UserTrackPoint."); if (reader.IsEmptyElement) return; UserTrackPoint point = new UserTrackPoint(); 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)) CreateUserTrackingLocations(reader, point.MatchingLocations); else if (0 == string.Compare(reader.Name, "ExcludedLocations", StringComparison.Ordinal)) CreateUserTrackingLocations(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, "UserTrackPoint", StringComparison.Ordinal)) { profile.UserTrackPoints.Add(point); return; } break; } } // // Only valid exit is on an EndElement that matches the element that is passed in. throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "UserTrackPoint."); }
private void CacheInsert(string qualifiedID, UserTrackPoint point) { List<UserTrackPoint> points = null; if (!_user.TryGetValue(qualifiedID, out points)) { points = new List<UserTrackPoint>(); _user.Add(qualifiedID, points); } points.Add(point); }
private void WriteUserTrackPoint(UserTrackPoint point, XmlTextWriter writer) { // // Validate this element's required fields if ((null == point.MatchingLocations) || (0 == point.MatchingLocations.Count)) throw new ArgumentException(ExecutionStringManager.NoMatchingLocations); writer.WriteStartElement("UserTrackPoint"); writer.WriteStartElement("MatchingLocations"); // // Write the locations that should be matched // At least one non null location is required. int count = 0; foreach (UserTrackingLocation location in point.MatchingLocations) { if (null != location) { WriteUserTrackingLocation(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 (UserTrackingLocation location in point.ExcludedLocations) { if (null != location) WriteUserTrackingLocation(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 CacheInsert(string qualifiedID, UserTrackPoint point) { List<UserTrackPoint> list = null; if (!this._user.TryGetValue(qualifiedID, out list)) { list = new List<UserTrackPoint>(); this._user.Add(qualifiedID, list); } list.Add(point); }
static TrackingProfile GetProfileWithUserTrackPoint() { TrackingProfile trackingProfile = new TrackingProfile(); trackingProfile.Version = new Version("1.0.0"); // Add a TrackPoint to cover all user track points UserTrackPoint userTrackPoint = new UserTrackPoint(); UserTrackingLocation userLocation = new UserTrackingLocation(); userLocation.ActivityType = typeof(Activity); userLocation.MatchDerivedActivityTypes = true; userLocation.ArgumentType = typeof(object); userLocation.MatchDerivedArgumentTypes = true; userTrackPoint.MatchingLocations.Add(userLocation); trackingProfile.UserTrackPoints.Add(userTrackPoint); return trackingProfile; }
private void CreateUserTrackPoint(XmlReader reader, TrackingProfile profile) { if (reader == null) { throw new ArgumentNullException("reader"); } if (profile == null) { throw new ArgumentNullException("profile"); } if (string.Compare(reader.Name, "UserTrackPoint", StringComparison.Ordinal) != 0) { throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "UserTrackPoint."); } if (!reader.IsEmptyElement) { UserTrackPoint item = new UserTrackPoint(); 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.CreateUserTrackingLocations(reader, item.MatchingLocations); break; } if (string.Compare(reader.Name, "ExcludedLocations", StringComparison.Ordinal) == 0) { this.CreateUserTrackingLocations(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, "UserTrackPoint", StringComparison.Ordinal) == 0) { profile.UserTrackPoints.Add(item); return; } } throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "UserTrackPoint."); } }
private void WriteUserTrackPoint(UserTrackPoint point, XmlTextWriter writer) { if ((point.MatchingLocations == null) || (point.MatchingLocations.Count == 0)) { throw new ArgumentException(ExecutionStringManager.NoMatchingLocations); } writer.WriteStartElement("UserTrackPoint"); writer.WriteStartElement("MatchingLocations"); int num = 0; foreach (UserTrackingLocation location in point.MatchingLocations) { if (location != null) { this.WriteUserTrackingLocation(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 (UserTrackingLocation location2 in point.ExcludedLocations) { if (location2 != null) { this.WriteUserTrackingLocation(location2, writer); } } writer.WriteEndElement(); } this.WriteAnnotations(point.Annotations, writer); this.WriteExtracts(point.Extracts, writer); writer.WriteEndElement(); }
// Profile creation private static TrackingProfile GetProfile() { // Create a Tracking Profile that covers all user track points. TrackingProfile profile = new TrackingProfile(); profile.Version = new Version("1.0.0"); // Add a TrackPoint to cover all user track points. // We want to receive user events generated by any Activity, with any argument type. // We could restrict the ActivityType to be PolicyActivity and // ArgumentType to be RuleActionTrackingEvent if we wanted to only get // tracking events from policy execution. UserTrackPoint userTrackPoint = new UserTrackPoint(); UserTrackingLocation 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; }
// Profile creation private static TrackingProfile GetProfile() { // Create a Tracking Profile TrackingProfile profile = new TrackingProfile(); profile.Version = new Version("3.0.0"); // Add a TrackPoint to cover all activity status events ActivityTrackPoint activityTrackPoint = new ActivityTrackPoint(); ActivityTrackingLocation activityLocation = new ActivityTrackingLocation(typeof(Activity)); activityLocation.MatchDerivedTypes = true; WorkflowTrackingLocation wLocation = new WorkflowTrackingLocation(); IEnumerable<ActivityExecutionStatus> 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 WorkflowTrackPoint 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 UserTrackPoint userTrackPoint = new UserTrackPoint(); UserTrackingLocation 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 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); }