public void LogUserCommandEvent(UserCommandEvent userCommandEvent) { using (var command = new NpgsqlCommand("log_user_command_event")) { Log.DebugFormat("Inserting user command event {0} into databse...", userCommandEvent.Id); command.CommandType = System.Data.CommandType.StoredProcedure; AddCommonEventPropertyParametersToCommand(command, userCommandEvent); command.Parameters.Add(new NpgsqlParameter { Value = userCommandEvent.Command }); command.Parameters.Add(new NpgsqlParameter { NpgsqlDbType = NpgsqlDbType.Char, Value = ((object)userCommandEvent.StockSymbol) ?? DBNull.Value }); command.Parameters.Add(new NpgsqlParameter { NpgsqlDbType = NpgsqlDbType.Money, Value = ((object)userCommandEvent.Funds) ?? DBNull.Value }); int id = ExecuteInsertCommand(command); Log.DebugFormat(CultureInfo.InvariantCulture, "Successfully inserted user command event {0} (database id = {1}).", userCommandEvent.Id, id); } }
private UserCommandEvent GetUserCommandEventFromRecord(NpgsqlDataReader reader) { var userCommandEvent = new UserCommandEvent { Command = (CommandType)reader.GetValue(8), StockSymbol = (reader.IsDBNull(9)) ? null : reader.GetString(9), Funds = (reader.IsDBNull(10)) ? null : (decimal?)reader.GetDecimal(10) }; FillBaseEventPropertiesFromRecord(userCommandEvent, reader); return(userCommandEvent); }
private void LogDumplogEvent(Request request, string userId) { string transactionNumberHeader = request.Headers["X-TransNo"].FirstOrDefault(); if (String.IsNullOrEmpty(transactionNumberHeader)) { return; } int transactionId = Int32.Parse(transactionNumberHeader); var dumplogEvent = new UserCommandEvent { Id = Guid.NewGuid(), TransactionId = transactionId, Command = CommandType.DUMPLOG, UserId = userId, Service = "Transaction Monitor", Server = _hostName, OccuredAt = DateTime.Now }; _repository.LogTransactionEvent(dumplogEvent); }