Elmah.MySqlErrorLog.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 = new MySqlConnection(ConnectionString))
            using (var command = Commands.GetErrorsXml(ApplicationName, pageIndex, pageSize))
            {
                command.Connection = connection;
                connection.Open();

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

                    if (errorEntryList != null)
                    {
                        while (reader.Read())
                        {
                            var error = new Error();

                            error.ApplicationName = reader["Application"].ToString();
                            error.HostName = reader["Host"].ToString();
                            error.Type = reader["Type"].ToString();
                            error.Source = reader["Source"].ToString();
                            error.Message = reader["Message"].ToString();
                            error.User = reader["User"].ToString();
                            error.StatusCode = Convert.ToInt32(reader["StatusCode"]);
                            error.Time = Convert.ToDateTime(reader.GetString("TimeUtc")).ToLocalTime();

                            errorEntryList.Add(new ErrorLogEntry(this, reader["ErrorId"].ToString(), error));
                        }
                    }
                    reader.Close();
                }

                return (int)command.Parameters["TotalCount"].Value;
            }
        }