Ejemplo n.º 1
0
        private ModelEvent ConvertToEvent(SQLiteEvent evt)
        {
            var modelEvent = _serializer.DeserializeFromBytes <ModelEvent>(evt.EventData);

            _modelEventProperties.SetEntityData <Guid>(modelEvent, evt.EventID, nameof(ModelEvent.EventID));
            _modelEventProperties.SetEntityData <string>(modelEvent, evt.EntityType, nameof(ModelEvent.EntityType));
            _modelEventProperties.SetEntityData <string>(modelEvent, evt.EntityID, nameof(ModelEvent.EntityID));
            StampEvent(modelEvent, evt.DeviceID, new VectorClock(evt.VectorClock));
            return(modelEvent);
        }
Ejemplo n.º 2
0
 public void StoreEvents(IEnumerable <ModelEvent> events)
 {
     using (var context = GetContext())
     {
         foreach (var evt in events)
         {
             SQLiteEvent sqlEvent = ConvertToStore(evt);
             context.Add(sqlEvent);
         }
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        private SQLiteEvent ConvertToStore(ModelEvent evt)
        {
            SQLiteEvent sqlEvent = new SQLiteEvent();

            sqlEvent.EventID     = evt.EventID;
            sqlEvent.EntityType  = evt.EntityType;
            sqlEvent.EntityID    = evt.EntityID;
            sqlEvent.DeviceID    = evt.DeviceID;
            sqlEvent.VectorClock = evt.EventVector.ToByteArray();
            sqlEvent.EventData   = _serializer.SerializeToBytes(evt, typeof(ModelEvent));

            return(sqlEvent);
        }