コード例 #1
0
        public string Add(ISyncItemId mailboxItemId)
        {
            AirSyncDiagnostics.Assert(mailboxItemId != null);
            if (mailboxItemId != null && mailboxItemId.NativeId != null)
            {
                StoreObjectId storeObjectId = mailboxItemId.NativeId as StoreObjectId;
                if (storeObjectId != null && storeObjectId.ObjectType == StoreObjectType.CalendarItemOccurrence)
                {
                    AirSyncDiagnostics.TraceDebug <ISyncItemId>(ExTraceGlobals.RequestsTracer, this, "CalendarItemOccurrence ItemId is being added to the ItemIdMapping! Id:{0}.", mailboxItemId);
                }
            }
            string text;

            if (base.OldIds.ContainsKey(mailboxItemId))
            {
                text = base.OldIds[mailboxItemId];
            }
            else
            {
                text = this.parentSyncId + ":" + base.UniqueCounter.ToString(CultureInfo.InvariantCulture);
            }
            AirSyncDiagnostics.Assert(text.Length <= 64);
            base.Add(mailboxItemId, text);
            return(text);
        }
コード例 #2
0
 internal static ServerManifestEntry CreateItemDeleteManifestEntry(ISyncItemId syncItemId)
 {
     return(new ServerManifestEntry(syncItemId)
     {
         ChangeType = ChangeType.Delete
     });
 }
コード例 #3
0
        private StoreObjectId GetStoreObjectId(string folderId)
        {
            SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(folderId);
            if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
            {
                throw new AirSyncPermanentException(StatusCode.InvalidCombinationOfIDs, false)
                      {
                          ErrorStringForProtocolLogger = "BadIdComboInConversationMove"
                      };
            }
            if (this.folderIdMapping == null)
            {
                using (CustomSyncState customSyncState = this.syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]))
                {
                    if (customSyncState == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoSyncStateInConversationMove"
                              };
                    }
                    if (customSyncState[CustomStateDatumType.IdMapping] == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoIdMappingInConversationMove"
                              };
                    }
                    this.folderIdMapping = (FolderIdMapping)customSyncState[CustomStateDatumType.IdMapping];
                    this.fullFolderTree  = (FolderTree)customSyncState[CustomStateDatumType.FullFolderTree];
                }
            }
            ISyncItemId syncItemId = this.folderIdMapping[folderId];

            if (syncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "NoFldrIdInMappingInConversationMove"
                      };
            }
            MailboxSyncItemId mailboxSyncItemId = syncItemId as MailboxSyncItemId;

            if (mailboxSyncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.InvalidIDs, false)
                      {
                          ErrorStringForProtocolLogger = "BadIdInConversationMove"
                      };
            }
            if (this.fullFolderTree.IsSharedFolder(mailboxSyncItemId) || this.fullFolderTree.GetPermissions(mailboxSyncItemId) != SyncPermissions.FullAccess)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_Retry, false)
                      {
                          ErrorStringForProtocolLogger = "DeniedInConversationMove"
                      };
            }
            return((StoreObjectId)mailboxSyncItemId.NativeId);
        }
コード例 #4
0
 public ServerManifestEntry CreateItemChangeManifestEntry(ISyncItemId syncItemId, ISyncWatermark watermark)
 {
     return(new ServerManifestEntry(syncItemId)
     {
         Watermark = watermark,
         ChangeType = ChangeType.Add
     });
 }
コード例 #5
0
ファイル: FolderTree.cs プロジェクト: YHZX2013/exchange_diff
 public void SetPermissions(ISyncItemId folderId, SyncPermissions permissions)
 {
     FolderTree.FolderInfo folderInfo = this.GetFolderInfo(folderId);
     if (folderInfo.Permissions != permissions)
     {
         folderInfo.Permissions = permissions;
         this.isDirty           = true;
     }
 }
コード例 #6
0
		// Token: 0x0600090F RID: 2319 RVA: 0x00035ECC File Offset: 0x000340CC
		public void RemoveFolder(ISyncItemId folderId)
		{
			ISyncItemId parentId = this.GetFolderInfo(folderId).ParentId;
			if (parentId != null)
			{
				this.UnlinkChild(parentId, folderId);
			}
			this.isDirty |= this.folderTree.Remove(folderId);
		}
