Exemplo n.º 1
0
 private DebugEvent GetDebugEventFromRecord(NpgsqlDataReader reader)
 {
     var debugEvent = new DebugEvent
     {
         Command = (CommandType)reader.GetValue(8),
         StockSymbol = (reader.IsDBNull(9)) ? null : reader.GetString(9),
         Funds = (reader.IsDBNull(10)) ? null : (decimal?) reader.GetDecimal(10),
         FileName = (reader.IsDBNull(11)) ? null : reader.GetString(11),
         DebugMessage = (reader.IsDBNull(12)) ? null : reader.GetString(12)
     };
     FillBaseEventPropertiesFromRecord(debugEvent, reader);
     return debugEvent;
 }
Exemplo n.º 2
0
        public void LogDebugEvent(DebugEvent debugEvent)
        {
            using (var command = new NpgsqlCommand("log_debug_event"))
            {
                Log.DebugFormat("Inserting debug event {0} into databse...", debugEvent.Id);

                command.CommandType = System.Data.CommandType.StoredProcedure;

                AddCommonEventPropertyParametersToCommand(command, debugEvent);

                command.Parameters.Add(new NpgsqlParameter
                {
                    NpgsqlDbType = NpgsqlDbType.Enum,
                    Value = debugEvent.Command
                });

                command.Parameters.Add(new NpgsqlParameter
                {
                    NpgsqlDbType = NpgsqlDbType.Char,
                    Value = ((object) debugEvent.StockSymbol) ?? DBNull.Value
                });

                command.Parameters.Add(new NpgsqlParameter
                {
                    NpgsqlDbType = NpgsqlDbType.Money,
                    Value = ((object) debugEvent.Funds) ?? DBNull.Value
                });

                command.Parameters.Add(new NpgsqlParameter
                {
                    NpgsqlDbType = NpgsqlDbType.Varchar,
                    Value = ((object) debugEvent.FileName) ?? DBNull.Value
                });

                command.Parameters.Add(new NpgsqlParameter
                {
                    NpgsqlDbType = NpgsqlDbType.Varchar,
                    Value = ((object) debugEvent.DebugMessage) ?? DBNull.Value
                });

                int id = ExecuteInsertCommand(command);

                Log.DebugFormat(CultureInfo.InvariantCulture,
                    "Successfully inserted debug event {0} (database id = {1}).", debugEvent.Id, id);
            }
        }