Ejemplo n.º 1
0
        /// <summary>
        /// Gets the exception page.
        /// </summary>
        /// <param name="applicationId">The application id.</param>
        /// <param name="pageSize">The amount of record rows to retrieve.</param>
        /// <param name="pageIndex">The index of the page to retrieve.</param>
        /// <param name="rowCount">The total amount of rows of the exception table.</param>
        /// <param name="appLocationFilter">The ApplicationLocation to filter. Set this value to -1 if you don't want to filter by application locations.</param>
        /// <param name="handlingStatus">The handling status of this exception. Set this value to -1 if you don't want to filter by handling status.</param>
        /// <param name="orderBy">The order by.</param>
        /// <returns></returns>
        public static LogDatasets.ExceptionLogDataTable GetExceptionPage(int applicationId, int pageSize, int pageIndex, out int?rowCount, int appLocationFilter, int handlingStatus
                                                                         , ExceptionsOrderBy orderBy)
        {
            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("@HandlingStatus", handlingStatus);
            dam.AddOutPutParameter("@RowCount", SqlDbType.Int);
            dam.AddInputParameter("@OrderBy", (int)orderBy);

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

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

            return(dt);
        }
Ejemplo n.º 2
0
        public void Test_LogException()
        {
            Trace.WriteLine(Configuration.GetGenericHeader());

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

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

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            LogManager.LogException(ApplicationLocation.Application, ExceptionHandlingStatus.Unhandled, new Exception(GetTestMessage(testId)));
            stopwatch.Stop();
            Trace.WriteLine("Exception Log insert time: " + stopwatch.Elapsed.ToString());

            int?newRowCount = 0;

            LogDatasets.ExceptionLogDataTable dt = LogManager.GetExceptionPage(10, 0, out newRowCount);
            Assert.IsTrue(newRowCount > oldRowCount);
            Assert.IsTrue(dt[0].ExceptionMessage.IndexOf(GetTestMessage(testId)) > 0);
            Trace.WriteLine(Configuration.GetGenericFooter());
        }
Ejemplo 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);
            _ExceptionLogTable = LogManager.GetExceptionPage(
                pageSize
                , this.PageIndex
                , out _TotalRowCount
                , (string.IsNullOrEmpty(_DDLApplicationLocations.SelectedValue) ? -1 : int.Parse(_DDLApplicationLocations.SelectedValue))
                , (string.IsNullOrEmpty(_DDLHandlingStatus.SelectedValue) ? -1 : int.Parse(_DDLHandlingStatus.SelectedValue))
                , (string.IsNullOrEmpty(_DDLOrderBy.SelectedValue)
                    ? LogManager.ExceptionsOrderBy.DateCreatedDesc
                    : (LogManager.ExceptionsOrderBy)Enum.Parse(typeof(LogManager.ExceptionsOrderBy), _DDLOrderBy.SelectedValue)));
            #endregion

            #region styling
            if (this.UseDefaultStyling)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ExceptionLogViewSyles",
                                                            @"
<style type=""text/css"">
<!--
.ExceptionLogView {
}
.ExceptionLogView table {
	border: Solid 1px #FCFCFC;
	width: 802px;
}
.ExceptionLogView table th {
	text-align: center;
	font-weight: bold;
	padding: 3px 4px 3px 4px;
	border: Solid 1px #212121;
}
.ExceptionLogView table td {
	padding: 1px 4px 1px 4px;
	border: Solid 1px #212121;
}
.ExceptionLogViewPager {
	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;
}
.ExceptionLogViewPager table {
	width: 780px;
}
.ExceptionLogViewPager table td {
	cursor: pointer;
}
.ExceptionLogViewPagerCell {
}
.ExceptionLogViewPagerCellSelected {
	background-color: #FEC654;
}
.ExceptionLogViewCell {
	text-align: left;
}
.ExceptionLogViewCell p {
	padding: 1px 0px 1px 0px;
    margin: 0px;
}
.ExceptionLogViewFilter {
	display: inline;
	float: left;
	clear: none;
	border: Solid 1px #212121;
	padding: 2px 6px 2px 6px;
	background-color: #33FF99;
}
.ExceptionLogViewDelete {
	display: block;
	float: left;
	clear: both;
	border: Solid 1px #212121;
	padding: 2px 6px 2px 6px;
	margin-top: 4px;
	background-color: #CC66FF;
}
-->
</style>
", false);
                this.CssClass = "ExceptionLogView";
                this.ExceptionCellCssClass     = "ExceptionLogViewCell";
                this.DeleteCellCssClass        = "ExceptionLogViewDelete";
                this.FilterCssClass            = "ExceptionLogViewFilter";
                this.PagerCssClass             = "ExceptionLogViewPager";
                this.PagerCellCssClass         = "ExceptionLogViewPagerCell";
                this.PagerSelectedCellCssClass = "ExceptionLogViewPagerCellSelected";
            }
            #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, GETPAGE_ARGUMENT + POSTBACK_SEPARATOR.ToString() + (i - 1).ToString())) + "\">&lt; previous</a>&nbsp;|&nbsp;"))
                                        + "<a onclick=\"" + Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this, GETPAGE_ARGUMENT + POSTBACK_SEPARATOR.ToString() + (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, GETPAGE_ARGUMENT + POSTBACK_SEPARATOR.ToString() + 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, GETPAGE_ARGUMENT + POSTBACK_SEPARATOR.ToString() + (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, GETPAGE_ARGUMENT + POSTBACK_SEPARATOR.ToString() + (pageCount - 1).ToString())) + @""">" + (((pageCount - 1) * pageSize) + 1).ToString()
                                 + "&nbsp;-&nbsp;" + _TotalRowCount.ToString() + @"</td></tr></table>";
            }
            else
            {
                _ShowPager = false;
            }
            #endregion

            if (!this.Page.ClientScript.IsClientScriptBlockRegistered("EV_MarkAs"))
            {
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "EV_MarkAs",
                                                                 @"
function __UpdateExceptionStatus(dropDownId, exceptionId) {
    var o = document.getElementById(dropDownId);
    if (o != null) {
        __doPostBack('" + this.UniqueID + @"', '" + UPDATE_RECORDS_ARGUMENT + POSTBACK_SEPARATOR.ToString() + @"' + exceptionId + '" + POSTBACK_SEPARATOR.ToString() + @"' + o.options[o.selectedIndex].value);
        return true;
    }    
    alert('DropDown not found.');
    return false;
}
", true);
            }
            base.OnPreRender(e);
        }