コード例 #7
0
ファイル: FolderTree.cs プロジェクト: YHZX2013/exchange_diff
 public void SetOwner(ISyncItemId folderId, string owner)
 {
     FolderTree.FolderInfo folderInfo = this.GetFolderInfo(folderId);
     if (!string.Equals(folderInfo.Owner, owner))
     {
         folderInfo.Owner = owner;
         this.isDirty     = true;
     }
 }
コード例 #8
0
 internal void UpdateFilterStateWithAddOrChange(ISyncItemId itemId, bool calendar, bool recurring, ExDateTime endTime)
 {
     if (itemId == null)
     {
         throw new ArgumentNullException("itemId");
     }
     DateTimeCustomSyncFilter.FilterState filterState = null;
     if (this.CustomFilterState == null)
     {
         this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>();
     }
     try
     {
         if (!this.CustomFilterState.ContainsKey(itemId))
         {
             filterState = new DateTimeCustomSyncFilter.FilterState();
             this.CustomFilterState[itemId] = filterState;
         }
         else
         {
             filterState = this.CustomFilterState[itemId];
         }
         filterState.IsCalendarItem = calendar;
         if (calendar)
         {
             filterState.IsRecurring = recurring;
             if (recurring)
             {
                 if (endTime.Equals(ExDateTime.MinValue))
                 {
                     filterState.DoesRecurrenceEnd = false;
                 }
                 else
                 {
                     filterState.DoesRecurrenceEnd = true;
                     filterState.EndTime           = endTime;
                 }
             }
             else
             {
                 filterState.EndTime = endTime;
             }
         }
     }
     catch (Exception ex)
     {
         if (ex is ObjectNotFoundException || !SyncCommand.IsItemSyncTolerableException(ex))
         {
             throw;
         }
         if (filterState != null)
         {
             filterState.IsCalendarItem = false;
         }
     }
 }
コード例 #9
0
ファイル: FolderTree.cs プロジェクト: YHZX2013/exchange_diff
 public bool AddFolder(ISyncItemId folderId)
 {
     if (this.folderTree.ContainsKey(folderId))
     {
         return(false);
     }
     this.folderTree[folderId] = new FolderTree.FolderInfo();
     this.isDirty = true;
     return(true);
 }
コード例 #10
0
        protected void DeleteItem(ISyncItemId syncItemId, CancelEventParameters parameters)
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.DeleteItem");
            string key = EntitySyncItem.GetKey(base.StoreSession.MailboxGuid, (StoreId)syncItemId.NativeId);

            this.Events.Cancel(key, parameters, null);
            base.ItemIdMapping.Delete(new ISyncItemId[]
            {
                syncItemId
            });
        }
コード例 #11
0
 // Token: 0x17000361 RID: 865
 public virtual string this[ISyncItemId mailboxId]
 {
     get
     {
         if (this.mailboxIdToSyncIdTable.ContainsKey(mailboxId))
         {
             return(this.mailboxIdToSyncIdTable[mailboxId]);
         }
         return(null);
     }
 }
コード例 #12
0
 public bool IsItemInFilter(ISyncItemId itemId)
 {
     if (this.prepopulate)
     {
         return(false);
     }
     if (this.CustomFilterState == null)
     {
         this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>();
     }
     return(this.CustomFilterState.ContainsKey(itemId) && this.IsFilterStateInFilter(this.CustomFilterState[itemId]));
 }
コード例 #13
0
 internal ServerManifestEntry CreateReadFlagChangeManifestEntry(ISyncItemId syncItemId, bool read)
 {
     if (this.folderSync != null && !this.folderSync.ClientHasItem(syncItemId))
     {
         return(null);
     }
     return(new ServerManifestEntry(syncItemId)
     {
         ChangeType = ChangeType.ReadFlagChange,
         IsRead = read
     });
 }
コード例 #14
0
 public override string this[ISyncItemId mailboxId]
 {
     get
     {
         string text = base[mailboxId];
         if (text != null && !base.IsInDeletedItemsBuffer(text))
         {
             return(text);
         }
         return(null);
     }
 }
