Esempio n. 1
0
        /// <summary>
        /// Gets the event page.
        /// </summary>
        /// <param name="applicationId">The application id.</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="pageIndex">Index of the page.</param>
        /// <param name="rowCount">The row count.</param>
        /// <param name="appLocationFilter">The app location filter.</param>
        /// <param name="eventTypeFilter">The event type filter.</param>
        /// <param name="userId">The user id.</param>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <returns></returns>
        public static LogDatasets.EventLogDataTable GetEventPage(int applicationId, int pageSize, int pageIndex, out int?rowCount, int appLocationFilter, int eventTypeFilter
                                                                 , int userId, DateTime startDate, DateTime endDate)
        {
            rowCount = 0;
            DataAccessManager dam = new DataAccessManager(ConnectionString);

            dam.AddInputParameter("@ApplicationId", applicationId);
            dam.AddInputParameter("@PageIndex", pageIndex);
            dam.AddInputParameter("@PageSize", pageSize);
            dam.AddInputParameter("@AppLocationFilter", appLocationFilter);
            dam.AddInputParameter("@EventTypeFilter", eventTypeFilter);

            dam.AddInputParameter("@AuthenticatedUserIdFilter", userId.ToString());
            dam.AddInputParameter("@StartDate", startDate);
            dam.AddInputParameter("@EndDate", endDate);

            dam.AddOutPutParameter("@RowCount", SqlDbType.Int);

            Dictionary <string, object> outputParameters = new Dictionary <string, object>();

            LogDatasets.EventLogDataTable dt = dam.ExecuteTableQuery <LogDatasets.EventLogDataTable>(GetFormattedStoredProcedureName(SP_EVENTLOG_GETPAGE_WITHFILTERS), out outputParameters);
            rowCount = (int)outputParameters["@RowCount"];

            return(dt);
        }
Esempio n. 2
0
        public void Test_LogEvent()
        {
            Trace.WriteLine(Configuration.GetGenericHeader());

            int? oldRowCount = 0;
            Guid testId      = Guid.NewGuid();

            LogManager.GetEventPage(10, 0, out oldRowCount);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            LogManager.LogEvent(ApplicationLocation.Application, EventType.Verbose, GetTestMessage(testId));
            stopwatch.Stop();
            Trace.WriteLine("Event Log insert time: " + stopwatch.Elapsed.ToString());

            int?newRowCount = 0;

            LogDatasets.EventLogDataTable dt = LogManager.GetEventPage(10, 0, out newRowCount);
            Assert.IsTrue(newRowCount > oldRowCount);
            Assert.IsTrue(dt[0].Message == GetTestMessage(testId));
            Trace.WriteLine(Configuration.GetGenericFooter());
        }
Esempio n. 3
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"></see> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            #region get eventlog table
            int pageSize = int.Parse(_DDLPageSize.SelectedValue);
            _EventLogTable = LogManager.GetEventPage(pageSize, this.PageIndex, out _TotalRowCount
                                                     , (string.IsNullOrEmpty(_DDLApplicationLocations.SelectedValue) ? -1 : int.Parse(_DDLApplicationLocations.SelectedValue))
                                                     , (string.IsNullOrEmpty(_DDLEventTypes.SelectedValue) ? -1 : int.Parse(_DDLEventTypes.SelectedValue)));
            #endregion

            #region styling
            if (this.UseDefaultStyling)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "EventLogViewSyles",
                                                            @"
