/// <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; }