Ejemplo n.º 1
0
        public void ResolveConflictLocalWins(SyncConflict conflict)
        {
            if (_closed)
            {
                throw new InvalidOperationException();
            }

            var tickCount       = _store.IncrementLocalRepilcaTickCount();
            var modifiedReplica = new ReplicaInfo
            {
                ReplicaId        = _store.GetLocalReplicaId(),
                ReplicaTickCount = tickCount
            };
            var resolvedStatus = conflict.LocalItemInfo.Deleted ? SyncStatus.Delete : SyncStatus.Update;
            var data           = JObject.Parse("{item:{itemRefs:[]}}");

            if (resolvedStatus != SyncStatus.Delete)
            {
                var builder = SyncUtil.JsonItemFromSyncableItemInfo(conflict.LocalItemInfo);
                _store.BuildItemData(conflict.LocalItemInfo, builder);
                data = new JObject {
                    { "item", builder }
                };
            }

            using (var connection = _syncSessionDbConnectionProvider.GetSyncSessionDbConnection(_localSessionId))
            {
                SessionDbHelper.ResolveItemWithData(connection, conflict.RemoteItemInfo, resolvedStatus, modifiedReplica,
                                                    data);
            }
        }
Ejemplo n.º 2
0
        public void ResolveConflictRemoteWins(SyncConflict conflict)
        {
            if (_closed)
            {
                throw new InvalidOperationException();
            }

            var tickCount       = _store.IncrementLocalRepilcaTickCount();
            var modifiedReplica = new ReplicaInfo
            {
                ReplicaId        = _store.GetLocalReplicaId(),
                ReplicaTickCount = tickCount
            };
            var resolvedStatus = conflict.RemoteItemInfo.Deleted ? SyncStatus.Delete : SyncStatus.Update;

            using (var connection = _syncSessionDbConnectionProvider.GetSyncSessionDbConnection(_localSessionId))
            {
                SessionDbHelper.ResolveItemNoData(connection, conflict.RemoteItemInfo, resolvedStatus, modifiedReplica);
            }
        }
Ejemplo n.º 3
0
        public void ResolveConflictMerge(SyncConflict conflict, JObject itemData)
        {
            if (_closed)
            {
                throw new InvalidOperationException();
            }

            long         tickCount       = _store.IncrementLocalRepilcaTickCount();
            IReplicaInfo modifiedReplica = new ReplicaInfo
            {
                ReplicaId        = _store.GetLocalReplicaId(),
                ReplicaTickCount = tickCount
            };
            ISyncableItemInfo itemInfo = conflict.RemoteItemInfo;

            using (
                IDbConnection connection = _syncSessionDbConnectionProvider.GetSyncSessionDbConnection(_localSessionId))
            {
                SessionDbHelper.ResolveItemWithData(connection, itemInfo, SyncStatus.Update, modifiedReplica, itemData);
            }
        }