Elmah.OracleErrorLog.GetErrors C# (CSharp) Méthode

GetErrors() public méthode

Returns a page of errors from the databse in descending order of logged time.
public GetErrors ( int pageIndex, int pageSize, ICollection errorEntryList ) : int
pageIndex int
pageSize int
errorEntryList ICollection
Résultat int
        public override int GetErrors(int pageIndex, int pageSize, ICollection<ErrorLogEntry> errorEntryList)
        {
            if (pageIndex < 0)
                throw new ArgumentOutOfRangeException("pageIndex", pageIndex, null);

            if (pageSize < 0)
                throw new ArgumentOutOfRangeException("pageSize", pageSize, null);

            using (var connection = CreateOpenConnection())
            using (var command = connection.CreateCommand())
            {
                command.CommandText = SchemaOwner + "pkg_elmah$get_error.GetErrorsXml";
                command.CommandType = CommandType.StoredProcedure;

                var addParameter = command.ParameterAdder();
                addParameter("v_Application", DbType.String, ApplicationName);
                addParameter("v_PageIndex", DbType.Int32, pageIndex);
                addParameter("v_PageSize", DbType.Int32, pageSize);
                var totalCount = addParameter("v_TotalCount", DbType.Int32, Missing.Value);
                totalCount.Direction = ParameterDirection.Output;
                AddProviderSpecificTypeParameter(command, "v_Results", ThisProviderInfo.RefCursorDbType).Direction = ParameterDirection.Output;

                using (var reader = command.ExecuteReader())
                {
                    Debug.Assert(reader != null);

                    if (errorEntryList != null)
                    {
                        while (reader.Read())
                        {
                            var id = reader["ErrorId"].ToString();
                            var guid = new Guid(id);

                            var error = new Error
                            {
                                ApplicationName = reader["Application"].ToString(),
                                HostName = reader["Host"].ToString(),
                                Type = reader["Type"].ToString(),
                                Source = reader["Source"].ToString(),
                                Message = reader["Message"].ToString(),
                                User = reader["UserName"].ToString(),
                                StatusCode = Convert.ToInt32(reader["StatusCode"]),
                                Time = Convert.ToDateTime(reader["TimeUtc"]).ToLocalTime()
                            };

                            errorEntryList.Add(new ErrorLogEntry(this, guid.ToString(), error));
                        }
                    }
                    reader.Close();
                }

                return (int) totalCount.Value;
            }
        }