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); }
protected override bool TryGetProfile(Type workflowType, out TrackingProfile profile) { //Depending on the workflowType, service can return different tracking profiles //In this sample we're returning the same profile for all running types profile = GetProfile(); return true; }
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; }
protected override bool TryReloadProfile(Type workflowType, Guid workflowInstanceId, out TrackingProfile profile) { lock (_lock) { _default = null; } profile = _default; return true; }
protected override bool TryGetProfile(Type workflowType, out TrackingProfile profile) { try { profile = Default; return true; } catch (Exception) { profile = null; return false; } }
private RTTrackingProfile(RTTrackingProfile runtimeProfile) { this._activities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(); this._activitiesIgnore = new List<string>(); this._user = new Dictionary<string, List<UserTrackPoint>>(); this._userIgnore = new List<string>(); this._profile = runtimeProfile._profile; this._isPrivate = runtimeProfile._isPrivate; this._pendingChanges = runtimeProfile._pendingChanges; this._pendingWorkflowChange = runtimeProfile._pendingWorkflowChange; this._workflowType = runtimeProfile._workflowType; this._activities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(runtimeProfile._activities.Count); foreach (KeyValuePair<string, List<ActivityTrackPointCacheItem>> pair in runtimeProfile._activities) { this._activities.Add(pair.Key, runtimeProfile._activities[pair.Key]); } this._activitiesIgnore = new List<string>(runtimeProfile._activitiesIgnore); if (runtimeProfile._dynamicActivities != null) { this._dynamicActivities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(runtimeProfile._dynamicActivities.Count); foreach (KeyValuePair<string, List<ActivityTrackPointCacheItem>> pair2 in runtimeProfile._dynamicActivities) { this._dynamicActivities.Add(pair2.Key, runtimeProfile._dynamicActivities[pair2.Key]); } } if (runtimeProfile._dynamicActivitiesIgnore != null) { this._dynamicActivitiesIgnore = new List<string>(runtimeProfile._dynamicActivitiesIgnore); } this._user = new Dictionary<string, List<UserTrackPoint>>(runtimeProfile._user.Count); foreach (KeyValuePair<string, List<UserTrackPoint>> pair3 in runtimeProfile._user) { this._user.Add(pair3.Key, runtimeProfile._user[pair3.Key]); } this._userIgnore = new List<string>(runtimeProfile._userIgnore); if (runtimeProfile._dynamicUser != null) { this._dynamicUser = new Dictionary<string, List<UserTrackPoint>>(runtimeProfile._dynamicUser.Count); foreach (KeyValuePair<string, List<UserTrackPoint>> pair4 in runtimeProfile._dynamicUser) { this._dynamicUser.Add(pair4.Key, pair4.Value); } } if (runtimeProfile._dynamicUserIgnore != null) { this._dynamicUserIgnore = new List<string>(runtimeProfile._dynamicUserIgnore); } }
internal RTTrackingProfile(TrackingProfile profile, Activity root, Type serviceType) { this._activities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(); this._activitiesIgnore = new List<string>(); this._user = new Dictionary<string, List<UserTrackPoint>>(); this._userIgnore = new List<string>(); if (profile == null) { throw new ArgumentNullException("profile"); } if (root == null) { throw new ArgumentNullException("root"); } if (null == serviceType) { throw new ArgumentNullException("serviceType"); } this._workflowType = root.GetType(); this._serviceType = serviceType; TrackingProfileSerializer serializer = new TrackingProfileSerializer(); StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); StringReader reader = null; TrackingProfile profile2 = null; try { serializer.Serialize(writer, profile); reader = new StringReader(writer.ToString()); profile2 = serializer.Deserialize(reader); } finally { if (reader != null) { reader.Close(); } if (writer != null) { writer.Close(); } } this._profile = profile2; this.CheckAllActivities(root); }
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; }
/// <summary> /// Primary constructor /// </summary> /// <param name="root"></param> /// <param name="workflowType"></param> /// <param name="profile"></param> internal RTTrackingProfile(TrackingProfile profile, Activity root, Type serviceType) { if (null == profile) throw new ArgumentNullException("profile"); if (null == root) throw new ArgumentNullException("root"); if (null == serviceType) throw new ArgumentNullException("serviceType"); _workflowType = root.GetType(); _serviceType = serviceType; // // "Clone" a private copy in case the tracking service holds a reference to // the profile it gave us and attempts to modify it at a later point TrackingProfileSerializer tps = new TrackingProfileSerializer(); StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); StringReader reader = null; TrackingProfile privateProfile = null; try { // // Let exceptions bubble back to the tracking service - // the profile must be valid per the schema. tps.Serialize(writer, profile); reader = new StringReader(writer.ToString()); privateProfile = tps.Deserialize(reader); } finally { if (null != reader) reader.Close(); if (null != writer) writer.Close(); } _profile = privateProfile; CheckAllActivities((Activity)root); }
protected internal abstract bool TryGetProfile(Type workflowType, out TrackingProfile profile);
protected internal abstract bool TryReloadProfile(Type workflowType, Guid workflowInstanceId, out TrackingProfile profile);
static void SerializeTrackingProfileAndWriteToConsole(TrackingProfile trackingProfile) { TrackingProfileSerializer trackingProfileSerializer = new TrackingProfileSerializer(); StringBuilder trackingProfileString = new StringBuilder(); using (StringWriter writer = new StringWriter(trackingProfileString, CultureInfo.InvariantCulture)) { trackingProfileSerializer.Serialize(writer, trackingProfile); Console.WriteLine(writer.ToString()); } }
public TrackingProfile Deserialize(TextReader reader) { TrackingProfile profile = null; this._vArgs = new List<ValidationEventArgs>(); this._vex = false; if (reader == null) { throw new ArgumentNullException("reader"); } NameTable nameTable = new NameTable(); XmlNamespaceManager nsMgr = new XmlNamespaceManager(nameTable); nsMgr.AddNamespace(string.Empty, "http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile"); XmlParserContext inputContext = new XmlParserContext(nameTable, nsMgr, null, XmlSpace.None); XmlReader reader2 = XmlReader.Create(reader, this.GetSchemaReaderSettings(), inputContext); try { profile = new TrackingProfile(); if (!reader2.ReadToDescendant("TrackingProfile")) { this.CheckSchemaErrors(); return null; } string attribute = reader2.GetAttribute("version"); if ((attribute == null) || (attribute.Trim().Length == 0)) { throw new TrackingProfileDeserializationException(ExecutionStringManager.InvalidProfileVersion); } profile.Version = new Version(attribute); if (!reader2.ReadToDescendant("TrackPoints")) { this.CheckSchemaErrors(); return null; } this.CreateTrackPoints(reader2, profile); this.CheckSchemaErrors(); } catch (Exception) { profile = null; throw; } finally { this._vArgs = new List<ValidationEventArgs>(); this._vex = false; reader2.Close(); } return profile; }
private RTTrackingProfile CreateProfile(TrackingProfile profile, Type workflowType, Type serviceType) { return new RTTrackingProfile(profile, this._runtime.GetWorkflowDefinition(workflowType), serviceType); }
static TrackingProfile GetProfileAllWorkflowEvents() { TrackingProfile trackingProfile = new TrackingProfile(); trackingProfile.Version = new Version("1.0.0"); // Add a TrackPoint to cover all user track points WorkflowTrackPoint workflowTrackPoint = new WorkflowTrackPoint(); IEnumerable<TrackingWorkflowEvent> statuses = Enum.GetValues(typeof(TrackingWorkflowEvent)) as IEnumerable<TrackingWorkflowEvent>; foreach (TrackingWorkflowEvent status in statuses) { workflowTrackPoint.MatchingLocation.Events.Add(status); } trackingProfile.WorkflowTrackPoints.Add(workflowTrackPoint); return trackingProfile; }
/// <summary> /// Deserialize TrackingProfile in xml form to a TrackingProfile object. /// </summary> /// <param name="reader">TextReader containing TrackingProfile in xml form</param> /// <param name="profile">TrackingProfile</param> /// <exception cref="">XmlSchemaException</exception> /// <exception cref="">XmlException</exception> /// <exception cref="">ArgumentNullException</exception> /// <exception cref="">ArgumentException</exception> /// <exception cref="">ArgumentOutOfRangeException</exception> /// <exception cref="">FormatException</exception> /// <exception cref="">OverflowException</exception> /// <exception cref="">InvalidOperationException</exception> /// <exception cref="">TrackingProfileDeserializationException</exception> public TrackingProfile Deserialize(TextReader reader) { TrackingProfile profile = null; _vArgs = new List<ValidationEventArgs>(); _vex = false; if (null == reader) throw new ArgumentNullException("reader"); // // Specify that if no namespace is declare the default should be interpreted as ours NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); nsmgr.AddNamespace(String.Empty, _ns); XmlParserContext ctx = new XmlParserContext(nt, nsmgr, null, XmlSpace.None); XmlReader pReader = XmlReader.Create(reader, GetSchemaReaderSettings(), ctx); try { profile = new TrackingProfile(); // // Schema validation will catch if element is missing if (!pReader.ReadToDescendant("TrackingProfile")) { // // Will throw exception with validation errors CheckSchemaErrors(); return null; } string version = pReader.GetAttribute("version"); if ((null == version) || (0 == version.Trim().Length)) throw new TrackingProfileDeserializationException(ExecutionStringManager.InvalidProfileVersion); profile.Version = new Version(version); if (!pReader.ReadToDescendant("TrackPoints")) { // // Will throw exception with validation errors CheckSchemaErrors(); return null; } CreateTrackPoints(pReader, profile); CheckSchemaErrors(); } catch (Exception) { profile = null; throw; } finally { _vArgs = new List<ValidationEventArgs>(); _vex = false; pReader.Close(); } return profile; }
/// <summary> /// Saves a profile for the specified workflow type /// </summary> /// <param name="workflowType"></param> /// <param name="profile"></param> public void SaveProfile(Type workflowType, TrackingProfile profile) { TrackingProfile currentProfile = GetWorkflowProfile(workflowType, false); if (currentProfile != null && currentProfile.Version >= profile.Version) { //If there already exists a profile (with a later version) //for this workflow, prompt the user to rev the version. UpdateProfileVersion updateVersionForm = new UpdateProfileVersion(); updateVersionForm.CurrentTrackingProfile = currentProfile; updateVersionForm.NewTrackingProfile = profile; updateVersionForm.WorkflowType = workflowType; DialogResult result = updateVersionForm.ShowDialog(); if (result != DialogResult.OK) return; } try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { using (SqlCommand command = new SqlCommand()) { command.CommandText = "[dbo].[UpdateTrackingProfile]"; command.CommandType = CommandType.StoredProcedure; command.Connection = connection; SqlParameter typeFullName = new SqlParameter("@TypeFullName", workflowType.FullName); SqlParameter assemblyFullName = new SqlParameter("@AssemblyFullName", workflowType.Assembly.FullName); command.Parameters.Add(typeFullName); command.Parameters.Add(assemblyFullName); SqlParameter version = new SqlParameter("@Version", profile.Version.ToString()); SqlParameter serializedProfile = new SqlParameter("@TrackingProfileXml", new TrackingProfileManager(profile).SerializeProfile()); command.Parameters.Add(version); command.Parameters.Add(serializedProfile); connection.Open(); command.ExecuteNonQuery(); MessageBox.Show("Save successful!", "Success"); } } } catch (SqlException ex) { MessageBox.Show(string.Format("Error saving profile: {0}", ex.Message), "Error"); } }
public ProfileUpdatedEventArgs(Type workflowType, TrackingProfile profile) { _workflowType = workflowType; _profile = profile; }
private void CreateTrackPoints(XmlReader reader, TrackingProfile profile) { if (null == reader) throw new ArgumentNullException("reader"); if (null == profile) throw new ArgumentNullException("profile"); if (0 != string.Compare(reader.Name, "TrackPoints", StringComparison.Ordinal)) throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "TrackPoints."); if (reader.IsEmptyElement) return; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (0 == string.Compare(reader.Name, "ActivityTrackPoint", StringComparison.Ordinal)) CreateActivityTrackPoint(reader, profile); else if (0 == string.Compare(reader.Name, "UserTrackPoint", StringComparison.Ordinal)) CreateUserTrackPoint(reader, profile); else if (0 == string.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal)) CreateWorkflowTrackPoint(reader, profile); break; case XmlNodeType.EndElement: if (0 == string.Compare(reader.Name, "TrackPoints", StringComparison.Ordinal)) return; break; } } // // Only valid exit is on an EndElement that matches the element that is passed in. throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "TrackPoints."); }
private RTTrackingProfile CreateProfile(TrackingProfile profile, Activity schedule, Type serviceType) { return new RTTrackingProfile(profile, schedule, serviceType); }
/// <summary> /// Constructor used for cloning. /// </summary> /// <param name="runtimeProfile">RTTrackingProfile to clone</param> /// <remarks>All members are shallow copied! Use MakePrivate to deep copy after cloning.</remarks> private RTTrackingProfile(RTTrackingProfile runtimeProfile) { // // Shallow copy _profile = runtimeProfile._profile; _isPrivate = runtimeProfile._isPrivate; _pendingChanges = runtimeProfile._pendingChanges; _pendingWorkflowChange = runtimeProfile._pendingWorkflowChange; _workflowType = runtimeProfile._workflowType; // // Deep copy the cache. Items in the cache can // be shared but the cache themselves cannot as they may be modified // // Activity match and ignore cache _activities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(runtimeProfile._activities.Count); foreach (KeyValuePair<string, List<ActivityTrackPointCacheItem>> kvp in runtimeProfile._activities) _activities.Add(kvp.Key, runtimeProfile._activities[kvp.Key]); _activitiesIgnore = new List<string>(runtimeProfile._activitiesIgnore); // // Pending dynamic update activity match and ignore cache if (null != runtimeProfile._dynamicActivities) { _dynamicActivities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(runtimeProfile._dynamicActivities.Count); foreach (KeyValuePair<string, List<ActivityTrackPointCacheItem>> kvp in runtimeProfile._dynamicActivities) _dynamicActivities.Add(kvp.Key, runtimeProfile._dynamicActivities[kvp.Key]); } if (null != runtimeProfile._dynamicActivitiesIgnore) _dynamicActivitiesIgnore = new List<string>(runtimeProfile._dynamicActivitiesIgnore); // // User event match and ignore cache _user = new Dictionary<string, List<UserTrackPoint>>(runtimeProfile._user.Count); foreach (KeyValuePair<string, List<UserTrackPoint>> kvp in runtimeProfile._user) _user.Add(kvp.Key, runtimeProfile._user[kvp.Key]); _userIgnore = new List<string>(runtimeProfile._userIgnore); // // Pending dynamic update activity match and ignore cache if (null != runtimeProfile._dynamicUser) { _dynamicUser = new Dictionary<string, List<UserTrackPoint>>(runtimeProfile._dynamicUser.Count); foreach (KeyValuePair<string, List<UserTrackPoint>> kvp in runtimeProfile._dynamicUser) _dynamicUser.Add(kvp.Key, kvp.Value); } if (null != runtimeProfile._dynamicUserIgnore) _dynamicUserIgnore = new List<string>(runtimeProfile._dynamicUserIgnore); }
private void Write(TrackingProfile profile, XmlTextWriter writer) { writer.WriteStartDocument(true); writer.WriteStartElement("TrackingProfile"); // Write the namespace declaration. writer.WriteAttributeString("xmlns", _ns); if (null == profile.Version) throw new ArgumentException(ExecutionStringManager.InvalidProfileVersion); string version = null; if (profile.Version.Revision >= 0) version = string.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}.{2}.{3}", profile.Version.Major, profile.Version.Minor, profile.Version.Build, profile.Version.Revision); else if (profile.Version.Build >= 0) version = string.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}.{2}", profile.Version.Major, profile.Version.Minor, profile.Version.Build); else if (profile.Version.Minor >= 0) version = string.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}", profile.Version.Major, profile.Version.Minor); writer.WriteAttributeString("version", version); WriteTrackPoints(profile, writer); writer.WriteEndElement(); writer.WriteEndDocument(); }
private void Write(TrackingProfile profile, XmlTextWriter writer) { writer.WriteStartDocument(true); writer.WriteStartElement("TrackingProfile"); writer.WriteAttributeString("xmlns", "http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile"); if (null == profile.Version) { throw new ArgumentException(ExecutionStringManager.InvalidProfileVersion); } string str = null; if (profile.Version.Revision >= 0) { str = string.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}.{2}.{3}", new object[] { profile.Version.Major, profile.Version.Minor, profile.Version.Build, profile.Version.Revision }); } else if (profile.Version.Build >= 0) { str = string.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}.{2}", new object[] { profile.Version.Major, profile.Version.Minor, profile.Version.Build }); } else if (profile.Version.Minor >= 0) { str = string.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}", new object[] { profile.Version.Major, profile.Version.Minor }); } writer.WriteAttributeString("version", str); this.WriteTrackPoints(profile, writer); writer.WriteEndElement(); writer.WriteEndDocument(); }
/// <summary> /// Loads a workflow and profile from the SQL Tracking Database, using the LoadFromStore winform. /// </summary> /// <param name="workflowType"></param> /// <param name="profile"></param> public void LoadWorkflowAndProfile(out Type workflowType, out TrackingProfile profile) { LoadFromStore loadFromStoreForm = new LoadFromStore(); loadFromStoreForm.WorkflowProfiles = GetWorkflowAndProfiles(); DialogResult result = loadFromStoreForm.ShowDialog(); if (result == DialogResult.OK) { workflowType = loadFromStoreForm.SelectedWorkflow; if (workflowType != null) { profile = GetWorkflowProfile(workflowType, loadFromStoreForm.SelectedProfileVersion, true); } else { profile = null; } } else { workflowType = null; profile = null; return; } }
private void CreateWorkflowTrackPoint(XmlReader reader, TrackingProfile profile) { if (null == reader) throw new ArgumentNullException("reader"); if (null == profile) throw new ArgumentNullException("profile"); if (0 != string.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal)) throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "WorkflowTrackPoint."); if (reader.IsEmptyElement) return; WorkflowTrackPoint point = new WorkflowTrackPoint(); point.MatchingLocation = new WorkflowTrackingLocation(); 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, "TrackingWorkflowEvent", StringComparison.Ordinal)) point.MatchingLocation.Events.Add((TrackingWorkflowEvent)Enum.Parse(typeof(TrackingWorkflowEvent), reader.ReadString())); // // Xsd validation will catch unknown elements break; case XmlNodeType.EndElement: if (0 == string.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal)) { profile.WorkflowTrackPoints.Add(point); return; } break; } } // // Only valid exit is on an EndElement that matches the element that is passed in. throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "WorkflowTrackPoint."); }
public void Serialize(TextWriter writer, TrackingProfile profile) { if (profile == null) { throw new ArgumentNullException("profile"); } if (writer == null) { throw new ArgumentNullException("writer"); } XmlTextWriter writer2 = new XmlTextWriter(writer); this.InitWriter(writer2); this.Write(profile, writer2); writer2.Flush(); writer2.Close(); }
/// <summary> /// Xml serialize a TrackingProfile. /// </summary> /// <param name="profile">TrackingProfile to serialize.</param> /// <param name="writer">TextWriter to store xml text.</param> public void Serialize(TextWriter writer, TrackingProfile profile) { if (null == profile) throw new ArgumentNullException("profile"); if (null == writer) throw new ArgumentNullException("writer"); XmlTextWriter xmlWriter = new XmlTextWriter(writer); InitWriter(xmlWriter); Write(profile, xmlWriter); xmlWriter.Flush(); xmlWriter.Close(); }
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 WriteTrackPoints(TrackingProfile profile, XmlTextWriter writer) { // // We must have at least 1 trackpoint or the profile won't be valid if (((null == profile.WorkflowTrackPoints) || (0 == profile.WorkflowTrackPoints.Count)) && ((null == profile.ActivityTrackPoints) || (0 == profile.ActivityTrackPoints.Count)) && ((null == profile.UserTrackPoints) || (0 == profile.UserTrackPoints.Count))) throw new ArgumentException(ExecutionStringManager.TrackingSerializationNoTrackPoints); int count = 0; writer.WriteStartElement("TrackPoints"); foreach (WorkflowTrackPoint point in profile.WorkflowTrackPoints) { if (null != point) { WriteWorkflowTrackPoint(point, writer); count++; } } foreach (ActivityTrackPoint point in profile.ActivityTrackPoints) { if (null != point) { WriteActivityTrackPoint(point, writer); count++; } } foreach (UserTrackPoint point in profile.UserTrackPoints) { if (null != point) { WriteUserTrackPoint(point, writer); count++; } } // // We must have at least 1 trackpoint or the profile isn't valid if (0 == count) throw new ArgumentException(ExecutionStringManager.TrackingSerializationNoTrackPoints); writer.WriteEndElement(); }