コード例 #15
0
        public ISyncItem GetItem(ISyncItemId id, params PropertyDefinition[] specifiedPrefetchProperties)
        {
            this.CheckDisposed("GetItem");
            RecipientInfoCacheSyncItemId recipientInfoCacheSyncItemId = id as RecipientInfoCacheSyncItemId;

            if (recipientInfoCacheSyncItemId == null)
            {
                return(null);
            }
            if (this.FastCache.ContainsKey(recipientInfoCacheSyncItemId))
            {
                return(this.FastCache[recipientInfoCacheSyncItemId]);
            }
            return(null);
        }
コード例 #16
0
 public ISyncItem GetItem(ISyncItemId id, params PropertyDefinition[] specifiedPrefetchProperties)
 {
     this.CheckDisposed("GetItem");
     PropertyDefinition[] array;
     if (specifiedPrefetchProperties != null && specifiedPrefetchProperties.Length != 0)
     {
         array = new PropertyDefinition[specifiedPrefetchProperties.Length + MailboxSyncProvider.defaultPrefetchProperties.Length];
         specifiedPrefetchProperties.CopyTo(array, 0);
         MailboxSyncProvider.defaultPrefetchProperties.CopyTo(array, specifiedPrefetchProperties.Length);
     }
     else
     {
         array = MailboxSyncProvider.defaultPrefetchProperties;
     }
     return(this.GetItem(this.BindToItemWithItemClass((StoreObjectId)id.NativeId, array)));
 }
コード例 #17
0
ファイル: FolderTree.cs プロジェクト: YHZX2013/exchange_diff
 public void UnlinkChild(ISyncItemId parentId, ISyncItemId childId)
 {
     FolderTree.FolderInfo folderInfo  = this.GetFolderInfo(parentId);
     FolderTree.FolderInfo folderInfo2 = this.GetFolderInfo(childId);
     if (!parentId.Equals(folderInfo2.ParentId) || !folderInfo.Children.Contains(childId))
     {
         AirSyncDiagnostics.TraceError <ISyncItemId, ISyncItemId, ISyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "Tried to unlink a child folder from a folder that was not its parent.  ChildSyncId: {0}, child's ParentSyncId: {1}, ParentSyncId passed in: {2}", childId, folderInfo2.ParentId, parentId);
         this.TraceTree();
         return;
     }
     if (folderInfo.Children.Remove(childId))
     {
         this.GetFolderInfo(childId).ParentId = null;
         this.isDirty = true;
     }
 }
コード例 #18
0
        public string Add(ISyncItemId mailboxFolderId)
        {
            AirSyncDiagnostics.Assert(mailboxFolderId != null);
            string text;

            if (base.OldIds.ContainsKey(mailboxFolderId))
            {
                text = base.OldIds[mailboxFolderId];
            }
            else
            {
                text = base.UniqueCounter.ToString(CultureInfo.InvariantCulture);
            }
            base.Add(mailboxFolderId, text);
            return(text);
        }
