private void WriteMonitorState(HenIT.RTF.RTFBuilder rtfBuilder, MonitorState ms) { if (ms != null) { if (FormatUtils.N(ms.ForAgent) != "") { rtfBuilder.FontStyle(FontStyle.Bold).Append("For object: ").FontStyle(FontStyle.Regular).AppendLine(ms.ForAgent); } rtfBuilder.FontStyle(FontStyle.Bold).Append("Time: ").FontStyle(FontStyle.Regular).AppendLine(ms.Timestamp.ToString("yyyy-MM-dd HH:mm:ss")); rtfBuilder.FontStyle(FontStyle.Bold).Append("State: ").FontStyle(FontStyle.Regular).AppendLine(ms.State.ToString()); rtfBuilder.FontStyle(FontStyle.Bold).Append("Duration: ").FontStyle(FontStyle.Regular).AppendLine(ms.CallDurationMS.ToString() + " ms"); if (ms.AlertsRaised != null) { rtfBuilder.FontStyle(FontStyle.Bold).Append("Alert count: ").FontStyle(FontStyle.Regular).AppendLine(ms.AlertsRaised.Count.ToString()); } rtfBuilder.FontStyle(FontStyle.Bold).Append("Executed on: ").FontStyle(FontStyle.Regular).AppendLine(FormatUtils.N(ms.ExecutedOnHostComputer)); rtfBuilder.FontStyle(FontStyle.Bold).Append("Ran as: ").FontStyle(FontStyle.Regular).AppendLine(FormatUtils.N(ms.RanAs)); rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Value(s): ").FontStyle(FontStyle.Regular).AppendLine(ms.CurrentValue.ToString()); if (ms.RawDetails != null && ms.RawDetails.Length > 0) //ms.State != CollectorState.Good && { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Raw details: ").FontStyle(FontStyle.Regular).AppendLine(ms.RawDetails); } if (ms.AlertsRaised != null) { if (ms.AlertsRaised.Count > 0) { string alertSummary = ""; ms.AlertsRaised.ForEach(a => alertSummary += '\t' + a.TrimEnd('\r', '\n').Replace("\r\n", "\r\n\t") + "\r\n"); alertSummary = alertSummary.Trim('\r', '\n'); rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Alert details:").FontStyle(FontStyle.Regular).AppendLine(alertSummary.TrimEnd('\r', '\n')); } } } }
private void UpdateRawView() { try { if (lvwHistory.SelectedItems.Count == 1) { HenIT.RTF.RTFBuilder rtfBuilder = new HenIT.RTF.RTFBuilder(); object selectedObject = lvwHistory.SelectedItems[0].Tag; if (selectedObject is MonitorState) { MonitorState ms = (MonitorState)selectedObject; WriteMonitorState(rtfBuilder, ms); } rtxDetails.Rtf = rtfBuilder.ToString(); rtxDetails.SelectionStart = 0; rtxDetails.SelectionLength = 0; rtxDetails.ScrollToCaret(); } } catch { } }