//recieving public void RecieveMessage(object sender, EventArgs eventArgs) { MessengingEventArgs<MeasuringMessage> messengingEventArgs = eventArgs as MessengingEventArgs<MeasuringMessage>; if (messengingEventArgs != null) { MeasuringMessage recievedMessage = messengingEventArgs.Object; if (recievedMessage.MessageType == MessageTypeEnum.CriticalInfo) { MongoMessage mongoMessage = new MongoMessage(recievedMessage); MongoDbAccessor.AddMongoMessage(mongoMessage); } } }
public void AddMongoMessage(MongoMessage mongoMessage) { IMongoCollection<BsonDocument> messagesCollection = GetMongoCollection("messages"); messagesCollection.InsertOneAsync(mongoMessage.ToBsonDocument()); }