internal static void GetAllMembers(Activity activity, IList<TrackingDataItem> items, TrackingAnnotationCollection annotations) { Type type = activity.GetType(); foreach (FieldInfo info in type.GetFields(BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) { if (!IsInternalVariable(info.Name)) { TrackingDataItem item = new TrackingDataItem { FieldName = info.Name, Data = GetRuntimeValue(info.GetValue(activity), activity) }; foreach (string str in annotations) { item.Annotations.Add(str); } items.Add(item); } } foreach (PropertyInfo info2 in type.GetProperties(BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) { if (!IsInternalVariable(info2.Name) && (info2.GetIndexParameters().Length <= 0)) { TrackingDataItem item2 = new TrackingDataItem { FieldName = info2.Name, Data = GetRuntimeValue(info2.GetValue(activity, null), activity) }; foreach (string str2 in annotations) { item2.Annotations.Add(str2); } items.Add(item2); } } }
internal static void GetAllMembers(Activity activity, IList <TrackingDataItem> items, TrackingAnnotationCollection annotations) { Type type = activity.GetType(); foreach (FieldInfo info in type.GetFields(BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) { if (!IsInternalVariable(info.Name)) { TrackingDataItem item = new TrackingDataItem { FieldName = info.Name, Data = GetRuntimeValue(info.GetValue(activity), activity) }; foreach (string str in annotations) { item.Annotations.Add(str); } items.Add(item); } } foreach (PropertyInfo info2 in type.GetProperties(BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) { if (!IsInternalVariable(info2.Name) && (info2.GetIndexParameters().Length <= 0)) { TrackingDataItem item2 = new TrackingDataItem { FieldName = info2.Name, Data = GetRuntimeValue(info2.GetValue(activity, null), activity) }; foreach (string str2 in annotations) { item2.Annotations.Add(str2); } items.Add(item2); } } }
internal static void GetAllMembers(Activity activity, IList <TrackingDataItem> items, TrackingAnnotationCollection annotations) { Type t = activity.GetType(); // // Get all fields FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.GetField); foreach (FieldInfo f in fields) { if (!PropertyHelper.IsInternalVariable(f.Name)) { TrackingDataItem data = new TrackingDataItem(); data.FieldName = f.Name; data.Data = GetRuntimeValue(f.GetValue(activity), activity); foreach (string s in annotations) { data.Annotations.Add(s); } items.Add(data); } } // // Get all properties (except indexers) PropertyInfo[] properties = t.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.GetProperty); foreach (PropertyInfo p in properties) { if (!IsInternalVariable(p.Name)) { // // Skip indexers, since private data members // are exposed the data is still available. if (p.GetIndexParameters().Length > 0) { continue; } TrackingDataItem data = new TrackingDataItem(); data.FieldName = p.Name; data.Data = GetRuntimeValue(p.GetValue(activity, null), activity); foreach (string s in annotations) { data.Annotations.Add(s); } items.Add(data); } } }
internal static void GetProperty(string name, Activity activity, TrackingAnnotationCollection annotations, out TrackingDataItem item) { item = null; object tmp = PropertyHelper.GetProperty(name, activity); item = new TrackingDataItem(); item.FieldName = name; item.Data = tmp; foreach (string s in annotations) item.Annotations.Add(s); }
internal override void GetData(Activity activity, IServiceProvider provider, IList <TrackingDataItem> items) { if ((this._name == null) || (this._name.Trim().Length == 0)) { PropertyHelper.GetAllMembers(activity, items, this._annotations); } else { TrackingDataItem item = null; PropertyHelper.GetProperty(this._name, activity, this._annotations, out item); if (item != null) { items.Add(item); } } }
internal override void GetData(Activity activity, IServiceProvider provider, IList <TrackingDataItem> items) { if ((null == _name) || (0 == _name.Trim().Length)) { // // If we don't have a name we get everything PropertyHelper.GetAllMembers(activity, items, _annotations); } else { TrackingDataItem item = null; PropertyHelper.GetProperty(_name, activity, _annotations, out item); if (null != item) { items.Add(item); } } }
/// <summary> /// Serialise a <see cref="TrackingDataItem" /> ready for persistence. /// </summary> /// <param name="trackingDataItem"> /// The original <see cref="TrackingDataItem" /> to serialise. /// </param> /// <returns> /// A <see cref="SerialisableTrackingDataItem" /> containing a serialised /// copy of the <see cref="TrackingDataItem" />. /// </returns> private static SerialisableTrackingDataItem buildSerialisableTrackingDataItem(TrackingDataItem trackingDataItem) { SerialisableTrackingDataItem serialisableTrackingDataItem = new SerialisableTrackingDataItem(); serialisableTrackingDataItem.Annotations.AddRange(trackingDataItem.Annotations); serialisableTrackingDataItem.Data = buildSerialisableData(trackingDataItem.Data); serialisableTrackingDataItem.FieldName = trackingDataItem.FieldName; return serialisableTrackingDataItem; }
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 (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 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; } }
internal static void GetAllMembers(Activity activity, IList<TrackingDataItem> items, TrackingAnnotationCollection annotations) { Type t = activity.GetType(); // // Get all fields FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.GetField); foreach (FieldInfo f in fields) { if (!PropertyHelper.IsInternalVariable(f.Name)) { TrackingDataItem data = new TrackingDataItem(); data.FieldName = f.Name; data.Data = GetRuntimeValue(f.GetValue(activity), activity); foreach (string s in annotations) data.Annotations.Add(s); items.Add(data); } } // // Get all properties (except indexers) PropertyInfo[] properties = t.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.GetProperty); foreach (PropertyInfo p in properties) { if (!IsInternalVariable(p.Name)) { // // Skip indexers, since private data members // are exposed the data is still available. if (p.GetIndexParameters().Length > 0) continue; TrackingDataItem data = new TrackingDataItem(); data.FieldName = p.Name; data.Data = GetRuntimeValue(p.GetValue(activity, null), activity); foreach (string s in annotations) data.Annotations.Add(s); items.Add(data); } } }