当前位置: 首页>>代码示例>>C#>>正文


C# LogEntry.Reverse方法代码示例

本文整理汇总了C#中LogEntry.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# LogEntry.Reverse方法的具体用法?C# LogEntry.Reverse怎么用?C# LogEntry.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogEntry的用法示例。


在下文中一共展示了LogEntry.Reverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildLogTable

    private void BuildLogTable(LogEntry[] entries)
    {
        XElement table = new XElement("table");

            XElement tableHeader = new XElement("tr");
            tableHeader.Add(
                    new XElement("th", " "),
                    new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.DateLabel")),
                    new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.MessageLabel")),
                    new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.TitleLabel")),
                    new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.EventTypeLabel"))
                    //new XElement("th", "URL"),
                    //new XElement("th", "Referer")
                );

            table.Add(tableHeader);

            foreach (LogEntry logEntry in entries.Reverse())
            {
                TraceEventType eventType;

                try
                {
                    eventType = (TraceEventType)Enum.Parse(typeof(TraceEventType), logEntry.Severity);
                }
                catch (Exception)
                {
                    eventType = TraceEventType.Information;
                }

                XAttribute color = null;

                switch (eventType)
                {
                    case TraceEventType.Information:
                        color = new XAttribute("bgcolor", "lime");
                        break;

                    case TraceEventType.Verbose:
                        color = new XAttribute("bgcolor", "white");
                        break;

                    case TraceEventType.Warning:
                        color = new XAttribute("bgcolor", "yellow");
                        break;

                    case TraceEventType.Error:
                        color = new XAttribute("bgcolor", "orange");
                        break;

                    case TraceEventType.Critical:
                        color = new XAttribute("bgcolor", "red");
                        break;

                    default:
                        color = new XAttribute("bgcolor", "pink");
                        break;
                }

                XElement row = new XElement("tr");
                row.Add(
                    new XElement("td", " ", color),
                    new XElement("td", string.Format("{0} {1}", logEntry.TimeStamp.ToShortDateString(), logEntry.TimeStamp.ToShortTimeString())),
                    new XElement("td", new XElement("pre", logEntry.Message.Replace("\n", ""))),
                    new XElement("td", logEntry.Title),
                    new XElement("td", logEntry.Severity)
                    //new XElement("td", logEntry.HttpRequestUrl ?? "" + " "),
                    //new XElement("td", logEntry.HttpReferingUrl ?? "" + " ")
                );

                table.Add(row);
            }

            LogHolder.Controls.Add(new LiteralControl(table.ToString()));
    }
开发者ID:MaxPRafferty,项目名称:JS-E,代码行数:75,代码来源:log.aspx.cs

示例2: BuildLogTable

    private void BuildLogTable(LogEntry[] entries)
    {
        XElement table = new XElement("table");

        XElement tableHeader = new XElement("tr");
        tableHeader.Add(
                new XElement("th", " "),
                new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.DateLabel")),
                new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.MessageLabel")),
                new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.TitleLabel")),
                new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.EventTypeLabel"))
            );

        table.Add(tableHeader);

        foreach (LogEntry logEntry in entries.Reverse())
        {
            TraceEventType eventType;

            try
            {
                eventType = (TraceEventType)Enum.Parse(typeof(TraceEventType), logEntry.Severity);
            }
            catch (Exception)
            {
                eventType = TraceEventType.Information;
            }

            var colors = new []
                               {
                                   new Tuple<TraceEventType, string>(TraceEventType.Information, "lime"),
                                   new Tuple<TraceEventType, string>(TraceEventType.Verbose, "white"),
                                   new Tuple<TraceEventType, string>(TraceEventType.Warning, "yellow"),
                                   new Tuple<TraceEventType, string>(TraceEventType.Error, "orange"),
                                   new Tuple<TraceEventType, string>(TraceEventType.Critical, "red")
                               };

            string colorName = colors.Where(c => c.Item1 == eventType).Select(c => c.Item2).FirstOrDefault() ?? "orange";

            XAttribute color = new XAttribute("bgcolor", colorName);

            XElement row = new XElement("tr");
            row.Add(
                new XElement("td", color, " "),
                new XElement("td", logEntry.TimeStamp.ToString(View_DateTimeFormat)),
                new XElement("td", new XElement("pre", EncodeXml10InvalidCharacters(logEntry.Message.Replace("\n", "")))),
                new XElement("td", EncodeXml10InvalidCharacters(logEntry.Title)),
                new XElement("td", logEntry.Severity)
            );

            table.Add(row);
        }

        LogHolder.Controls.Add(new LiteralControl(table.ToString()));
    }
开发者ID:BeatriceCarrington,项目名称:Interior,代码行数:55,代码来源:log.aspx.cs


注:本文中的LogEntry.Reverse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。