/// <summary> /// Creates an <see cref="IEnumerable{T}" /> from an <see cref="IMMPxNodeHistory" /> /// </summary> /// <param name="source">An <see cref="IMMPxNodeHistory" /> to create an <see cref="IEnumerable{T}" /> from.</param> /// <returns>An <see cref="IEnumerable{T}" /> that contains the fields from the input source.</returns> public static IEnumerable <IMMPxHistory> AsEnumerable(this IMMPxNodeHistory source) { if (source != null) { source.Reset(); IMMPxHistory history = source.Next(); while (history != null) { yield return(history); history = source.Next(); } } }
/// <summary> /// Adds the history record for the specified node id and type. /// </summary> /// <param name="source">The source.</param> /// <param name="list">The list of history records.</param> /// <param name="nodeId">The node identifier.</param> /// <param name="nodeType">Type of the node.</param> /// <param name="description">The description.</param> /// <param name="extraData">The extra data.</param> /// <returns> /// Returns a <see cref="IMMPxHistory" /> representing the history record. /// </returns> public static IMMPxHistory AddHistory(this IMMPxApplication source, IMMPxNodeHistory list, int nodeId, int nodeType, string description, string extraData) { IMMPxHistory history = new PxHistoryClass(); history.CurrentUser = source.User.Id; history.CurrentUserName = source.User.Name; history.Date = DateTime.Now; history.Description = description; history.NodeId = nodeId; history.nodeTypeId = nodeType; history.ExtraData = extraData; var property = source.Connection.Properties["Data Source Name"]; if (property != null) { string server = (!Convert.IsDBNull(property.Value)) ? Convert.ToString(property.Value, CultureInfo.InvariantCulture) : string.Empty; history.Server = server; } list.Add(history); return(history); }