示例#1
0
        public string ReadAllRawDetails(char linePaddingChar = ' ', int linePaddingRepeat = 0)
        {
            StringBuilder sb         = new StringBuilder();
            string        prePadding = new string(linePaddingChar, linePaddingRepeat);

            if (AlertHeader != null && AlertHeader.Trim().Length > 0)
            {
                sb.AppendLine(new string(linePaddingChar, linePaddingRepeat) + AlertHeader);
            }
            if (AdditionalAlertText != null && AdditionalAlertText.Trim().Length > 0)
            {
                sb.AppendLine(new string(linePaddingChar, linePaddingRepeat) + AdditionalAlertText);
            }
            if (ForAgent != null && ForAgent.Length > 0)
            {
                prePadding += string.Format("{0}: ", ForAgent);
                if (State == CollectorState.Good || State == CollectorState.Warning || State == CollectorState.Error || State == CollectorState.Disabled || State == CollectorState.ConfigurationError)
                {
                    if (CurrentValue != null)
                    {
                        prePadding += string.Format("{0} ", CurrentValue);
                        if (CurrentValueUnit != null && CurrentValueUnit.Length > 0)
                        {
                            prePadding += string.Format("{0} ", CurrentValueUnit);
                        }
                    }
                    prePadding += string.Format("({0}) ", State);
                }
            }
            if (RawDetails != null && RawDetails.Length > 0)
            {
                prePadding += RawDetails.TrimEnd('\r', '\n').Replace("\r\n", "\r\n" + linePaddingChar);
            }


            if (prePadding.Trim(linePaddingChar).Length > 0)
            {
                sb.AppendLine(prePadding);
                linePaddingRepeat++;
            }

            if (ChildStates != null)
            {
                foreach (MonitorState ms in ChildStates)
                {
                    sb.AppendLine(ms.ReadAllRawDetails(linePaddingChar, linePaddingRepeat));
                }
            }
            if (AlertFooter != null && AlertFooter.Trim().Length > 0)
            {
                sb.AppendLine(new string(linePaddingChar, linePaddingRepeat) + AlertFooter);
            }
            return(sb.ToString().TrimEnd());
        }
示例#2
0
        public string ReadAllHtmlDetails()
        {
            StringBuilder sb = new StringBuilder();

            if (AlertHeader != null && AlertHeader.Trim().Length > 0)
            {
                sb.Append("<p><b>" + AlertHeader + "</b></p>");
            }
            if (AdditionalAlertText != null && AdditionalAlertText.Trim().Length > 0)
            {
                sb.Append("<p>" + AdditionalAlertText + "</p>");
            }
            if ((ForAgent != null && ForAgent.Length > 0) || (HtmlDetails != null && HtmlDetails.Length > 0) || (RawDetails != null && RawDetails.Length > 0))
            {
                sb.Append("<p>");
                if (ForAgent != null && ForAgent.Length > 0)
                {
                    sb.Append(string.Format("{0}: ", ForAgent));
                    if (State == CollectorState.Good || State == CollectorState.Warning || State == CollectorState.Error || State == CollectorState.Disabled || State == CollectorState.ConfigurationError)
                    {
                        if (CurrentValue != null)
                        {
                            sb.Append(string.Format("{0} ", CurrentValue));
                            if (CurrentValueUnit != null && CurrentValueUnit.Length > 0)
                            {
                                sb.Append(string.Format("{0} ", CurrentValueUnit));
                            }
                        }
                        if (State == CollectorState.Error || State == CollectorState.ConfigurationError || State == CollectorState.Warning)
                        {
                            sb.Append(string.Format("(<b>{0}</b>) ", State));
                        }
                        else
                        {
                            sb.Append(string.Format("({0}) ", State));
                        }
                    }
                }
                if (HtmlDetails != null && HtmlDetails.Length > 0)
                {
                    sb.AppendLine(HtmlDetails + "</p>");
                }
                else if (RawDetails != null && RawDetails.Length > 0)
                {
                    sb.AppendLine(RawDetails + "</p>");
                }
                else
                {
                    sb.AppendLine("</p>");
                }
            }

            if (ChildStates != null && ChildStates.Count > 0)
            {
                sb.AppendLine("<ul>");
                if (ChildStates != null)
                {
                    foreach (MonitorState ms in ChildStates)
                    {
                        sb.Append("<li>" + ms.ReadAllHtmlDetails() + "</li>");
                    }
                }
                sb.AppendLine("</ul>");
            }
            if (AlertFooter != null && AlertFooter.Trim().Length > 0)
            {
                sb.AppendLine("<p>" + AlertFooter + "</p>");
            }
            return(sb.ToString());
        }