Esempio n. 1
0
 /// <summary>
 /// To Bson
 /// </summary>
 public static BsonDocument ToBson(EventHandlerRecord record)
 {
     return new BsonDocument
     {
         { "HandlerId", record.HandlerId ?? "" },
         { "EventId", record.EventId ?? "" },
         { "CommandId", record.CommandId ?? "" },
         { "TypeName", record.TypeName ?? "" },
         { "StartedDate", record.StartedDate },
         { "EndedDate", record.EndedDate },
         { "ErrorMessage", record.ErrorMessage ?? "" },
         { "ErrorStackTrace", record.ErrorStackTrace ?? "" },
     };
 }
Esempio n. 2
0
        public static EventHandlerRecord FromBson(BsonDocument doc)
        {
            var handler = new EventHandlerRecord
            {
                HandlerId = doc.GetString("HandlerId"),
                EventId = doc.GetString("EventId"),
                CommandId = doc.GetString("CommandId"),
                TypeName = doc.GetString("TypeName"),
                StartedDate = doc.GetDateTime("StartedDate"),
                EndedDate = doc.GetDateTime("EndedDate"),
                ErrorMessage = doc.GetString("ErrorMessage"),
                ErrorStackTrace = doc.GetString("ErrorStackTrace"),
            };

            return handler;
        }
Esempio n. 3
0
        public void LogEventHandler(EventHandlerRecord record)
        {
            try
            {
                var handlerDoc = EventHandlerRecord.ToBson(record);

                var query = Query.And(
                    Query.EQ("_id", record.CommandId),
                    Query.EQ("Events.Event.Metadata.EventId", record.EventId)
                );

                var update = Update.Push("Events.$.Handlers", handlerDoc);

                if (record.ErrorMessage != "")
                    update.Inc("Errors", 1);

                Logs.Logs.Update(query, update);
            }
            catch(Exception)
            {
                // Catch all errors because logging should not throw errors if unsuccessful
            }
        }