コード例 #19
0
        public override bool GetNewOperations(ISyncWatermark minSyncWatermark, ISyncWatermark maxSyncWatermark, bool enumerateDeletes, int numOperations, QueryFilter filter, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest)
        {
            base.CheckDisposed("GetNewOperations");
            AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "EntitySyncProvider.GetNewOperations. numOperations = {0}", numOperations);
            if (newServerManifest == null)
            {
                throw new ArgumentNullException("newServerManifest");
            }
            if (!enumerateDeletes)
            {
                throw new NotImplementedException("enumerateDeletes is false!");
            }
            if (filter != null)
            {
                throw new NotImplementedException("filter is non-null! Filters are not supported on EntitySyncProvider");
            }
            SyncCalendar     syncCalendar = new SyncCalendar(this.CalendarSyncState, base.Folder.Session, base.Folder.Id.ObjectId, (CalendarFolder folder) => EntitySyncProvider.PropertiesToSync, this.WindowStart, this.WindowEnd, false, numOperations);
            IFolderSyncState folderSyncState;
            IList <KeyValuePair <StoreId, LocalizedException> > list;
            SyncCalendarResponse syncCalendarResponse = syncCalendar.Execute(out folderSyncState, out list);

            AirSyncDiagnostics.TraceInfo <IFolderSyncState>(ExTraceGlobals.RequestsTracer, this, "newSyncState:{0}", folderSyncState);
            SyncCalendarFolderSyncState syncCalendarFolderSyncState = (SyncCalendarFolderSyncState)folderSyncState;

            this.CalendarSyncState = new AirSyncCalendarSyncState(syncCalendarFolderSyncState.SerializeAsBase64String(), syncCalendarResponse.QueryResumptionPoint, syncCalendarResponse.OldWindowEnd);
            if (list.Count > 0 && Command.CurrentCommand.MailboxLogger != null)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (KeyValuePair <StoreId, LocalizedException> keyValuePair in list)
                {
                    stringBuilder.AppendFormat("Exception caught for item {0}\r\n{1}\r\n\r\n", keyValuePair.Key, keyValuePair.Value);
                }
                Command.CurrentCommand.MailboxLogger.SetData(MailboxLogDataName.CalendarSync_Exception, stringBuilder.ToString());
            }
            AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "DeletedItems:{0}", syncCalendarResponse.DeletedItems.Count);
            foreach (StoreId storeId in syncCalendarResponse.DeletedItems)
            {
                ISyncItemId syncItemId = EntitySyncItemId.CreateFromId(storeId);
                newServerManifest.Add(syncItemId, new ServerManifestEntry(ChangeType.Delete, syncItemId, null));
            }
            this.CopyListToDictionary(syncCalendarResponse.UpdatedItems, "UpdatedItems", newServerManifest);
            this.CopyListToDictionary(syncCalendarResponse.RecurrenceMastersWithInstances, "RecurrenceMastersWithInstances", newServerManifest);
            this.CopyListToDictionary(syncCalendarResponse.RecurrenceMastersWithoutInstances, "RecurrenceMastersWithoutInstances", newServerManifest);
            this.CopyListToDictionary(syncCalendarResponse.UnchangedRecurrenceMastersWithInstances, "UnchangedRecurrenceMastersWithInstances", newServerManifest);
            AirSyncDiagnostics.TraceInfo <bool>(ExTraceGlobals.RequestsTracer, this, "MoreAvailable:{0}", !syncCalendarResponse.IncludesLastItemInRange);
            return(!syncCalendarResponse.IncludesLastItemInRange);
        }
コード例 #20
0
 // Token: 0x060008E2 RID: 2274 RVA: 0x00035094 File Offset: 0x00033294
 public void CommitChanges()
 {
     if (this.addedItems.Count > 0)
     {
         this.addedItems.Clear();
         this.dirty = true;
     }
     for (int i = 0; i < this.deletedItems.Count; i++)
     {
         string      key  = this.deletedItems[i];
         ISyncItemId key2 = this.syncIdToMailboxIdTable[key];
         this.mailboxIdToSyncIdTable.Remove(key2);
         this.syncIdToMailboxIdTable.Remove(key);
         this.dirty = true;
     }
     this.deletedItems.Clear();
 }
コード例 #21
0
        public ManifestCallbackStatus ReadUnread(byte[] entryId, bool read)
        {
            ManifestCallbackStatus result     = ManifestCallbackStatus.Continue;
            StoreObjectId          id         = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown);
            ISyncItemId            syncItemId = MailboxSyncItemId.CreateForExistingItem(this.mailboxSyncProvider.FolderSync, id);

            if (syncItemId == null)
            {
                return(result);
            }
            ServerManifestEntry serverManifestEntry = this.mailboxSyncProvider.CreateReadFlagChangeManifestEntry(syncItemId, read);

            if (serverManifestEntry != null)
            {
                this.lastServerManifestEntry = serverManifestEntry;
            }
            return(this.CheckYieldOrStop());
        }
コード例 #22
0
 // Token: 0x060008E1 RID: 2273 RVA: 0x00034FFC File Offset: 0x000331FC
 public void ClearChanges()
 {
     for (int i = 0; i < this.addedItems.Count; i++)
     {
         string      text = this.addedItems[i];
         ISyncItemId key  = this.syncIdToMailboxIdTable[text];
         this.syncIdToMailboxIdTable.Remove(text);
         this.mailboxIdToSyncIdTable.Remove(key);
         this.oldIds[key] = text;
         this.dirty       = true;
     }
     this.addedItems.Clear();
     if (this.deletedItems.Count > 0)
     {
         this.deletedItems.Clear();
         this.dirty = true;
     }
 }
