Example #1
0
        private HierarchySyncOperations PostEnumerateServerOperations(Dictionary <StoreObjectId, FolderStateEntry> serverFolders, StoreObjectId rootFolderId)
        {
            Dictionary <StoreObjectId, FolderManifestEntry> dictionary = new Dictionary <StoreObjectId, FolderManifestEntry>();

            foreach (KeyValuePair <StoreObjectId, FolderStateEntry> keyValuePair in this.ClientState)
            {
                StoreObjectId    key   = keyValuePair.Key;
                FolderStateEntry value = keyValuePair.Value;
                if (!serverFolders.ContainsKey(key))
                {
                    dictionary.Add(key, new FolderManifestEntry(key)
                    {
                        ChangeType = ChangeType.Delete,
                        ParentId   = value.ParentId
                    });
                }
            }
            foreach (FolderManifestEntry folderManifestEntry in dictionary.Values)
            {
                if (dictionary.ContainsKey(folderManifestEntry.ParentId))
                {
                    this.ClientState.Remove(folderManifestEntry.ItemId);
                }
                else if (this.ClientState.ContainsKey(folderManifestEntry.ParentId) || folderManifestEntry.ParentId.Equals(rootFolderId))
                {
                    this.ServerManifest[folderManifestEntry.ItemId] = folderManifestEntry;
                }
            }
            return(new HierarchySyncOperations(this, this.ServerManifest, false));
        }
Example #2
0
        public void RecordClientOperation(StoreObjectId folderId, ChangeType change, Folder folder)
        {
            EnumValidator.ThrowIfInvalid <ChangeType>(change, "change");
            ExTraceGlobals.SyncTracer.Information <StoreObjectId, ChangeType>((long)this.GetHashCode(), "Storage.FolderHierarchySync.RecordClientOperation. ItemId = {0}, ChangeType = {1}", folderId, change);
            if (folderId == null)
            {
                throw new ArgumentNullException("folderId");
            }
            if (folder != null && !folderId.Equals(folder.Id.ObjectId))
            {
                throw new ArgumentException(ServerStrings.ExFolderDoesNotMatchFolderId);
            }
            if (change != ChangeType.Add && change != ChangeType.Change && change != ChangeType.Delete)
            {
                throw new ArgumentOutOfRangeException("change");
            }
            if ((change == ChangeType.Add || change == ChangeType.Change) && folder == null)
            {
                throw new ArgumentNullException("folder", ServerStrings.ExInvalidNullParameterForChangeTypes("folder", "ChangeType.Add, ChangeType.Change"));
            }
            switch (change)
            {
            case ChangeType.Add:
                if (this.ClientState.ContainsKey(folderId))
                {
                    throw new ArgumentException(ServerStrings.ExFolderAlreadyExistsInClientState);
                }
                break;

            case ChangeType.Change:
            case ChangeType.Delete:
                if (!this.ClientState.ContainsKey(folderId))
                {
                    throw new ArgumentException(ServerStrings.ExFolderNotFoundInClientState);
                }
                break;
            }
            switch (change)
            {
            case ChangeType.Add:
            case ChangeType.Change:
            {
                FolderStateEntry value = new FolderStateEntry(folder.ParentId, folder.GetValueOrDefault <byte[]>(InternalSchema.ChangeKey), this.changeTrackingDelegate(this.storeSession, folder.StoreObjectId, null));
                this.ClientState[folderId] = value;
                return;
            }

            case (ChangeType)3:
                break;

            case ChangeType.Delete:
                this.ClientState.Remove(folderId);
                break;

            default:
                return;
            }
        }