Example #1
0
 public TruncateState(SyncContainer owner) : base(owner)
 {
     foreach (SyncContainer sc in StateOwner.Children)
     {
         sc.Truncate();
     }
 }
Example #2
0
        protected override void SynchronizeImpl()
        {
            ISerializableObject source = StateOwner.SourceObject;
            ISerializableObject sink   = StateOwner.SinkSerializer.CreateISerializableObject(StateOwner.SynchronizedType);

            CopyUtils.PlainCopy(StateOwner.SinkSerializer, KeyCarrier, sink, new FieldLock(source.GetType()), true);
            CopyUtils.PlainCopy(StateOwner.SinkSerializer, source, sink, new FieldLock(source.GetType()), false);

            StateOwner.SinkSerializer.Connector.InsertPlain(sink);
            StateOwner.SinkObject = sink;

            SyncItem si1 = StateOwner.SyncSerializer.CreateISerializableObject <SyncItem>();
            SyncItem si2 = StateOwner.SyncSerializer.CreateISerializableObject <SyncItem>();

            si1.SyncGuid = AttributeWorker.RowGuid(source);
            si2.SyncGuid = AttributeWorker.RowGuid(sink);
            si1.ClassID  = source.GetType().Name;
            si2.ClassID  = source.GetType().Name;

            si1.Hashcode = SyncContainer.ComputeHashCode(StateOwner.SourceSerializer.Target, source);
            si2.Hashcode = SyncContainer.ComputeHashCode(StateOwner.SinkSerializer.Target, sink);

            si1.CounterPart = si2;

            StateOwner.SyncSerializer.Connector.Save(si1);
            StateOwner.SyncSerializer.ConnectOneToOne(si1, si2);
            StateOwner.SyncSerializer.Connector.Save(si2);
            StateOwner.SyncSerializer.ConnectOneToOne(si2, si1);
            StateOwner.SyncSerializer.Connector.Save(si1);

            StateOwner.UpdateFieldStates(StateOwner.SourceSerializer.Target, si1, source);//Deaktiviert
            StateOwner.UpdateFieldStates(StateOwner.SinkSerializer.Target, si2, sink);
        }
Example #3
0
        protected override void SynchronizeImpl()
        {
            ISerializableObject source = StateOwner.SourceObject;
            ISerializableObject sink   = StateOwner.SinkObject;


            CopyUtils.ForeignKeyCopy(StateOwner.SinkSerializer, KeyCarrier, sink, base._fieldLock);

            //Kopiere die angepassten Daten...
            CopyUtils.PlainCopy(StateOwner.SinkSerializer, _resolved, sink, base._fieldLock, false);
            CopyUtils.PlainCopy(StateOwner.SourceSerializer, _resolved, source, base._fieldLock, false);

            StateOwner.SinkSerializer.Connector.UpdatePlain(sink);
            StateOwner.SourceSerializer.Connector.UpdatePlain(source);


            _sourceSyncItem.Hashcode = SyncContainer.ComputeHashCode(StateOwner.SourceSerializer.Target, source);
            StateOwner.SyncSerializer.Connector.Save(_sourceSyncItem);
            SyncItem tmp = _sourceSyncItem.CounterPart;

            tmp.Hashcode = SyncContainer.ComputeHashCode(StateOwner.SinkSerializer.Target, sink);
            StateOwner.SyncSerializer.Connector.Save(tmp);

            StateOwner.UpdateFieldStates(StateOwner.SourceSerializer.Target, _sourceSyncItem, source);
            StateOwner.UpdateFieldStates(StateOwner.SinkSerializer.Target, tmp, sink);
        }
Example #4
0
 internal TruncateState(SyncContainer owner, SyncState previous)
     : base(owner, previous)
 {
     foreach (SyncContainer sc in StateOwner.Children)
     {
         sc.Truncate();
     }
 }
Example #5
0
 internal void AddISerializableObject(ISerializableObject iso)
 {
     if (!_pooledObjects.ContainsKey(AttributeWorker.RowGuid(iso)))
     {
         SyncContainer container = new SyncContainer(iso, _syncSerializer, _serializer);
         _pooledObjects[AttributeWorker.RowGuid(iso)] = container;
     }
 }
Example #6
0
        protected override void SynchronizeImpl()
        {
            ISerializableObject source = StateOwner.SourceObject;
            ISerializableObject sink   = StateOwner.SinkObject;

            CopyUtils.PlainCopy(StateOwner.SinkSerializer, KeyCarrier, sink, _fieldLock, true);
            CopyUtils.PlainCopy(StateOwner.SinkSerializer, source, sink, _fieldLock, false);

            StateOwner.SinkSerializer.Connector.UpdatePlain(sink);

            _sourceSyncItem.Hashcode = SyncContainer.ComputeHashCode(StateOwner.SourceSerializer.Target, source);
            StateOwner.SyncSerializer.Connector.Save(_sourceSyncItem);
            SyncItem sinkSyncItem = _sourceSyncItem.CounterPart;

            sinkSyncItem.Hashcode = SyncContainer.ComputeHashCode(StateOwner.SinkSerializer.Target, sink);
            StateOwner.SyncSerializer.Connector.Save(sinkSyncItem);

            StateOwner.UpdateFieldStates(StateOwner.SourceSerializer.Target, _sourceSyncItem, source);
            StateOwner.UpdateFieldStates(StateOwner.SinkSerializer.Target, sinkSyncItem, sink);
        }