<style type=""text/css"">
<!--
.EventLogView {
}
.EventLogView table {
	border: Solid 1px #FCFCFC;
	width: 802px;
}
.EventLogView table th {
	text-align: center;
	font-weight: bold;
	padding: 3px 4px 3px 4px;
	border: Solid 1px #212121;
}
.EventLogView table td {
	padding: 1px 4px 1px 4px;
	border: Solid 1px #212121;
}
.EventLogViewPager {
	width: 800px;
	border: Solid 1px #212121;
	padding-top: 1px;
	padding-bottom: 1px;
	text-align: center;
	height: 120px;
	margin-top: 8px;
	overflow: auto;
	display: block;
	clear: both;
	float: left;
}
.EventLogViewPager table {
	width: 780px;
}
.EventLogViewPager table td {
	cursor: pointer;
}
.EventLogViewPagerCell {
}
.EventLogViewPagerCellSelected {
	background-color: #FEC654;
}
.EventLogViewEventIDCell {
	width: 60px;
	text-align: center;
}
.EventLogViewAppLocationCell {
	width: 90px;
	text-align: center;
}
.EventLogViewMessageCell {
	width: 320px;
	text-align: left;
}
.EventLogViewEventDateCell {
	width: 160px;
	text-align: center;
}
.EventLogViewEventTypeCell {
	width: 90px;
	text-align: center;
}
.EventLogViewMachineNameCell {
	width: 80px;
	text-align: center;
}
.EventLogViewFilter {
	display: inline;
	float: left;
	clear: none;
	border: Solid 1px #212121;
	padding: 2px 6px 2px 6px;
	background-color: #33FF99;
}
.EventLogViewDelete {
	display: inline;
	float: left;
	clear: right;
	border: Solid 1px #212121;
	padding: 2px 6px 2px 6px;
	margin-left: 4px;
	background-color: #CC66FF;
}
-->
</style>
"
                                                            , false);
                this.CssClass                  = "EventLogView";
                this.EventIDCellCssClass       = "EventLogViewEventIDCell";
                this.DeleteCellCssClass        = "EventLogViewDelete";
                this.FilterCssClass            = "EventLogViewFilter";
                this.AppLocationCellCssClass   = "EventLogViewAppLocationCell";
                this.MessageCellCssClass       = "EventLogViewMessageCell";
                this.EventDateCellCssClass     = "EventLogViewEventDateCell";
                this.EventTypeCellCssClass     = "EventLogViewEventTypeCell";
                this.MachineNameCellCssClass   = "EventLogViewMachineNameCell";
                this.PagerCssClass             = "EventLogViewPager";
                this.PagerCellCssClass         = "EventLogViewPagerCell";
                this.PagerSelectedCellCssClass = "EventLogViewPagerCellSelected";
            }
            #endregion

            #region pager
            int pageCount = (int)_TotalRowCount / pageSize;

            if (pageCount == 0)
            {
                pageCount = 1;
            }
            else if (_TotalRowCount % pageSize != 0)
            {
                pageCount++;
            }

            string cellClass;
            if (pageCount > 1)
            {
                _ShowPager = true;
                int maxItemCounter = 0;
                _PagerRowHTML  = string.Empty;
                _PagerRowHTML += "<table cellpadding='2' cellspacing='1' border='0'><tr>";

                for (int i = 0; i < pageCount - 1; i++)
                {
                    if (maxItemCounter >= MaxPagerItemsPerRow)
                    {
                        _PagerRowHTML += "</tr><tr>";
                        maxItemCounter = 0;
                    }

                    if (i == this.PageIndex)
                    {
                        _PageInfoHMTL = "<div style='display: inline; float: left; clear: none; width: 300px; text-align: right;'>showing results " + ((i * pageSize) + 1).ToString() + "&nbsp;-&nbsp;" + (((i + 1) * pageSize)).ToString() + " from " + _TotalRowCount.ToString() + " records.</div>"
                                        + ((i == 0) ? ("") : ("<a onclick=\"" + Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this, (i - 1).ToString())) + "\">&lt; previous</a>&nbsp;|&nbsp;"))
                                        + "<a onclick=\"" + Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this, (i + 1).ToString())) + "\">next &gt;</a>";
                        cellClass = (string.IsNullOrEmpty(PagerSelectedCellCssClass) ? ("") : (@" class=""" + PagerSelectedCellCssClass + @""""));
                    }
                    else
                    {
                        cellClass = (string.IsNullOrEmpty(PagerCellCssClass) ? ("") : (@" class=""" + PagerCellCssClass + @""""));
                    }

                    _PagerRowHTML += @"<td" + cellClass
                                     + @" onclick=""" + Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this, i.ToString())) + @""">"
                                     + ((i * pageSize) + 1).ToString() + "&nbsp;-&nbsp;" + (((i + 1) * pageSize)).ToString() + @"</td>";
                    maxItemCounter++;
                }

                // add last pager
                if ((pageCount - 1) == this.PageIndex)
                {
                    _PageInfoHMTL = "Showing results " + (((pageCount - 1) * pageSize) + 1).ToString() + "&nbsp;-&nbsp;" + _TotalRowCount.ToString() + " from " + _TotalRowCount.ToString() + " records."
                                    + ((pageCount < 2) ? ("") : ("<a onclick=\"" + Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this, (pageCount - 2).ToString())) + "\">&lt; previous</a>&nbsp;&nbsp;"));
                    cellClass = (string.IsNullOrEmpty(PagerSelectedCellCssClass) ? ("") : (@" class=""" + PagerSelectedCellCssClass + @""""));
                }
                else
                {
                    cellClass = (string.IsNullOrEmpty(PagerCellCssClass) ? ("") : (@" class=""" + PagerCellCssClass + @""""));
                }
                _PagerRowHTML += (maxItemCounter >= MaxPagerItemsPerRow ? "</tr><tr>" : "") + @"<td" + cellClass
                                 + @" onclick=""" + Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this, (pageCount - 1).ToString())) + @""">" + (((pageCount - 1) * pageSize) + 1).ToString()
                                 + "&nbsp;-&nbsp;" + _TotalRowCount.ToString() + @"</td></tr></table>";
            }
            else
            {
                _ShowPager = false;
            }
            #endregion

            base.OnPreRender(e);
        }