コード例 #23
0
 // Token: 0x060008EC RID: 2284 RVA: 0x00035640 File Offset: 0x00033840
 protected void Add(ISyncItemId mailboxId, string syncId)
 {
     AirSyncDiagnostics.Assert(mailboxId != null);
     AirSyncDiagnostics.Assert(syncId != null);
     if (this.syncIdToMailboxIdTable.ContainsKey(syncId))
     {
         ISyncItemId syncItemId = this.syncIdToMailboxIdTable[syncId];
         if (syncItemId.Equals(mailboxId))
         {
             return;
         }
         throw new InvalidOperationException("SyncId has already been mapped to a different MailboxId");
     }
     else if (this.usingWriteBuffer && this.addedItemsWriteBuffer.ContainsKey(syncId))
     {
         ISyncItemId syncItemId2 = this.addedItemsWriteBuffer[syncId];
         if (syncItemId2.Equals(mailboxId))
         {
             return;
         }
         throw new InvalidOperationException("SyncId has already been mapped to a different MailboxId");
     }
     else
     {
         if (this.mailboxIdToSyncIdTable.ContainsKey(mailboxId) || (this.usingWriteBuffer && this.addedItemsWriteBufferReversed.ContainsKey(mailboxId)))
         {
             throw new InvalidOperationException("MailboxId has already been mapped to a different SyncId");
         }
         if (this.usingWriteBuffer)
         {
             this.addedItemsWriteBuffer[syncId]            = mailboxId;
             this.addedItemsWriteBufferReversed[mailboxId] = syncId;
             this.uniqueCounter += 1L;
             return;
         }
         this.syncIdToMailboxIdTable.Add(syncId, mailboxId);
         this.mailboxIdToSyncIdTable.Add(mailboxId, syncId);
         this.addedItems.Add(syncId);
         this.uniqueCounter += 1L;
         this.dirty          = true;
         return;
     }
 }
コード例 #24
0
ファイル: FolderTree.cs プロジェクト: YHZX2013/exchange_diff
        private bool RemoveFolderAndChildren(ISyncItemId folderId, FolderIdMapping folderIdMapping, int foldersSeen, int numberOfFoldersInTree)
        {
            FolderTree.FolderInfo folderInfo = this.GetFolderInfo(folderId);
            foldersSeen++;
            if (foldersSeen > numberOfFoldersInTree)
            {
                AirSyncDiagnostics.TraceError <int>(ExTraceGlobals.AlgorithmTracer, this, "Error: Loop detected in folder tree.  NumberOfFoldersInTree: {0}", numberOfFoldersInTree);
                this.TraceTree();
                return(false);
            }
            int num = 0;

            while (folderInfo.Children.Count > num)
            {
                ISyncItemId syncItemId = folderInfo.Children[num];
                if (this.folderTree.ContainsKey(syncItemId))
                {
                    if (!this.RemoveFolderAndChildren(syncItemId, folderIdMapping, foldersSeen, numberOfFoldersInTree))
                    {
                        return(false);
                    }
                }
                else
                {
                    num++;
                    MailboxSyncItemId mailboxSyncItemId = syncItemId as MailboxSyncItemId;
                    AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.AlgorithmTracer, this, "FolderTree.RemoveFolderAndChildren could not find child folder: {0} to remove.", (mailboxSyncItemId == null) ? "<folder is not a MailboxSyncItemId>" : mailboxSyncItemId.ToString());
                }
            }
            if (folderIdMapping.Contains(folderId))
            {
                folderIdMapping.Delete(new ISyncItemId[]
                {
                    folderId
                });
            }
            this.RemoveFolder(folderId);
            return(true);
        }
