コード例 #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 ?? "" },
     };
 }
コード例 #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 ?? "" },
     });
 }
コード例 #3
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;
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #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
            }
        }
コード例 #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
            }
        }