/// <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 ?? "" },
     };
 }
Example #2
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 ?? "" },
     });
 }
        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;
        }
Example #4
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);
        }
Example #5
0
        /// <summary>
        /// From Bson
        /// </summary>
        public static EventHandlerRecordCollection FromBson(BsonValue doc)
        {
            var list = new List <EventHandlerRecord>();

            if (!doc.IsBsonArray)
            {
                return(new EventHandlerRecordCollection(list));
            }

            var evnts = doc.AsBsonArray;

            foreach (var evnt in evnts)
            {
                list.Add(EventHandlerRecord.FromBson(evnt.AsBsonDocument));
            }

            return(new EventHandlerRecordCollection(list));
        }
Example #6
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);
                Write.Logs.Update(query, update);
            }
            catch (Exception e)
            {
                // Catch all errors because logging should not throw errors if unsuccessful
            }
        }
Example #7
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);
                Write.Logs.Update(query, update);
            }
            catch(Exception e)
            {
                // Catch all errors because logging should not throw errors if unsuccessful
            }
        }