コード例 #25
0
 private void CopyListToDictionary(IList <SyncCalendarItemType> items, string listName, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest)
 {
     AirSyncDiagnostics.TraceInfo <string, int>(ExTraceGlobals.RequestsTracer, this, "{0}:{1}", listName, items.Count);
     foreach (SyncCalendarItemType syncCalendarItemType in items)
     {
         EntitySyncWatermark watermark = null;
         object obj;
         if (syncCalendarItemType.RowData != null && syncCalendarItemType.RowData.TryGetValue(ItemSchema.ArticleId, out obj) && !(obj is PropertyError))
         {
             watermark = EntitySyncWatermark.CreateWithChangeNumber((int)obj);
         }
         ISyncItemId         syncItemId          = EntitySyncItemId.CreateFromId(syncCalendarItemType.ItemId);
         ServerManifestEntry serverManifestEntry = new ServerManifestEntry(ChangeType.Add, syncItemId, watermark);
         serverManifestEntry.MessageClass     = "IPM.APPOINTMENT";
         serverManifestEntry.CalendarItemType = syncCalendarItemType.CalendarItemType;
         OccurrenceStoreObjectId occurrenceStoreObjectId = StoreId.GetStoreObjectId(syncCalendarItemType.ItemId) as OccurrenceStoreObjectId;
         if (occurrenceStoreObjectId != null)
         {
             serverManifestEntry.SeriesMasterId = occurrenceStoreObjectId.GetMasterStoreObjectId();
         }
         newServerManifest.Add(syncItemId, serverManifestEntry);
     }
 }
コード例 #26
0
 // Token: 0x0600184E RID: 6222 RVA: 0x0008E9FC File Offset: 0x0008CBFC
 private void UpdateFilter(Dictionary <StoreObjectId, string> mapping, DateTimeCustomSyncFilter dateTimeFilter, Dictionary <string, CommonNode> items)
 {
     foreach (StoreObjectId storeObjectId in mapping.Keys)
     {
         string      key        = mapping[storeObjectId];
         CommonNode  commonNode = items[key];
         ISyncItemId syncItemId = MailboxSyncItemId.CreateForNewItem(storeObjectId);
         if (commonNode.IsCalendar)
         {
             dateTimeFilter.UpdateFilterStateWithAddOrChange(syncItemId, true, true, commonNode.EndTime);
         }
         ChangeTrackingNode[] array;
         if (commonNode.IsEmail)
         {
             array = new ChangeTrackingNode[]
             {
                 ChangeTrackingNode.AllOtherNodes,
                 new ChangeTrackingNode("Email", "Read")
             };
         }
         else
         {
             array = new ChangeTrackingNode[]
             {
                 ChangeTrackingNode.AllNodes
             };
         }
         GenericDictionaryData <DerivedData <ISyncItemId>, ISyncItemId, FolderSync.ClientStateInformation> genericDictionaryData = (GenericDictionaryData <DerivedData <ISyncItemId>, ISyncItemId, FolderSync.ClientStateInformation>) this.syncState[SyncStateProp.ClientState];
         if (!genericDictionaryData.Data.ContainsKey(syncItemId))
         {
             genericDictionaryData.Data[syncItemId] = new FolderSync.ClientStateInformation();
         }
         FolderSync.ClientStateInformation clientStateInformation = genericDictionaryData.Data[syncItemId];
         clientStateInformation.ChangeTrackingInformation = new int?[array.Length];
         clientStateInformation.ClientHasItem             = true;
     }
 }
コード例 #27
0
ファイル: FolderTree.cs プロジェクト: YHZX2013/exchange_diff
 private FolderTree.FolderInfo GetFolderInfo(ISyncItemId folderId)
 {
     if (folderId == null)
     {
         throw new ArgumentNullException("folderId");
     }
     if (!this.folderTree.ContainsKey(folderId))
     {
         this.TraceTree();
         AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerError, null, false);
         if (Command.CurrentCommand.ProtocolLogger != null)
         {
             string text = string.Format("{0}InvalidFolderIdException", Command.CurrentCommand.Request.CommandType);
             Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.Error, text);
             ex.ErrorStringForProtocolLogger = text;
         }
         else
         {
             ex.ErrorStringForProtocolLogger = "BadFolderIdInFolderTree";
         }
         throw ex;
     }
     return(this.folderTree[folderId]);
 }
コード例 #28
0
        public override ISyncItemId ConvertClientToServerObjectAndSave(SyncCommandItem syncCommandItem, ref uint maxWindowSize, ref bool mergeToClient)
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.ConvertClientToServerObjectAndSave");
            base.CheckFullAccess();
            ItemIdMapping itemIdMapping = base.ItemIdMapping;
            IItem         item          = ((EntitySyncItem)syncCommandItem.Item).Item;

            try
            {
                this.EntityDataObject.Bind(item);
                base.AirSyncDataObject.Bind(syncCommandItem.XmlNode);
                this.EntityDataObject.CopyFrom(base.AirSyncDataObject);
            }
            finally
            {
                base.AirSyncDataObject.Unbind();
                this.EntityDataObject.Unbind();
            }
            ISyncItemId syncItemId = this.ApplyChanges(syncCommandItem);

            syncCommandItem.ChangeTrackingInformation = base.ChangeTrackFilter.UpdateChangeTrackingInformation(syncCommandItem.XmlNode, syncCommandItem.ChangeTrackingInformation);
            syncCommandItem.SyncId = base.ItemIdMapping[syncItemId];
            return(syncItemId);
        }
