Esempio n. 1
0
        public ChangeBatch GetChangeBatch(uint batchSize, SyncKnowledge destinationKnowledge, out ForgottenKnowledge forgottenKnowledge, out object changeDataRetriever)
        {
            // Increment the tick count
            GetNextTickCount();

            // Get local changes
            List <ItemChange> changes = DetectChanges(destinationKnowledge, batchSize);

            // Update the knowledge with an updated local tick count
            SyncKnowledge.SetLocalTickCount(tickCount);

            // Construct the ChangeBatch and return it
            ChangeBatch changeBatch = new ChangeBatch(IdFormats, destinationKnowledge, ForgottenKnowledge);

            changeBatch.BeginUnorderedGroup();
            changeBatch.AddChanges(changes);
            if (changes.Count < batchSize || changes.Count == 0)
            {
                changeBatch.SetLastBatch();
            }
            changeBatch.EndUnorderedGroup(SyncKnowledge, changeBatch.IsLastBatch);

            // Return the forgotten knowledge
            forgottenKnowledge = ForgottenKnowledge;

            changeDataRetriever = this;

            return(changeBatch);
        }
Esempio n. 2
0
        public List <ItemChange> GetChanges(ChangeBatch sourceChanges)
        {
            // Increment the tick count
            GetNextTickCount();

            // Increase local knowledge tick count.
            SyncKnowledge.SetLocalTickCount(tickCount);

            // Create a collection to hold the changes we'll put into our batch
            List <ItemChange> changes = new List <ItemChange>();

            foreach (ItemChange ic in sourceChanges)
            {
                ItemMetadata item;
                ItemChange   change;
                // Iterate through each item to get the corresponding version in the local store
                if (metadataStore.TryGetItem(ic.ItemId, out item))
                {
                    // Found the corresponding item in the local metadata
                    // Get the local creation version and change (update) version from the metadata
                    change = new ItemChange(IdFormats, ReplicaId, item.ItemId, item.IsTombstone ? ChangeKind.Deleted: ChangeKind.Update, item.CreationVersion, item.ChangeVersion);
                }
                else
                {
                    // Remote item has no local counterpart
                    // This item is unknown to us
                    change = new ItemChange(IdFormats, ReplicaId, ic.ItemId, ChangeKind.UnknownItem, SyncVersion.UnknownVersion, SyncVersion.UnknownVersion);
                }

                // Add our change to the change list
                changes.Add(change);
            }

            return(changes);
        }
Esempio n. 3
0
        internal static void SetLocalTickCountRanges(SyncKnowledge knowledge, ulong newTick)
        {
            SyncKnowledge knowledge1 = knowledge.Clone();

            knowledge.SetLocalTickCount(newTick);
            knowledge.Combine(knowledge1);
        }
Esempio n. 4
0
 public void SetLocalTickCount()
 {
     SyncKnowledge.SetLocalTickCount(tickCount);
 }