/// <summary> /// Returns the specified error from the database, or null /// if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Length == 0) { throw new ArgumentException(null, "id"); } Guid errorGuid; try { errorGuid = new Guid(id); } catch (FormatException e) { throw new ArgumentException(e.Message, "id", e); } string errorXml; using (OracleConnection connection = new OracleConnection(this.ConnectionString)) using (OracleCommand command = connection.CreateCommand()) { command.CommandText = SchemaOwner + "pkg_elmah$get_error.GetErrorXml"; command.CommandType = CommandType.StoredProcedure; OracleParameterCollection parameters = command.Parameters; parameters.Add("v_Application", OracleType.NVarChar, _maxAppNameLength).Value = ApplicationName; parameters.Add("v_ErrorId", OracleType.NVarChar, 32).Value = errorGuid.ToString("N"); parameters.Add("v_AllXml", OracleType.NClob).Direction = ParameterDirection.Output; connection.Open(); command.ExecuteNonQuery(); OracleLob xmlLob = (OracleLob)command.Parameters["v_AllXml"].Value; StreamReader streamreader = new StreamReader(xmlLob, Encoding.Unicode); char[] cbuffer = new char[1000]; int actual; StringBuilder sb = new StringBuilder(); while ((actual = streamreader.Read(cbuffer, 0, cbuffer.Length)) > 0) { sb.Append(cbuffer, 0, actual); } errorXml = sb.ToString(); } if (errorXml == null) { return(null); } Error error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); }
/// <summary> /// Returns the specified error from the database, or null /// if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Length == 0) { throw new ArgumentException(null, "id"); } int errorId; try { errorId = int.Parse(id, CultureInfo.InvariantCulture); } catch (FormatException e) { throw new ArgumentException(e.Message, "id", e); } catch (OverflowException e) { throw new ArgumentException(e.Message, "id", e); } string errorXml; using (OleDbConnection connection = new OleDbConnection(this.ConnectionString)) using (OleDbCommand command = connection.CreateCommand()) { command.CommandText = @"SELECT AllXml FROM ELMAH_Error WHERE ErrorId = @ErrorId"; command.CommandType = CommandType.Text; OleDbParameterCollection parameters = command.Parameters; parameters.Add("@ErrorId", OleDbType.Integer).Value = errorId; connection.Open(); errorXml = (string)command.ExecuteScalar(); } if (errorXml == null) { return(null); } Error error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); }
/// <summary> /// Returns the specified error from the database, or null /// if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Length == 0) { throw new ArgumentException(null, "id"); } Guid errorGuid; try { errorGuid = new Guid(id); } catch (FormatException e) { throw new ArgumentException(e.Message, "id", e); } string errorXml = null; using (var connection = new MySqlConnection(ConnectionString)) using (var command = Commands.GetErrorXml(ApplicationName, errorGuid)) { command.Connection = connection; connection.Open(); using (var reader = command.ExecuteReader()) { Debug.Assert(reader != null); while (reader.Read()) { errorXml = reader.GetString("AllXml"); } reader.Close(); } } if (errorXml == null) { return(null); } var error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); }
/// <summary> /// Returns the specified error from the database, or null /// if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Length == 0) { throw new ArgumentException(null, "id"); } Guid errorGuid; try { errorGuid = new Guid(id); } catch (FormatException e) { throw new ArgumentException(e.Message, "id", e); } string errorXml; using (var connection = CreateOpenConnection()) using (var command = connection.CreateCommand()) { command.CommandText = SchemaOwner + "pkg_elmah$get_error.GetErrorXml"; command.CommandType = CommandType.StoredProcedure; var addParameter = command.ParameterAdder(); addParameter("v_Application", DbType.String, ApplicationName); addParameter("v_ErrorId", DbType.String, errorGuid.ToString("N")); var allXml = AddProviderSpecificTypeParameter(command, "v_AllXml", ThisProviderInfo.ClobDbType); allXml.Direction = ParameterDirection.Output; command.ExecuteNonQuery(); errorXml = allXml.Value as string; if (errorXml == null) { // TODO Review whether Stream needs disposing var stream = (Stream)allXml.Value; var reader = new StreamReader(stream, Encoding.Unicode); errorXml = reader.ReadToEnd(); } } var error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); }
/// <summary> /// Returns the specified error from the database, or null /// if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Length == 0) { throw new ArgumentException(null, "id"); } Guid errorGuid; try { errorGuid = new Guid(id); } catch (FormatException e) { throw new ArgumentException(e.Message, "id", e); } const string sql = @" SELECT [AllXml] FROM [ELMAH_Error] WHERE [ErrorId] = @ErrorId"; using (SqlCeConnection connection = new SqlCeConnection(ConnectionString)) { using (SqlCeCommand command = new SqlCeCommand(sql, connection)) { command.Parameters.Add("@ErrorId", SqlDbType.UniqueIdentifier).Value = errorGuid; connection.Open(); string errorXml = (string)command.ExecuteScalar(); if (errorXml == null) { return(null); } Error error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); } } }
/// <summary> /// Returns the specified error from the database, or null /// if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Length == 0) { throw new ArgumentException(null, "id"); } long key; try { key = long.Parse(id, CultureInfo.InvariantCulture); } catch (FormatException e) { throw new ArgumentException(e.Message, "id", e); } const string sql = @" SELECT AllXml FROM Error WHERE ErrorId = @ErrorId"; using (SQLiteConnection connection = new SQLiteConnection(ConnectionString)) using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { SQLiteParameterCollection parameters = command.Parameters; parameters.Add("@ErrorId", DbType.Int64).Value = key; connection.Open(); string errorXml = (string)command.ExecuteScalar(); if (errorXml == null) { return(null); } Error error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); } }
/// <summary> /// Retrieves a single application error from log given its /// identifier, or null if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException("id"); } Guid errorGuid; try { errorGuid = new Guid(id); } catch (Exception e) { throw new ArgumentException(e.Message, "id", e); } string errorXml = null; using (MySqlConnection cn = new MySqlConnection(ConnectionString)) { using (MySqlCommand cmd = new MySqlCommand("Elmah_GetErrorXml", cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@pApplication", ApplicationName); cmd.Parameters.AddWithValue("@pErrorId", id); cn.Open(); using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { errorXml = reader["AllXml"].ToString(); } } } } if (string.IsNullOrEmpty(errorXml)) { return(null); } Error error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); }
/// <summary> /// Returns the specified error from the database, or null /// if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Length == 0) { throw new ArgumentException(null, "id"); } Guid errorGuid; try { errorGuid = new Guid(id); } catch (FormatException e) { throw new ArgumentException(e.Message, "id", e); } string errorXml; using (SqlConnection connection = new SqlConnection(this.ConnectionString)) using (SqlCommand command = Commands.GetErrorXml(this.ApplicationName, errorGuid)) { command.Connection = connection; connection.Open(); errorXml = (string)command.ExecuteScalar(); } if (errorXml == null) { return(null); } Error error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); }
public override ErrorLogEntry GetError(string id) { ErrorLogEntry result; ErrorDocument document; using (var session = _documentStore.OpenSession()) { document = session.Load <ErrorDocument>(id); } if (!string.IsNullOrEmpty(document.ErrorXml)) { result = new ErrorLogEntry(this, id, ErrorXml.DecodeString(document.ErrorXml)); } else { result = new ErrorLogEntry(this, id, document.Error); } return(result); }
public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList) { if (pageIndex < 0) { throw new ArgumentOutOfRangeException("pageIndex", pageIndex, null); } if (pageSize < 0) { throw new ArgumentOutOfRangeException("pageSize", pageSize, null); } using (NpgsqlConnection connection = new NpgsqlConnection(ConnectionString)) { connection.Open(); using (NpgsqlCommand command = Commands.GetErrorsXml(this.ApplicationName, pageIndex, pageSize)) { command.Connection = connection; using (NpgsqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { string id = reader.GetString(0); string xml = reader.GetString(1); Error error = ErrorXml.DecodeString(xml); errorEntryList.Add(new ErrorLogEntry(this, id, error)); } } } using (NpgsqlCommand command = Commands.GetErrorsXmlTotal(this.ApplicationName)) { command.Connection = connection; return(Convert.ToInt32(command.ExecuteScalar())); } } }
/// <summary> /// Returns the specified error from the database, or null /// if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { if (id == null) { throw new ArgumentNullException("id"); } if (id.Length == 0) { throw new ArgumentException(null, "id"); } int errorId; try { errorId = int.Parse(id, CultureInfo.InvariantCulture); } catch (FormatException e) { throw new ArgumentException(e.Message, "id", e); } catch (OverflowException e) { throw new ArgumentException(e.Message, "id", e); } string errorXml; using (VistaDBConnection connection = new VistaDBConnection(this.ConnectionString)) using (VistaDBCommand command = connection.CreateCommand()) { command.CommandText = @"SELECT AllXml FROM ELMAH_Error WHERE ErrorId = @ErrorId"; command.CommandType = CommandType.Text; VistaDBParameterCollection parameters = command.Parameters; parameters.Add("@ErrorId", VistaDBType.Int).Value = errorId; connection.Open(); // NB this has been deliberately done like this as command.ExecuteScalar // is not exhibiting the expected behaviour in VistaDB at the moment using (VistaDBDataReader dr = command.ExecuteReader()) { if (dr.Read()) { errorXml = dr[0] as string; } else { errorXml = null; } } } if (errorXml == null) { return(null); } Error error = ErrorXml.DecodeString(errorXml); return(new ErrorLogEntry(this, id, error)); }