コード例 #29
0
 // Token: 0x060008C8 RID: 2248 RVA: 0x00034B7C File Offset: 0x00032D7C
 protected override void ProcessCommand(FolderCommand.FolderRequest folderRequest, XmlDocument doc)
 {
     if (FolderCommand.IsEmptyOrWhiteSpacesOnly(folderRequest.DisplayName))
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EmptyDisplayName");
         AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), null, false);
         throw ex;
     }
     using (Folder folder = Folder.Create(base.MailboxSession, folderRequest.ParentId, StoreObjectType.Folder))
     {
         string namespaceURI = doc.DocumentElement.NamespaceURI;
         folder.DisplayName = folderRequest.DisplayName;
         string classNameFromType = AirSyncUtility.GetClassNameFromType(folderRequest.Type);
         if (classNameFromType == null)
         {
             AirSyncPermanentException ex;
             if (!this.IsValidSpecialFolderType(base.Version, folderRequest.Type))
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidFolderType");
                 ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), null, false);
                 throw ex;
             }
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CreateOfSpecialFolder");
             ex = new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, base.ConstructErrorXml(StatusCode.Sync_InvalidSyncKey), null, false);
             throw ex;
         }
         else
         {
             folder.ClassName = classNameFromType;
             try
             {
                 folder.Save();
                 folder.Load();
             }
             catch (ObjectExistedException innerException)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FolderExistsOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), innerException, false);
                 throw ex;
             }
             catch (InvalidOperationException innerException2)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidOperationOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException2, false);
                 throw ex;
             }
             catch (ObjectValidationException innerException3)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ObjectValidationOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), innerException3, false);
                 throw ex;
             }
             base.FolderHierarchySync.RecordClientOperation(folder.Id.ObjectId, ChangeType.Add, folder);
             folderRequest.RecoverySyncKey = folderRequest.SyncKey;
             folderRequest.SyncKey         = base.GetNextNumber(folderRequest.SyncKey);
             base.SyncStateChanged         = true;
             base.FolderHierarchySyncState[CustomStateDatumType.SyncKey]         = new Int32Data(folderRequest.SyncKey);
             base.FolderHierarchySyncState[CustomStateDatumType.RecoverySyncKey] = new Int32Data(folderRequest.RecoverySyncKey);
             XmlNode xmlNode = doc.CreateElement("Status", namespaceURI);
             xmlNode.InnerText = "1";
             XmlNode xmlNode2 = doc.CreateElement("SyncKey", namespaceURI);
             xmlNode2.InnerText = folderRequest.SyncKey.ToString(CultureInfo.InvariantCulture);
             XmlNode         xmlNode3        = doc.CreateElement("ServerId", namespaceURI);
             FolderIdMapping folderIdMapping = (FolderIdMapping)base.FolderIdMappingSyncState[CustomStateDatumType.IdMapping];
             ISyncItemId     syncItemId      = MailboxSyncItemId.CreateForNewItem(folder.Id.ObjectId);
             xmlNode3.InnerText = folderIdMapping.Add(syncItemId);
             folderIdMapping.CommitChanges();
             doc.DocumentElement.AppendChild(xmlNode);
             doc.DocumentElement.AppendChild(xmlNode2);
             doc.DocumentElement.AppendChild(xmlNode3);
             FolderTree folderTree = (FolderTree)base.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
             folderTree.AddFolder(syncItemId);
             if (!base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root).Equals(folderRequest.ParentId))
             {
                 ISyncItemId parentId = MailboxSyncItemId.CreateForNewItem(folderRequest.ParentId);
                 folderTree.LinkChildToParent(parentId, syncItemId);
             }
             base.ProtocolLogger.IncrementValue("F", PerFolderProtocolLoggerData.ClientAdds);
         }
     }
 }
