Пример #1
0
        /// <summary>
        /// Customs the fill.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="dataReader">The data reader.</param>
        /// <param name="fullyPopulate">if set to <c>true</c> [fully populate].</param>
        private static void CustomFill(LogEntry item, IDataReader dataReader, bool fullyPopulate)
        {
            foreach (object value in Enum.GetValues(typeof(TraceEventType)))
            {
                if (dataReader["Severity"].ToString().Equals(Enum.GetName(typeof(TraceEventType), value)))
                {
                    item.Severity = (TraceEventType)value;
                    break;
                }
            }

            ErrorType relatedErrorType;

            if (errorTypes == null || errorTypes.Count == 0)
            {
                relatedErrorType = ErrorTypeController.GetErrorType(item.ErrorType, "", item.CategoryName);
                if (relatedErrorType != null)
                {
                    errorTypes = new List <ErrorType>();
                    errorTypes.Add(relatedErrorType);
                }
            }
            else
            {
                //Set the RequiresAcknowledgement flag. This
                //this is done by trying to relate an error type to the log entry. If a related error type is found
                //then that item will state whether Acknowledgement is required
                //a list of error types should have been loaded up front in the calling controller method, this will stop the need to go to
                //the database for each log entry to try and recieve it's related error type
                relatedErrorType = errorTypes.Find(delegate(ErrorType errorType) { return(errorType.ExceptionType == item.ErrorType); });
            }


            item.RequiresAcknowledgement = relatedErrorType != null && relatedErrorType.RequiresAcknowledgement;
        }
Пример #2
0
        /// <summary>
        /// Gets the log entries.
        /// </summary>
        /// <param name="searchCriteria">The search criteria.</param>
        /// <param name="sortExpression">The sort expression.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maximumRows">The maximum rows.</param>
        /// <param name="totalRows">The total rows.</param>
        /// <param name="fullyPopulate">if set to <c>true</c> [fully populate].</param>
        /// <returns></returns>
        public static List <LogEntry> GetLogEntries(LogEntryCriteria searchCriteria,
                                                    string sortExpression,
                                                    int startRowIndex,
                                                    int maximumRows,
                                                    out int totalRows,
                                                    bool fullyPopulate)
        {
            List <LogEntry> logEntries = new List <LogEntry>();
            int             rows       = 0;

            try
            {
                //pre load an error type collection as this will be used in the custom fill method, this should be
                //more efficient than finding a related error type for each log entryone at a time
                if (searchCriteria.OpcoCode != Null.NullString && searchCriteria.CategoryName != Null.NullString &&
                    searchCriteria.ErrorType != Null.NullString)
                {
                    ErrorType errorType =
                        ErrorTypeController.GetErrorType(searchCriteria.ErrorType, searchCriteria.OpcoCode,
                                                         searchCriteria.CategoryName);

                    if (errorType != null)
                    {
                        errorTypes = new List <ErrorType>();
                        errorTypes.Add(errorType);
                    }
                }
                else
                {
                    errorTypes = ErrorTypeController.GetErrorTypes(searchCriteria.OpcoCode, searchCriteria.CategoryName, "");
                }

                logEntries =
                    CBO <LogEntry> .FillCollection(
                        DataAccessProvider.Instance(DATAPROVIDER).GetLogEntries(searchCriteria, sortExpression, startRowIndex, maximumRows, out rows),
                        CustomFill,
                        fullyPopulate);

                errorTypes.Clear();
                errorTypes = null;
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "Business Logic"))
                {
                    throw;
                }
            }
            totalRows = rows;
            return(logEntries);
        }