Acropolis.Foundation.EventSourcing.Logging.LogManager.LogCommand C# (CSharp) Méthode

LogCommand() public méthode

Log command
public LogCommand ( Command command ) : void
command Command
Résultat void
        public void LogCommand(Command command)
        {
            try
            {
                // Initialize command TypeName if not already initialized
                if (String.IsNullOrEmpty(command.Metadata.TypeName))
                    command.Metadata.TypeName = command.GetTypeName();

                var commandDocument = command.ToBsonDocument();

                // Removing _t element (generated by mongodb driver)
                commandDocument.Remove("_t");

                var record = new BsonDocument
                {
                    { "_id", command.Metadata.CommandId },
                    { "Command", commandDocument },
                    { "Handlers", new BsonArray() },
                    { "Events", new BsonArray() }
                };

                Write.Logs.Insert(record);
            }
            catch(Exception e)
            {
                // Catch all errors because logging should not throw errors if unsuccessful
            }
        }