Esempio n. 1
0
        private static string GetTransactionEventTypeString(TransactionEvent transactionEvent)
        {
            if (transactionEvent is UserCommandEvent)
            {
                return(EventType.UserCommandEvent);
            }
            if (transactionEvent is QuoteServerEvent)
            {
                return(EventType.QuoteServerEvent);
            }
            if (transactionEvent is AccountTransactionEvent)
            {
                return(EventType.AcccountTransactionEvent);
            }
            if (transactionEvent is SystemEvent)
            {
                return(EventType.SystemEvent);
            }
            if (transactionEvent is ErrorEvent)
            {
                return(EventType.ErrorEvent);
            }
            if (transactionEvent is DebugEvent)
            {
                return(EventType.DebugEvent);
            }

            throw new UnrecognizedTransactionEventException(transactionEvent.GetType().ToString());
        }
        private static string GetTransactionEventTypeString(TransactionEvent transactionEvent)
        {
            if (transactionEvent is UserCommandEvent)
                return EventType.UserCommandEvent;
            if (transactionEvent is QuoteServerEvent)
                return EventType.QuoteServerEvent;
            if (transactionEvent is AccountTransactionEvent)
                return EventType.AcccountTransactionEvent;
            if (transactionEvent is SystemEvent)
                return EventType.SystemEvent;
            if (transactionEvent is ErrorEvent)
                return EventType.ErrorEvent;
            if (transactionEvent is DebugEvent)
                return EventType.DebugEvent;

            throw new UnrecognizedTransactionEventException(transactionEvent.GetType().ToString());
        }
        public void LogTransactionEvent(TransactionEvent transactionEvent)
        {
            if (transactionEvent is UserCommandEvent)
            {
                LogUserCommandEvent(transactionEvent as UserCommandEvent);
                return;
            }

            if (transactionEvent is QuoteServerEvent)
            {
                LogQuoteServerEvent(transactionEvent as QuoteServerEvent);
                return;
            }

            if (transactionEvent is AccountTransactionEvent)
            {
                LogAccountTransactionEvent(transactionEvent as AccountTransactionEvent);
                return;
            }

            if (transactionEvent is SystemEvent)
            {
                LogSystemEvent(transactionEvent as SystemEvent);
                return;
            }

            if (transactionEvent is ErrorEvent)
            {
                LogErrorEvent(transactionEvent as ErrorEvent);
                return;
            }

            if (transactionEvent is DebugEvent)
            {
                LogDebugEvent(transactionEvent as DebugEvent);
                return;
            }
        }
 public void LogTransactionEvent(TransactionEvent transactionEvent)
 {
     transactionEvent.LoggedAt = DateTime.UtcNow;
     _eventCollection.InsertOne(transactionEvent);
 }
 private void FillBaseEventPropertiesFromRecord(TransactionEvent te, NpgsqlDataReader reader)
 {
     te.LoggedAt = reader.GetDateTime(1);
     te.OccuredAt = reader.GetDateTime(2);
     te.TransactionId = reader.GetInt32(4);
     te.UserId = (reader.IsDBNull(5)) ? null : reader.GetString(5);
     te.Service = reader.GetString(6);
     te.Server = reader.GetString(7);
 }
        private static void AddCommonEventPropertyParametersToCommand(NpgsqlCommand command, TransactionEvent transactionEvent)
        {
            command.Parameters.Add(new NpgsqlParameter
            {
                NpgsqlDbType = NpgsqlDbType.TimestampTZ,
                Value = transactionEvent.OccuredAt
            });

            command.Parameters.Add(new NpgsqlParameter
            {
                NpgsqlDbType = NpgsqlDbType.Integer,
                Value = transactionEvent.TransactionId
            });

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

            command.Parameters.Add(new NpgsqlParameter
            {
                NpgsqlDbType = NpgsqlDbType.Varchar,
                Value = transactionEvent.Service
            });

            command.Parameters.Add(new NpgsqlParameter
            {
                NpgsqlDbType = NpgsqlDbType.Varchar,
                Value = transactionEvent.Server
            });
        }