コード例 #1
0
ファイル: Client.cs プロジェクト: polchuk/Sync
        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);
            }
        }
コード例 #2
0
ファイル: Client.cs プロジェクト: polchuk/Sync
        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;
            }
        }
コード例 #3
0
ファイル: Client.cs プロジェクト: polchuk/Sync
        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;
            }
        }
コード例 #4
0
ファイル: Client.cs プロジェクト: polchuk/Sync
        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);
            }
        }
コード例 #5
0
ファイル: Client.cs プロジェクト: polchuk/Sync
        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;
            }
        }
コード例 #6
0
ファイル: Server.cs プロジェクト: polchuk/Sync
        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;
            }
        }
コード例 #7
0
ファイル: Server.cs プロジェクト: polchuk/Sync
        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;
            }
        }
コード例 #8
0
ファイル: Server.cs プロジェクト: polchuk/Sync
        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;
        }
コード例 #9
0
ファイル: Client.cs プロジェクト: polchuk/Sync
        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);
        }
コード例 #10
0
ファイル: Server.cs プロジェクト: polchuk/Sync
        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);
        }
コード例 #11
0
        /// <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);
        }
コード例 #12
0
ファイル: ServerProxy.cs プロジェクト: polchuk/Sync
        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));
        }
コード例 #13
0
ファイル: ServerProxy.cs プロジェクト: polchuk/Sync
        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);
        }
コード例 #14
0
            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();
            }
コード例 #15
0
ファイル: Server.cs プロジェクト: polchuk/Sync
 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;
 }
コード例 #16
0
ファイル: Server.cs プロジェクト: polchuk/Sync
        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);
        }
コード例 #17
0
ファイル: Server.cs プロジェクト: polchuk/Sync
 private void Delete(Entity entity, ISyncEntity proxy)
 {
     entity.ClientModifyDate = proxy.ClientModifyDate;
     entity.ServerSyncDate = DateTime.UtcNow;
     entity.IsDeleted = true;
 }
コード例 #18
0
ファイル: Server.cs プロジェクト: polchuk/Sync
 private void Delete(Entity entity, ISyncEntity proxy)
 {
     entity.ClientModifyDate = proxy.ClientModifyDate;
     entity.ServerSyncDate   = DateTime.UtcNow;
     entity.IsDeleted        = true;
 }
コード例 #19
0
ファイル: Client.cs プロジェクト: polchuk/Sync
        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;
            }
        }
コード例 #20
0
ファイル: Client.cs プロジェクト: polchuk/Sync
        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);
        }
コード例 #21
0
ファイル: ISyncPlugin.cs プロジェクト: oathx/Six
	/// <summary>
	/// Unregisters the entity.
	/// </summary>
	/// <param name="entity">Entity.</param>
	public void 			UnregisterEntity(ISyncEntity entity)
	{
		m_dEntity.Remove(entity);
	}
コード例 #22
0
        /// <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);
        }
コード例 #23
0
ファイル: ISyncPlugin.cs プロジェクト: oathx/Six
	/// <summary>
	/// Registers the AO.
	/// </summary>
	/// <param name="aoi">Aoi.</param>
	public virtual void 	RegisterEntity(ISyncEntity entity)
	{
		// ref the aoi object
		m_dEntity.Add(entity);
	}