private void WriteUserTrackingRecord(UserTrackingRecord userTrackingRecord) { var message = GetTitle("User Activity Record"); message += string.Format("EventDateTime: {0}\r\n" , userTrackingRecord.EventDateTime); message += string.Format("QualifiedName: {0}\r\n", userTrackingRecord.QualifiedName); message += string.Format("ActivityType: {0}\r\n", userTrackingRecord.ActivityType.FullName); message += string.Format("Args: {0}\r\n", userTrackingRecord.UserData); if (userTrackingRecord.UserDataKey != null) { switch (userTrackingRecord.UserDataKey.ToLower()) { case "error": case "fatal": if (userTrackingRecord.UserData is Exception) { message += "\r\n"; message += ((Exception)userTrackingRecord.UserData).ToString(); m_Logger.Error(userTrackingRecord.UserData as Exception); } m_Logger.Error(message); break; case "notification": m_Logger.Notification(message); break; default: m_Logger.Debug(message); break; } } else { m_Logger.Debug(message); } }
private static void WriteUserTrackingRecord(UserTrackingRecord userTrackingRecord) { WriteTitle("User Activity Record"); Console.WriteLine("EventDateTime: " + userTrackingRecord.EventDateTime.ToString()); Console.WriteLine("QualifiedName: " + userTrackingRecord.QualifiedName.ToString()); Console.WriteLine("ActivityType: " + userTrackingRecord.ActivityType.FullName.ToString()); Console.WriteLine("Args: " + userTrackingRecord.UserData.ToString()); }
private static void WriteUserTrackingRecord(UserTrackingRecord userTrackingRecord) { WriteTitle("User Activity Record"); Console.WriteLine("EventDataTime: " + userTrackingRecord.EventDateTime.ToString()); Console.WriteLine("QualifiedId: " + userTrackingRecord.QualifiedName.ToString()); Console.WriteLine("ActivityType: " + userTrackingRecord.ActivityType.FullName.ToString()); if (userTrackingRecord.UserData is RuleActionTrackingEvent) { WriteRuleActionTrackingEvent((RuleActionTrackingEvent)userTrackingRecord.UserData); } }
internal bool TryTrackUserEvent(Activity activity, string keyName, object argument, WorkflowExecutor exec, UserTrackingRecord record) { List<UserTrackPoint> points; if (TryGetCacheItems(activity, out points)) { bool ret = false; foreach (UserTrackPoint point in points) { if (point.IsMatch(activity, keyName, argument)) { ret = true; point.Track(activity, argument, exec, record.Body); record.Annotations.AddRange(point.Annotations); } } return ret; } return false; }
/// <summary> /// Serialise a <see cref="UserTrackingRecord" /> ready for persistence. /// </summary> /// <param name="userTrackingRecord"> /// The original <see cref="UserTrackingRecord" /> to serialise. /// </param> /// <returns> /// Modified copy of the <see cref="UserTrackingRecord" /> containing /// with serialised data. /// </returns> private static SerialisableUserTrackingRecord buildSerialisableUserTrackingRecord(UserTrackingRecord userTrackingRecord) { SerialisableUserTrackingRecord serialisableUserTrackingRecord = new SerialisableUserTrackingRecord(); serialisableUserTrackingRecord.ActivityType = userTrackingRecord.ActivityType; serialisableUserTrackingRecord.Annotations.AddRange(userTrackingRecord.Annotations); serialisableUserTrackingRecord.ContextGuid = userTrackingRecord.ContextGuid; serialisableUserTrackingRecord.EventDateTime = userTrackingRecord.EventDateTime; serialisableUserTrackingRecord.EventOrder = userTrackingRecord.EventOrder; serialisableUserTrackingRecord.ParentContextGuid = userTrackingRecord.ParentContextGuid; serialisableUserTrackingRecord.QualifiedName = userTrackingRecord.QualifiedName; serialisableUserTrackingRecord.UserDataKey = userTrackingRecord.UserDataKey; if (userTrackingRecord.Body != null) { for (int i = 0; i < userTrackingRecord.Body.Count; i++) serialisableUserTrackingRecord.Body.Add(buildSerialisableTrackingDataItem(userTrackingRecord.Body[i])); } if (userTrackingRecord.EventArgs != null) serialisableUserTrackingRecord.EventArgs = buildSerialisableData(userTrackingRecord.EventArgs); if (userTrackingRecord.UserData != null) serialisableUserTrackingRecord.UserData = buildSerialisableData(userTrackingRecord.UserData); return serialisableUserTrackingRecord; }
internal void UserTrackPoint(object sender, WorkflowExecutor.UserTrackPointEventArgs e) { Guid guid; Guid guid2; if (!typeof(WorkflowExecutor).IsInstanceOfType(sender)) { throw new ArgumentException("sender is not WorkflowExecutor"); } WorkflowExecutor exec = (WorkflowExecutor) sender; Activity activity = e.Activity; DateTime utcNow = DateTime.UtcNow; int nextEventOrderId = this._broker.GetNextEventOrderId(); this.GetContext(activity, exec, out guid2, out guid); foreach (TrackingChannelWrapper wrapper in this._channels) { UserTrackingRecord record = new UserTrackingRecord(activity.GetType(), activity.QualifiedName, guid2, guid, utcNow, nextEventOrderId, e.Key, e.Args); if (wrapper.GetTrackingProfile(exec).TryTrackUserEvent(activity, e.Key, e.Args, exec, record)) { wrapper.TrackingChannel.Send(record); } } }
private void LoadUserEventsFromReader(SqlDataReader reader, object parameter) { if (null == reader) { throw new ArgumentNullException("reader"); } // // There should always be 4 recordsets in this reader! // BinaryFormatter formatter = new BinaryFormatter(); Dictionary <long, UserTrackingRecord> userEvents = new Dictionary <long, UserTrackingRecord>(); // // Build a dictionary of activity records so that we can match // annotation and artifact records from subsequent recordsets DateTime tmpMin = SqlDateTime.MinValue.Value; while (reader.Read()) { string qId = reader.GetString(0); DateTime dt = reader.GetDateTime(1); Guid context = reader.GetGuid(2), parentContext = reader.GetGuid(3); int order = reader.GetInt32(4); string key = null; if (!reader.IsDBNull(5)) { key = reader.GetString(5); } // // Get the user data from the serialized column if we can // Try the string column if serialized column is null // If both are null the user data was null originally object userData = null; if (!reader.IsDBNull(7)) { userData = formatter.Deserialize(new MemoryStream((Byte[])reader[7])); } else if (!reader.IsDBNull(6)) { userData = reader.GetString(6); } if (reader.IsDBNull(8) || reader.IsDBNull(9)) { throw new InvalidOperationException(String.Format(System.Globalization.CultureInfo.CurrentCulture, ExecutionStringManager.SqlTrackingTypeNotFound, qId)); } Type type = Type.GetType(reader.GetString(8) + ", " + reader.GetString(9), true, false); long eventId = reader.GetInt64(10); DateTime dbDt = reader.GetDateTime(11); userEvents.Add(eventId, new UserTrackingRecord(type, qId, context, parentContext, dt, order, key, userData)); if (dbDt > tmpMin) { tmpMin = dbDt; } } if (!reader.NextResult()) { throw new ArgumentException(ExecutionStringManager.InvalidUserEventReader); } // // If we have annotations on the event itself, add them while (reader.Read()) { long eventId = reader.GetInt64(0); string annotation = null; if (!reader.IsDBNull(1)) { annotation = reader.GetString(1); } UserTrackingRecord user = null; if (userEvents.TryGetValue(eventId, out user)) { if (null != user) { user.Annotations.Add(annotation); } } } if (!reader.NextResult()) { throw new ArgumentException(ExecutionStringManager.InvalidUserEventReader); } // // Build a dictionary of artifact records so that we can match // annotation records from subsequent recordsets Dictionary <long, TrackingDataItem> artifacts = new Dictionary <long, TrackingDataItem>(); while (reader.Read()) { long eventId = reader.GetInt64(0); long artId = reader.GetInt64(1); string name = reader.GetString(2), strData = null; object data = null; // // These may both be null if (!reader.IsDBNull(3)) { strData = reader.GetString(3); } if (!reader.IsDBNull(4)) { data = formatter.Deserialize(new MemoryStream((Byte[])reader[4])); } TrackingDataItem item = new TrackingDataItem(); item.FieldName = name; if (null != data) { item.Data = data; } else { item.Data = strData; } artifacts.Add(artId, item); // // Find the event to which this artifact belongs and add it to the record UserTrackingRecord user = null; if (userEvents.TryGetValue(eventId, out user)) { if (null != user) { user.Body.Add(item); } } } if (!reader.NextResult()) { throw new ArgumentException(ExecutionStringManager.InvalidUserEventReader); } // // If we have annotations add them to the appropriate artifact while (reader.Read()) { long artId = reader.GetInt64(0); string annotation = null; if (!reader.IsDBNull(1)) { annotation = reader.GetString(1); } // // Find the right artifact and give it the annotation TrackingDataItem item = null; if (artifacts.TryGetValue(artId, out item)) { if (null != item) { item.Annotations.Add(annotation); } } } _userEvents.AddRange(userEvents.Values); // // Set the min dt to query for next time to the most recent event we got for this query. // Don't overwrite the previous min if nothing came back for this query if (tmpMin > SqlDateTime.MinValue.Value) { _userMinDT = tmpMin; } return; }
private void LoadUserEventsFromReader(SqlDataReader reader, object parameter) { if (reader == null) { throw new ArgumentNullException("reader"); } BinaryFormatter formatter = new BinaryFormatter(); Dictionary <long, UserTrackingRecord> dictionary = new Dictionary <long, UserTrackingRecord>(); DateTime time = SqlDateTime.MinValue.Value; while (reader.Read()) { string qualifiedName = reader.GetString(0); DateTime dateTime = reader.GetDateTime(1); Guid contextGuid = reader.GetGuid(2); Guid guid = reader.GetGuid(3); int eventOrder = reader.GetInt32(4); string userDataKey = null; if (!reader.IsDBNull(5)) { userDataKey = reader.GetString(5); } object userData = null; if (!reader.IsDBNull(7)) { userData = formatter.Deserialize(new MemoryStream((byte[])reader[7])); } else if (!reader.IsDBNull(6)) { userData = reader.GetString(6); } if (reader.IsDBNull(8) || reader.IsDBNull(9)) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.SqlTrackingTypeNotFound, new object[] { qualifiedName })); } Type activityType = Type.GetType(reader.GetString(8) + ", " + reader.GetString(9), true, false); long key = reader.GetInt64(10); DateTime time3 = reader.GetDateTime(11); dictionary.Add(key, new UserTrackingRecord(activityType, qualifiedName, contextGuid, guid, dateTime, eventOrder, userDataKey, userData)); if (time3 > time) { time = time3; } } if (!reader.NextResult()) { throw new ArgumentException(ExecutionStringManager.InvalidUserEventReader); } while (reader.Read()) { long num3 = reader.GetInt64(0); string str3 = null; if (!reader.IsDBNull(1)) { str3 = reader.GetString(1); } UserTrackingRecord record = null; if (dictionary.TryGetValue(num3, out record) && (record != null)) { record.Annotations.Add(str3); } } if (!reader.NextResult()) { throw new ArgumentException(ExecutionStringManager.InvalidUserEventReader); } Dictionary <long, TrackingDataItem> dictionary2 = new Dictionary <long, TrackingDataItem>(); while (reader.Read()) { long num4 = reader.GetInt64(0); long num5 = reader.GetInt64(1); string str4 = reader.GetString(2); string str5 = null; object obj3 = null; if (!reader.IsDBNull(3)) { str5 = reader.GetString(3); } if (!reader.IsDBNull(4)) { obj3 = formatter.Deserialize(new MemoryStream((byte[])reader[4])); } TrackingDataItem item = new TrackingDataItem { FieldName = str4 }; if (obj3 != null) { item.Data = obj3; } else { item.Data = str5; } dictionary2.Add(num5, item); UserTrackingRecord record2 = null; if (dictionary.TryGetValue(num4, out record2) && (record2 != null)) { record2.Body.Add(item); } } if (!reader.NextResult()) { throw new ArgumentException(ExecutionStringManager.InvalidUserEventReader); } while (reader.Read()) { long num6 = reader.GetInt64(0); string str6 = null; if (!reader.IsDBNull(1)) { str6 = reader.GetString(1); } TrackingDataItem item2 = null; if (dictionary2.TryGetValue(num6, out item2) && (item2 != null)) { item2.Annotations.Add(str6); } } this._userEvents.AddRange(dictionary.Values); if (time > SqlDateTime.MinValue.Value) { this._userMinDT = time; } }
private void WriteUserTrackingRecord(UserTrackingRecord userTrackingRecord) { WriteToFile("User Data: " + userTrackingRecord.UserData.ToString()); }