コード例 #30
0
        protected override void ProcessCommand(FolderCommand.FolderRequest folderRequest, XmlDocument doc)
        {
            DefaultFolderType defaultFolderType = base.MailboxSession.IsDefaultFolderType(folderRequest.ServerId);

            if (defaultFolderType != DefaultFolderType.None)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateOfDefaultFolder");
                AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), null, false);
                throw ex;
            }
            if (FolderCommand.IsEmptyOrWhiteSpacesOnly(folderRequest.DisplayName))
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateOfEmptyDisplayName");
                AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), null, false);
                throw ex;
            }
            string namespaceURI = doc.DocumentElement.NamespaceURI;

            using (Folder folder = Folder.Bind(base.MailboxSession, folderRequest.ServerId, null))
            {
                try
                {
                    this.ProcessFolderNameChange(folderRequest, folder);
                    if (folderRequest.ParentId.Equals(folderRequest.ServerId))
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateUnderSelf");
                        AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), null, false);
                        throw ex;
                    }
                    if (!folderRequest.ParentId.Equals(folder.ParentId))
                    {
                        using (Folder.Bind(base.MailboxSession, folderRequest.ParentId, null))
                        {
                        }
                        AggregateOperationResult aggregateOperationResult = base.MailboxSession.Move(folderRequest.ParentId, new StoreObjectId[]
                        {
                            folderRequest.ServerId
                        });
                        if (aggregateOperationResult.OperationResult == OperationResult.Failed)
                        {
                            AirSyncPermanentException ex;
                            if (aggregateOperationResult.GroupOperationResults != null && aggregateOperationResult.GroupOperationResults[0] != null && aggregateOperationResult.GroupOperationResults[0].Exception is ObjectExistedException)
                            {
                                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateOfNonExistentFolder");
                                ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), null, false);
                                throw ex;
                            }
                            base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateFailed");
                            ex = new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, base.ConstructErrorXml(StatusCode.Sync_ClientServerConversion), null, false);
                            throw ex;
                        }
                    }
                    FolderTree    folderTree      = (FolderTree)base.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                    ISyncItemId   syncItemId      = MailboxSyncItemId.CreateForNewItem(folderRequest.ServerId);
                    StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root);
                    ISyncItemId   parentId        = folderTree.GetParentId(syncItemId);
                    if (parentId != null)
                    {
                        folderTree.UnlinkChild(parentId, syncItemId);
                    }
                    if (!defaultFolderId.Equals(folderRequest.ParentId))
                    {
                        ISyncItemId parentId2 = MailboxSyncItemId.CreateForNewItem(folderRequest.ParentId);
                        folderTree.LinkChildToParent(parentId2, syncItemId);
                    }
                }
                catch (ObjectNotFoundException innerException)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ObjectNotFoundOnUpdate");
                    AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ServerError, base.ConstructErrorXml(StatusCode.Sync_ServerError), innerException, false);
                    throw ex;
                }
                catch (ObjectExistedException innerException2)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ObjectExistedOnUpdate");
                    AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), innerException2, false);
                    throw ex;
                }
                base.FolderHierarchySync.RecordClientOperation(folder.Id.ObjectId, ChangeType.Change, folder);
                folderRequest.RecoverySyncKey = folderRequest.SyncKey;
                folderRequest.SyncKey         = base.GetNextNumber(folderRequest.SyncKey);
                base.SyncStateChanged         = true;
                base.FolderHierarchySyncState[CustomStateDatumType.SyncKey]         = new Int32Data(folderRequest.SyncKey);
                base.FolderHierarchySyncState[CustomStateDatumType.RecoverySyncKey] = new Int32Data(folderRequest.RecoverySyncKey);
                base.ProtocolLogger.IncrementValue("F", PerFolderProtocolLoggerData.ClientChanges);
            }
            XmlNode xmlNode = doc.CreateElement("Status", namespaceURI);

            xmlNode.InnerText = "1";
            XmlNode xmlNode2 = doc.CreateElement("SyncKey", namespaceURI);

            xmlNode2.InnerText = folderRequest.SyncKey.ToString(CultureInfo.InvariantCulture);
            doc.DocumentElement.AppendChild(xmlNode);
            doc.DocumentElement.AppendChild(xmlNode2);
        }