public void ApplyChangeFromServer(ISyncEntity proxy) { Entity entity = null; foreach (var e in List) { if (e.ID == proxy.ID) { entity = e; break; } } if (entity != null) { if (proxy.IsDeleted) { Delete(entity); } else { Update(proxy, entity); } } else { Create(proxy); } }
public void SetClientEntitySynced(ISyncEntity entity, DateTime server_last_sync_date) { Entity e = null; foreach (var e_tmp in List) { if (e_tmp.ID == entity.ID) { e = e_tmp; break; } } if (e == null) return; if (e.IsDeleted) { List.Remove(e); } //check if entity was not modified localy while sending to server else if (e.ClientModifyDate == entity.ClientModifyDate) { e.ServerSyncDate = server_last_sync_date; e.IsModified = false; } }
public void SetClientEntitySynced(ISyncEntity entity, DateTime server_last_sync_date) { Entity e = null; foreach (var e_tmp in List) { if (e_tmp.ID == entity.ID) { e = e_tmp; break; } } if (e == null) { return; } if (e.IsDeleted) { List.Remove(e); } //check if entity was not modified localy while sending to server else if (e.ClientModifyDate == entity.ClientModifyDate) { e.ServerSyncDate = server_last_sync_date; e.IsModified = false; } }
private void Update(ISyncEntity proxy, Entity entity) { if (entity.ClientModifyDate < proxy.ClientModifyDate) { entity.ClientModifyDate = proxy.ClientModifyDate; entity.ServerSyncDate = proxy.ServerSyncDate; entity.Data = ((IEntity)proxy).Data; } }
private void Update(Entity entity, ISyncEntity proxy) { if (!entity.IsDeleted && entity.ClientModifyDate < proxy.ClientModifyDate) { entity.ClientModifyDate = proxy.ClientModifyDate; entity.ServerSyncDate = DateTime.UtcNow; entity.Data = ((IEntity)proxy).Data; } }
private Entity Create(ISyncEntity proxy) { var entity = new Entity(proxy.ID); entity.ClientModifyDate = proxy.ClientModifyDate; entity.ServerSyncDate = DateTime.UtcNow; entity.Data = ((IEntity)proxy).Data; List.Add(entity.ID, entity); return entity; }
private void Create(ISyncEntity proxy) { var entity = new Entity(proxy.ID); entity.ClientModifyDate = proxy.ClientModifyDate; entity.ServerSyncDate = proxy.ServerSyncDate; entity.Data = ((IEntity)proxy).Data; List.Add(entity); }
private Entity Create(ISyncEntity proxy) { var entity = new Entity(proxy.ID); entity.ClientModifyDate = proxy.ClientModifyDate; entity.ServerSyncDate = DateTime.UtcNow; entity.Data = ((IEntity)proxy).Data; List.Add(entity.ID, entity); return(entity); }
/// <summary> /// Fills up index 200. Creation of transaction, synchronization of the table and transaction commit is outside of this function. /// Entity desired ID and SyncTimestamp must be specified /// </summary> /// <param name="tran"></param> /// <param name="table">Where must be stored index 200</param> /// <param name="entity">entity.Id and entity.SyncTimestamp must be filled up</param> /// <param name="ptrEntityContent">pointer to the entity content (16 bytes) gathered with DBreeze InsertDataBlockWithFixedAddress</param> /// <param name="oldEntity">old instance of the entity from DB !!!MUST!!! be supplied when update or null when new entity</param> public static void InsertIndex4Sync(DBreeze.Transactions.Transaction tran, string table, T entity, byte[] ptrEntityContent, T oldEntity) { ISyncEntity ent = ((ISyncEntity)entity); if (oldEntity == null) { tran.Insert <byte[], byte[]>(table, 200.ToIndex(ent.Id), ptrEntityContent); } //Adding to value one byte indicating that this is a new entity tran.Insert <byte[], byte[]>(table, 201.ToIndex(ent.SyncTimestamp, ent.Id), (oldEntity == null) ? new byte[] { 1 } : null); }
public DateTime SendChangedToServer(ISyncEntity entity) { // Create server proxy from client entity var proxy = new ServerEntity() { ID = entity.ID, ClientModifyDate = entity.ClientModifyDate, IsDeleted = entity.IsDeleted, Data = ((Client.IEntity)entity).Data }; return(Server.ServerImpl.Instance.SendChangedToServer(proxy)); }
public DateTime SendChangedToServer(ISyncEntity entity) { // Create server proxy from client entity var proxy = new ServerEntity() { ID = entity.ID, ClientModifyDate = entity.ClientModifyDate, IsDeleted = entity.IsDeleted, Data = ((Client.IEntity)entity).Data }; return Server.ServerImpl.Instance.SendChangedToServer(proxy); }
public void Synchronize() { EntityTypeEnum entityType = EntityTypeEnum.Hierarchy; var type = $@"teste.Sync{entityType.ToString()}"; var coco = System.Reflection.Assembly.GetExecutingAssembly().FullName; var tata = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; Entity = (ISyncEntity)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(type); var teste = GetInstance(type); Entity.SynchronizeAll(); }
public DateTime SendChangedToServer(ISyncEntity proxy) { Entity entity = null; if (List.ContainsKey(proxy.ID)) { entity = List[proxy.ID]; if (proxy.IsDeleted) Delete(entity, proxy); else Update(entity, proxy); } else { entity = Create(proxy); } return entity.ServerSyncDate; }
public DateTime SendChangedToServer(ISyncEntity proxy) { Entity entity = null; if (List.ContainsKey(proxy.ID)) { entity = List[proxy.ID]; if (proxy.IsDeleted) { Delete(entity, proxy); } else { Update(entity, proxy); } } else { entity = Create(proxy); } return(entity.ServerSyncDate); }
private void Delete(Entity entity, ISyncEntity proxy) { entity.ClientModifyDate = proxy.ClientModifyDate; entity.ServerSyncDate = DateTime.UtcNow; entity.IsDeleted = true; }
/// <summary> /// Unregisters the entity. /// </summary> /// <param name="entity">Entity.</param> public void UnregisterEntity(ISyncEntity entity) { m_dEntity.Remove(entity); }
/// <summary> /// Fills up index 200. Creation of transaction, synchronization of the table and transaction commit is outside of this function. /// Entity desired ID and SyncTimestamp must be specified /// </summary> /// <param name="tran"></param> /// <param name="table">Where must be stored index 200</param> /// <param name="entity">entity.Id and entity.SyncTimestamp must be filled up</param> /// <param name="ptrEntityContent">pointer to the entity content (16 bytes) gathered with DBreeze InsertDataBlockWithFixedAddress</param> /// <param name="oldEntity">old instance of the entity from DB !!!MUST!!! be supplied when update or null when new entity</param> public static void InsertIndex4Sync(DBreeze.Transactions.Transaction tran, string table, ISyncEntity entity, byte[] ptrEntityContent, ISyncEntity oldEntity) { if (oldEntity == null) { tran.Insert <byte[], byte[]>(table, 200.ToIndex(entity.Id), ptrEntityContent); } tran.Insert <byte[], byte[]>(table, 201.ToIndex(entity.SyncTimestamp, entity.Id), null); }
/// <summary> /// Registers the AO. /// </summary> /// <param name="aoi">Aoi.</param> public virtual void RegisterEntity(ISyncEntity entity) { // ref the aoi object m_dEntity.Add(entity); }