예제 #1
0
        private void EventlogBox_PreRender(object sender, EventArgs e)
        {
            SiteConfig          siteConfig = SiteConfig.GetSiteConfig();
            Control             root       = contentPlaceHolder;
            ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());

            Table table = new Table();

            table.CssClass = "statsTableStyle";

            TableRow row = new TableRow();

            row.CssClass = "statsTableHeaderRowStyle";
            row.Cells.Add(new TableCell());
            row.Cells.Add(new TableCell());
            row.Cells.Add(new TableCell());
            row.Cells[0].CssClass = "statsTableDateColumnStyle";
            row.Cells[1].CssClass = "statsTableNumColumnStyle";
            row.Cells[2].CssClass = "statsTableColumnStyle";
            row.Cells[0].Text     = "<b>" + resmgr.GetString("text_time") + "</b>";
            row.Cells[1].Text     = "<b>" + resmgr.GetString("text_message_code") + "</b>";
            row.Cells[2].Text     = "<b>" + resmgr.GetString("text_message_text") + "</b>";
            table.Rows.Add(row);

            // get the user's local time
            DateTime utcTime   = DateTime.UtcNow;
            DateTime localTime = siteConfig.GetConfiguredTimeZone().ToLocalTime(utcTime);

            if (Request.QueryString["date"] != null)
            {
                try
                {
                    DateTime popUpTime = DateTime.ParseExact(Request.QueryString["date"], "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    utcTime   = new DateTime(popUpTime.Year, popUpTime.Month, popUpTime.Day, utcTime.Hour, utcTime.Minute, utcTime.Second);
                    localTime = new DateTime(popUpTime.Year, popUpTime.Month, popUpTime.Day, localTime.Hour, localTime.Minute, localTime.Second);
                }
                catch (FormatException ex)
                {
                    ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, ex);
                }
            }

            EventDataItemCollection logItems = new EventDataItemCollection();

            logItems.AddRange(logService.GetEventsForDay(localTime));

            if (siteConfig.AdjustDisplayTimeZone)
            {
                newtelligence.DasBlog.Util.WindowsTimeZone tz = siteConfig.GetConfiguredTimeZone();
                TimeSpan ts     = tz.GetUtcOffset(DateTime.UtcNow);
                int      offset = ts.Hours;

                if (offset < 0)
                {
                    logItems.AddRange(logService.GetEventsForDay(localTime.AddDays(1)));
                }
                else
                {
                    logItems.AddRange(logService.GetEventsForDay(localTime.AddDays(-1)));
                }
            }

            EventDataItem[] sortedLogItems = logItems.ToSortedArray();

            foreach (EventDataItem eventItem in sortedLogItems)
            {
                if (siteConfig.AdjustDisplayTimeZone)
                {
                    if (siteConfig.GetConfiguredTimeZone().ToLocalTime(eventItem.EventTimeUtc).Date != localTime.Date)
                    {
                        continue;
                    }
                }

                row          = new TableRow();
                row.CssClass = "statsTableRowStyle";

                switch (eventItem.EventCode)
                {
                case ((int)EventCodes.Error):
                case ((int)EventCodes.PingbackServerError):
                case ((int)EventCodes.PingWeblogsError):
                case ((int)EventCodes.Pop3ServerError):
                case ((int)EventCodes.SmtpError):
                    row.CssClass = "statsTableRowStyleError";
                    break;

                case ((int)EventCodes.SecurityFailure):
                    row.CssClass = "statsTableRowStyleSecurityFailure";
                    break;

                case ((int)EventCodes.TrackbackBlocked):
                case ((int)EventCodes.ReferralBlocked):
                case ((int)EventCodes.ItemReferralBlocked):
                case ((int)EventCodes.CommentBlocked):
                case ((int)EventCodes.PingbackBlocked):
                    row.CssClass = "statsTableRowStyleBlocked";
                    break;

                default:
                    break;
                }

                row.Cells.Add(new TableCell());
                row.Cells.Add(new TableCell());
                row.Cells.Add(new TableCell());
                row.Cells[0].CssClass = "statsTableDateColumnStyle";
                row.Cells[1].CssClass = "statsTableNumColumnStyle";
                row.Cells[2].CssClass = "statsTableColumnStyle";

                if (siteConfig.AdjustDisplayTimeZone)
                {
                    row.Cells[0].Text = siteConfig.GetConfiguredTimeZone().ToLocalTime(eventItem.EventTimeUtc).ToString("yyyy-MM-dd HH:mm:ss tt");
                }
                else
                {
                    row.Cells[0].Text = eventItem.EventTimeUtc.ToString("yyyy-MM-dd HH:mm:ss tt") + " UTC";
                }

                row.Cells[1].Text = eventItem.EventCode.ToString();
                row.Cells[2].Text = eventItem.HtmlMessage;

                table.Rows.Add(row);
            }

            root.Controls.Add(table);

            DataBind();
        }
