public static ToBson ( |
||
record | ||
리턴 | BsonDocument |
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 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 } }