public static CommentAuditRecordCollection Populate(DataRow[] drMembers) { CommentAuditRecordCollection colMembers = null; if (drMembers != null && drMembers.Length > 0) { colMembers = new CommentAuditRecordCollection(); foreach (DataRow drMember in drMembers) { CommentAuditRecord commentRecord = CommentAuditRecord.Populate(drMember); colMembers.Add(commentRecord); } } return colMembers; }
/// <summary> /// Converts all comments to a single string. /// </summary> /// <returns>Comments ToString()</returns> public string ToString(bool includeDateAndUser, bool includeDelimiters) { string commentsString = string.Empty; // Convert to comment Strings for Display purposes if (this != null && this.Count > 0) { CommentAuditRecordCollection telemetryComments = new CommentAuditRecordCollection(); CommentAuditRecordCollection nonTelemetryComments = new CommentAuditRecordCollection(); foreach (CommentAuditRecord commentRecord in this) { switch (commentRecord.Type) { case eCommentType.Telemetry: { telemetryComments.Add(commentRecord); break; } default: { nonTelemetryComments.Add(commentRecord); break; } } } if (telemetryComments.Count > 0) { // Order Comments by SortExpression (as this = AlarmLevel) telemetryComments.Sort("SortExpression", System.ComponentModel.ListSortDirection.Descending); } if (nonTelemetryComments.Count > 0) { // Order Comments with most recent displayed first nonTelemetryComments.Sort("ChangeDate", System.ComponentModel.ListSortDirection.Ascending); } // Build formatted CommentsString containing all the Comments in the collection for (int intIndex = 0; intIndex < telemetryComments.Count; intIndex++) { commentsString += telemetryComments[intIndex].ToString(includeDateAndUser); if (includeDelimiters) { commentsString += Environment.NewLine; commentsString += "--------------------------------------"; commentsString += Environment.NewLine; } } for (int intIndex = 0; intIndex < nonTelemetryComments.Count; intIndex++) { commentsString += nonTelemetryComments[intIndex].ToString(includeDateAndUser); if (includeDelimiters) { commentsString += Environment.NewLine; commentsString += "--------------------------------------"; commentsString += Environment.NewLine; } } } return commentsString; }
/// <summary> /// Populate OH Reason with core attributes (ID, Code, & Description) /// Called by all Find overloads and from LoadJobFromWorkOrder in WIS /// </summary> /// <param name="dtResults"></param> /// <returns></returns> public static CommentAuditRecordCollection Populate(DataTable dtResults) { CommentAuditRecordCollection colMembers = null; CommentAuditRecord commentRecord = null; if (dtResults != null && dtResults.Rows.Count > 0) { colMembers = new CommentAuditRecordCollection(); foreach (DataRow drMember in dtResults.Rows) { commentRecord = new CommentAuditRecord(); commentRecord.ChangeDate = (DateTime)drMember["ChangeDate"]; commentRecord.ChangeUser = drMember["ChangeUser"].ToString(); commentRecord.IsEngineerComment = (bool)drMember["IsEngineerComment"]; // ----------------------------------------------------- commentRecord.Text = drMember["CommentText"].ToString(); if (!drMember["CommentType"].Equals(DBNull.Value)) { commentRecord.Type = (eCommentType)Enum.Parse(typeof(eCommentType), drMember["CommentType"].ToString()); } if (!drMember["SortExpression"].Equals(DBNull.Value)) { commentRecord.SortExpression = drMember["SortExpression"].ToString(); } colMembers.Add(commentRecord); } } return colMembers; }