예제 #2
0
        private void EventlogBox_PreRender(object sender, EventArgs e)
        {
            SiteConfig siteConfig = SiteConfig.GetSiteConfig();
            Control root = contentPlaceHolder;
            ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());

            Table table = new Table();
            table.CssClass = "statsTableStyle";

            TableRow row = new TableRow();
            row.CssClass = "statsTableHeaderRowStyle";
            row.Cells.Add(new TableCell());
            row.Cells.Add(new TableCell());
            row.Cells.Add(new TableCell());
            row.Cells[0].CssClass = "statsTableDateColumnStyle";
            row.Cells[1].CssClass = "statsTableNumColumnStyle";
            row.Cells[2].CssClass = "statsTableColumnStyle";
            row.Cells[0].Text = "<b>" + resmgr.GetString("text_time") + "</b>";
            row.Cells[1].Text = "<b>" + resmgr.GetString("text_message_code") + "</b>";
            row.Cells[2].Text = "<b>" + resmgr.GetString("text_message_text") + "</b>";
            table.Rows.Add(row);

            // get the user's local time
            DateTime utcTime = DateTime.UtcNow;
            DateTime localTime = siteConfig.GetConfiguredTimeZone().ToLocalTime(utcTime);

            if (Request.QueryString["date"] != null)
            {
                try
                {
                    DateTime popUpTime = DateTime.ParseExact(Request.QueryString["date"], "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    utcTime = new DateTime(popUpTime.Year, popUpTime.Month, popUpTime.Day, utcTime.Hour, utcTime.Minute, utcTime.Second);
                    localTime = new DateTime(popUpTime.Year, popUpTime.Month, popUpTime.Day, localTime.Hour, localTime.Minute, localTime.Second);
                }
                catch (FormatException ex)
                {
                    ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, ex);
                }
            }

            EventDataItemCollection logItems = new EventDataItemCollection();
            logItems.AddRange(logService.GetEventsForDay(localTime));

            if (siteConfig.AdjustDisplayTimeZone)
            {
                newtelligence.DasBlog.Util.WindowsTimeZone tz = siteConfig.GetConfiguredTimeZone();
                TimeSpan ts = tz.GetUtcOffset(DateTime.UtcNow);
                int offset = ts.Hours;

                if (offset < 0)
                {
                    logItems.AddRange(logService.GetEventsForDay(localTime.AddDays(1)));
                }
                else
                {
                    logItems.AddRange(logService.GetEventsForDay(localTime.AddDays(-1)));
                }
            }

            EventDataItem[] sortedLogItems = logItems.ToSortedArray();

            foreach (EventDataItem eventItem in sortedLogItems)
            {
                if (siteConfig.AdjustDisplayTimeZone)
                {
                    if (siteConfig.GetConfiguredTimeZone().ToLocalTime(eventItem.EventTimeUtc).Date != localTime.Date)
                    {
                        continue;
                    }
                }

                row = new TableRow();
                row.CssClass = "statsTableRowStyle";

                switch (eventItem.EventCode)
                {
                    case ((int)EventCodes.Error):
                    case ((int)EventCodes.PingbackServerError):
                    case ((int)EventCodes.PingWeblogsError):
                    case ((int)EventCodes.Pop3ServerError):
                    case ((int)EventCodes.SmtpError):
                        row.CssClass = "statsTableRowStyleError";
                        break;
                    case ((int)EventCodes.SecurityFailure):
                        row.CssClass = "statsTableRowStyleSecurityFailure";
                        break;
                    case ((int)EventCodes.TrackbackBlocked):
                    case ((int)EventCodes.ReferralBlocked):
                    case ((int)EventCodes.ItemReferralBlocked):
                    case ((int)EventCodes.CommentBlocked):
                    case ((int)EventCodes.PingbackBlocked):
                        row.CssClass = "statsTableRowStyleBlocked";
                        break;
                    default:
                        break;
                }

                row.Cells.Add(new TableCell());
                row.Cells.Add(new TableCell());
                row.Cells.Add(new TableCell());
                row.Cells[0].CssClass = "statsTableDateColumnStyle";
                row.Cells[1].CssClass = "statsTableNumColumnStyle";
                row.Cells[2].CssClass = "statsTableColumnStyle";

                if (siteConfig.AdjustDisplayTimeZone)
                {
                    row.Cells[0].Text = siteConfig.GetConfiguredTimeZone().ToLocalTime(eventItem.EventTimeUtc).ToString("yyyy-MM-dd HH:mm:ss tt");
                }
                else
                {
                    row.Cells[0].Text = eventItem.EventTimeUtc.ToString("yyyy-MM-dd HH:mm:ss tt") + " UTC";
                }

                row.Cells[1].Text = eventItem.EventCode.ToString();
                row.Cells[2].Text = eventItem.HtmlMessage;

                table.Rows.Add(row);
            }

            root.Controls.Add(table);

            DataBind();
        }