Example #7
0
        internal void StartSynchronizing(SyncTool syncPeer)
        {
            if (!_initialized)
            {
                throw new SyncException("Syncpool is not initialized!");
            }
            if (!CheckSyncContext(syncPeer))
            {
                throw new SyncException("SyncPool is not compatible with SyncPeer!");
            }
            if (!CheckTarget(syncPeer))
            {
                throw new SyncException("Synchronising form source to source is not valid!");
            }

            _syncSerializer.Connector.BeginTransaction();
            syncPeer.Serializer.Connector.BeginTransaction();
            SyncContainer lastContainer = null;

            try
            {
                foreach (SyncContainer c in _pooledObjects.Values)
                {
                    lastContainer = c;
                    c.Synchronize();
                }

                _syncSerializer.Connector.Commit();
                syncPeer.Serializer.Connector.Commit();
            }
            catch (Exception ex)
            {
                ResetSynchronizedState();
                if (!OnSynchronizeEvent(new SynchronizeEventArgs()))
                {
                    throw new Exception("Synchronizing failed at: " + lastContainer, ex);
                }
            }
        }
Example #8
0
            public void HandleOneToMany(ISerializableObject handledItem, OneToManyAttribute attr, FieldInfo field)
            {
                IEnumerable set = (IEnumerable)field.GetValue(handledItem);

                foreach (ISerializableObject iso in set)
                {
                    try
                    {
                        SyncContainer s = _pooledObjects[AttributeWorker.RowGuid(iso)];
                        if (!_owner._children.Contains(s))
                        {
                            _owner._children.Add(s);
                        }
                        if (!s._parents.Contains(_owner))
                        {
                            s._parents.Add(_owner);
                        }
                    }
                    catch (KeyNotFoundException)
                    {
                    }
                }
            }
Example #9
0
            public void HandleManyToOne(ISerializableObject handledItem, ManyToOneAttribute attr, FieldInfo field)
            {
                ISerializableObject iso = (ISerializableObject)field.GetValue(handledItem);

                if (iso != null)
                {
                    try
                    {
                        SyncContainer s = _pooledObjects[AttributeWorker.RowGuid(iso)];
                        if (!_owner._parents.Contains(s))
                        {
                            _owner._parents.Add(s);
                        }
                        if (!s._children.Contains(_owner))
                        {
                            s._children.Add(_owner);
                        }
                    }
                    catch (KeyNotFoundException)
                    {
                    }
                }
            }
Example #10
0
 public DependencyRelationHandler(SyncContainer owner, IDictionary <Guid, SyncContainer> pooledObjects)
 {
     _pooledObjects = pooledObjects;
     _owner         = owner;
 }
Example #11
0
 public PrematureState(SyncContainer owner)
     : base(owner)
 {
 }
Example #12
0
 internal SynchronizedState(SyncContainer owner, SyncState previous)
     : base(owner, previous)
 {
 }
Example #13
0
 public DeletedState(SyncContainer owner, SyncItem sourceSyncItem)
     : base(owner, sourceSyncItem)
 {
 }
Example #14
0
 public ConflictState(SyncContainer owner, SyncItem sourceSyncItem) : base(owner)
 {
     _sourceSyncItem = sourceSyncItem;
 }
Example #15
0
 internal WritingStates(SyncContainer owner, SyncState previous)
     : base(owner, previous)
 {
     _doSynchronizing = true;
 }
Example #16
0
 public ConflictResolvedState(SyncContainer owner, ISerializableObject resolved, SyncItem sourceSyncItem)
     : base(owner, sourceSyncItem)
 {
     _resolved = resolved;
 }
Example #17
0
 internal IgnoreState(SyncContainer owner, SyncState previous)
     : base(owner, previous)
 {
 }
Example #18
0
 internal UpdateState(SyncContainer owner, SyncItem sourceSyncItem, SyncState previous)
     : base(owner, previous)
 {
     _sourceSyncItem = sourceSyncItem;
     _fieldLock      = new FieldLock(_sourceSyncItem.GetType());
 }
Example #19
0
 public UpdateState(SyncContainer owner, SyncItem sourceSyncItem)
     : base(owner)
 {
     _sourceSyncItem = sourceSyncItem;
     _fieldLock      = new FieldLock(_sourceSyncItem.GetType());
 }
Example #20
0
 internal SyncState(SyncContainer owner, SyncState previousState)
 {
     _StateOwner    = owner;
     _PreviousState = previousState;
 }
Example #21
0
 public InsertState(SyncContainer owner)
     : base(owner)
 {
 }
Example #22
0
 internal ConflictResolvedState(SyncContainer owner, ISerializableObject resolved, SyncItem sourceSyncItem, SyncState previous)
     : base(owner, sourceSyncItem, previous)
 {
     _resolved = resolved;
 }
Example #23
0
 public SyncState(SyncContainer owner)
 {
     _StateOwner    = owner;
     _PreviousState = null;
 }
Example #24
0
 public IgnoreState(SyncContainer owner)
     : base(owner)
 {
 }
Example #25
0
 public WritingStates(SyncContainer owner)
     : base(owner)
 {
     _doSynchronizing = true;
 }