// Token: 0x060009C1 RID: 2497 RVA: 0x00039668 File Offset: 0x00037868
 private void LoadSyncState()
 {
     this.folderIdMappingSyncState = base.SyncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]);
     if (this.folderIdMappingSyncState == null || this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] == null)
     {
         CustomSyncState customSyncState = base.SyncStateStorage.GetCustomSyncState(new GlobalSyncStateInfo(), new PropertyDefinition[0]);
         if (customSyncState == null)
         {
             base.SyncStateStorage.DeleteAllSyncStates();
         }
         else
         {
             customSyncState.Dispose();
             using (AutdStatusData autdStatusData = AutdStatusData.Load(base.SyncStateStorage, true, false))
             {
                 if (autdStatusData != null)
                 {
                     base.SyncStateStorage.DeleteAllSyncStates();
                 }
             }
         }
         this.folderIdMappingSyncState = base.SyncStateStorage.CreateCustomSyncState(new FolderIdMappingSyncStateInfo());
         this.folderIdMappingSyncState[CustomStateDatumType.IdMapping]              = new FolderIdMapping();
         this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree]         = new FolderTree();
         this.folderIdMappingSyncState[CustomStateDatumType.RecoveryFullFolderTree] = this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
     }
 }
Example #2
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);
        }
Example #3
0
        // Token: 0x06000CCE RID: 3278 RVA: 0x00044804 File Offset: 0x00042A04
        public static MeetingOrganizerSyncState LoadFromMailbox(MailboxSession mailboxSession, SyncStateStorage syncStateStorage, ProtocolLogger protocolLogger)
        {
            if (mailboxSession == null)
            {
                throw new ArgumentNullException("mailboxSession");
            }
            if (syncStateStorage == null)
            {
                throw new ArgumentNullException("syncStateStorage");
            }
            bool flag = false;
            MeetingOrganizerSyncState meetingOrganizerSyncState = null;
            CustomSyncState           customSyncState           = null;
            MeetingOrganizerSyncState result;

            try
            {
                MeetingOrganizerSyncStateInfo meetingOrganizerSyncStateInfo = new MeetingOrganizerSyncStateInfo();
                bool flag2 = false;
                ExTraceGlobals.FaultInjectionTracer.TraceTest <bool>(3104189757U, ref flag2);
                if (flag2)
                {
                    throw new CorruptSyncStateException(meetingOrganizerSyncStateInfo.UniqueName, new LocalizedString("FaultInjection"));
                }
                bool isDirty = false;
                customSyncState = syncStateStorage.GetCustomSyncState(meetingOrganizerSyncStateInfo, new PropertyDefinition[0]);
                if (customSyncState == null)
                {
                    customSyncState = syncStateStorage.CreateCustomSyncState(meetingOrganizerSyncStateInfo);
                    isDirty         = true;
                }
                else if (customSyncState.BackendVersion != null && customSyncState.BackendVersion.Value != customSyncState.Version)
                {
                    isDirty = true;
                }
                meetingOrganizerSyncState         = new MeetingOrganizerSyncState(customSyncState);
                meetingOrganizerSyncState.IsDirty = isDirty;
                flag   = true;
                result = meetingOrganizerSyncState;
            }
            finally
            {
                if (!flag)
                {
                    if (meetingOrganizerSyncState != null)
                    {
                        meetingOrganizerSyncState.Dispose();
                    }
                    else if (customSyncState != null)
                    {
                        customSyncState.Dispose();
                    }
                }
            }
            return(result);
        }
 private static bool TryGetSmsSyncDeviceLastSyncTime(SyncStateStorage syncStateStorage, E164Number smsSyncPhoneNumber, out ExDateTime lastSyncTime, out string deviceName)
 {
     lastSyncTime = ExDateTime.MinValue;
     deviceName   = null;
     using (CustomSyncState customSyncState = syncStateStorage.GetCustomSyncState(new GlobalSyncStateInfo
     {
         ReadOnly = true
     }, new PropertyDefinition[0]))
     {
         if (customSyncState == null)
         {
             return(false);
         }
         if (!customSyncState.GetData <BooleanData, bool>("DeviceEnableOutboundSMS", false))
         {
             return(false);
         }
         string data = customSyncState.GetData <StringData, string>("DevicePhoneNumber", null);
         if (string.IsNullOrEmpty(data))
         {
             return(false);
         }
         E164Number e164Number = null;
         if (!E164Number.TryParse(data, out e164Number))
         {
             return(false);
         }
         if (!e164Number.Equals(smsSyncPhoneNumber, true))
         {
             return(false);
         }
         deviceName = customSyncState.GetData <StringData, string>("DeviceFriendlyName", null);
     }
     lastSyncTime = syncStateStorage.CreationTime;
     using (CustomSyncState customSyncState2 = syncStateStorage.GetCustomSyncState(new SyncStatusSyncStateInfo
     {
         ReadOnly = true
     }, new PropertyDefinition[0]))
     {
         if (customSyncState2 != null)
         {
             lastSyncTime = customSyncState2.GetData <DateTimeData, ExDateTime>("LastSyncAttemptTime", ExDateTime.MinValue);
             if (ExDateTime.MinValue == lastSyncTime)
             {
                 lastSyncTime = customSyncState2.GetData <DateTimeData, ExDateTime>("LastSyncSuccessTime", syncStateStorage.CreationTime);
             }
         }
     }
     return(true);
 }
        // Token: 0x06000763 RID: 1891 RVA: 0x000291AC File Offset: 0x000273AC
        private StoreObjectId GetStoreObjectId(string folderId)
        {
            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 = "NoSyncStateInEmptyFolder"
                              };
                    }
                    if (customSyncState[CustomStateDatumType.IdMapping] == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoIdMappingInEmptyFolder"
                              };
                    }
                    this.folderIdMapping = (FolderIdMapping)customSyncState[CustomStateDatumType.IdMapping];
                }
            }
            SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(folderId);
            if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_Retry, false)
                      {
                          ErrorStringForProtocolLogger = "SpecialFolderInEmptyFolder"
                      };
            }
            MailboxSyncItemId mailboxSyncItemId = this.folderIdMapping[folderId] as MailboxSyncItemId;

            if (mailboxSyncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "NoIdMappingInEmptyFolder2"
                      };
            }
            return((StoreObjectId)mailboxSyncItemId.NativeId);
        }
        // Token: 0x06000299 RID: 665 RVA: 0x0000EF00 File Offset: 0x0000D100
        public static AirSyncRootInfo LoadFromMailbox(MailboxSession mailboxSession, SyncStateRootStorage syncStateRootStorage)
        {
            ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession);
            ArgumentValidator.ThrowIfNull("syncStateRootStorage", syncStateRootStorage);
            AirSyncRootInfo airSyncRootInfo = null;
            CustomSyncState customSyncState = null;
            bool            flag            = false;
            AirSyncRootInfo result;

            try
            {
                bool isDirty = false;
                AirSyncRootSyncStateInfo syncStateInfo = new AirSyncRootSyncStateInfo();
                customSyncState = syncStateRootStorage.GetCustomSyncState(syncStateInfo);
                if (customSyncState == null)
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "[AirSyncRootInfo.LoadFromMailbox] Had to create root sync state.");
                    customSyncState = syncStateRootStorage.CreateCustomSyncState(syncStateInfo);
                    isDirty         = true;
                }
                airSyncRootInfo         = new AirSyncRootInfo(customSyncState);
                airSyncRootInfo.IsDirty = isDirty;
                flag   = true;
                result = airSyncRootInfo;
            }
            finally
            {
                if (!flag)
                {
                    if (airSyncRootInfo != null)
                    {
                        airSyncRootInfo.Dispose();
                    }
                    else if (customSyncState != null)
                    {
                        customSyncState.Dispose();
                    }
                }
            }
            return(result);
        }
        // Token: 0x0600088E RID: 2190 RVA: 0x00032DC8 File Offset: 0x00030FC8
        private void LoadSyncState(int syncKey)
        {
            FolderIdMappingSyncStateInfo syncStateInfo = new FolderIdMappingSyncStateInfo();

            if (syncKey == 0)
            {
                base.SendServerUpgradeHeader  = true;
                this.folderIdMappingSyncState = base.SyncStateStorage.GetCustomSyncState(syncStateInfo, new PropertyDefinition[0]);
                if (this.folderIdMappingSyncState == null || this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] == null)
                {
                    CustomSyncState customSyncState = base.SyncStateStorage.GetCustomSyncState(new GlobalSyncStateInfo(), new PropertyDefinition[0]);
                    if (customSyncState == null)
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Could not find policy sync state.  Deleting all sync states.");
                        base.SyncStateStorage.DeleteAllSyncStates();
                    }
                    else
                    {
                        customSyncState.Dispose();
                        using (FolderHierarchySyncState folderHierarchySyncState = base.SyncStateStorage.GetFolderHierarchySyncState())
                        {
                            if (folderHierarchySyncState != null)
                            {
                                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Deleting all sync states.");
                                base.SyncStateStorage.DeleteAllSyncStates();
                            }
                        }
                    }
                    this.folderIdMappingSyncState = base.SyncStateStorage.CreateCustomSyncState(syncStateInfo);
                    this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] = new FolderIdMapping();
                    this.folderHierarchySyncState = base.SyncStateStorage.CreateFolderHierarchySyncState();
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Deleting folder hierarchy sync state.");
                    base.SyncStateStorage.DeleteFolderHierarchySyncState();
                    this.folderHierarchySyncState = base.SyncStateStorage.CreateFolderHierarchySyncState();
                    ((FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping]).CommitChanges();
                }
                this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree]         = new FolderTree();
                this.folderIdMappingSyncState[CustomStateDatumType.RecoveryFullFolderTree] = this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                base.InitializeSyncStatusSyncState();
                base.SyncStatusSyncData.ClearClientCategoryHash();
                this.shouldSaveSyncStatus = true;
                Interlocked.Exchange(ref this.validToCommitSyncStatusSyncState, 1);
            }
            else
            {
                this.folderIdMappingSyncState = base.SyncStateStorage.GetCustomSyncState(syncStateInfo, new PropertyDefinition[0]);
                this.folderHierarchySyncState = base.SyncStateStorage.GetFolderHierarchySyncState();
                if (this.folderHierarchySyncState == null || this.folderIdMappingSyncState == null || this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoHierarchyState");
                    throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                }
                FolderIdMapping   folderIdMapping = (FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping];
                StoreObjectId     defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);
                MailboxSyncItemId mailboxId       = MailboxSyncItemId.CreateForNewItem(defaultFolderId);
                if (!folderIdMapping.Contains(mailboxId))
                {
                    base.SyncStateStorage.DeleteAllSyncStates();
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InboxStoreObjectIdChanged");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateCorrupt, new LocalizedString("The sync state is corrupt.  It is most likely due to a recent mailbox migration."), false);
                }
            }
            if (this.folderHierarchySyncState.CustomVersion != null && this.folderHierarchySyncState.CustomVersion.Value > 5)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SyncStateVersionMismatch");
                throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateVersionInvalid, EASServerStrings.MismatchSyncStateError, true);
            }
        }
 // Token: 0x06000296 RID: 662 RVA: 0x0000EEC4 File Offset: 0x0000D0C4
 public AirSyncRootInfo(CustomSyncState wrappedState) : base(wrappedState)
 {
 }
Example #9
0
 public SyncStateDataInfo(CustomSyncState wrappedSyncState)
 {
     this.customSyncState = wrappedSyncState;
 }
        // Token: 0x06000AAA RID: 2730 RVA: 0x0003B168 File Offset: 0x00039368
        public static GlobalInfo LoadFromMailbox(MailboxSession mailboxSession, SyncStateStorage syncStateStorage, ProtocolLogger protocolLogger, out bool updateUserHasPartnership)
        {
            if (mailboxSession == null)
            {
                throw new ArgumentNullException("mailboxSession");
            }
            if (syncStateStorage == null)
            {
                throw new ArgumentNullException("syncStateStorage");
            }
            updateUserHasPartnership = false;
            CustomSyncState customSyncState         = null;
            GlobalInfo      globalInfo              = null;
            bool            isDirty                 = false;
            bool            hasNewSyncData          = false;
            bool            hasNewAutdData          = false;
            bool            isSyncStateJustUpgraded = false;
            bool            flag = false;
            GlobalInfo      result;

            try
            {
                GlobalSyncStateInfo syncStateInfo = new GlobalSyncStateInfo();
                customSyncState = syncStateStorage.GetCustomSyncState(syncStateInfo, GlobalInfo.ExtraGlobalInfoPropertiesToFetch);
                if (customSyncState == null)
                {
                    isDirty = true;
                    using (CustomSyncState customSyncState2 = syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]))
                    {
                        if (customSyncState2 == null)
                        {
                            updateUserHasPartnership = true;
                            syncStateStorage.DeleteAllSyncStates();
                        }
                    }
                    customSyncState = syncStateStorage.CreateCustomSyncState(syncStateInfo);
                    isDirty         = true;
                }
                else
                {
                    try
                    {
                        object obj = customSyncState.StoreObject.TryGetProperty(AirSyncStateSchema.LastSyncAttemptTime);
                        hasNewSyncData = (obj != null && !(obj is PropertyError));
                    }
                    catch (Exception arg)
                    {
                        AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestsTracer, null, "[GlobalInfo.LoadFromMailbox] Encountered exception when checking for new syncStatus properties.  Exception: {0}", arg);
                    }
                    try
                    {
                        object obj2 = customSyncState.StoreObject.TryGetProperty(AirSyncStateSchema.LastPingHeartbeatInterval);
                        hasNewAutdData = (obj2 != null && !(obj2 is PropertyError));
                    }
                    catch (Exception arg2)
                    {
                        AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestsTracer, null, "[GlobalInfo.LoadFromMailbox] Encountered exception when checking for new syncStatus properties.  Exception: {0}", arg2);
                    }
                    if (customSyncState.BackendVersion != null && customSyncState.BackendVersion.Value != customSyncState.Version)
                    {
                        isDirty = true;
                        isSyncStateJustUpgraded = true;
                        if (protocolLogger != null)
                        {
                            protocolLogger.SetValue(ProtocolLoggerData.Ssu, "2007");
                        }
                    }
                }
                globalInfo                         = new GlobalInfo(customSyncState);
                globalInfo.IsDirty                 = isDirty;
                globalInfo.HasNewSyncData          = hasNewSyncData;
                globalInfo.HasNewAutdData          = hasNewAutdData;
                globalInfo.IsSyncStateJustUpgraded = isSyncStateJustUpgraded;
                if (Command.CurrentCommand != null)
                {
                    globalInfo.WriteNewSyncData = Command.CurrentCommand.User.Features.IsEnabled(EasFeature.SyncStatusOnGlobalInfo);
                }
                flag   = true;
                result = globalInfo;
            }
            finally
            {
                if (!flag)
                {
                    if (globalInfo != null)
                    {
                        globalInfo.Dispose();
                    }
                    else if (customSyncState != null)
                    {
                        customSyncState.Dispose();
                    }
                }
            }
            return(result);
        }
 // Token: 0x06000A40 RID: 2624 RVA: 0x0003A8FC File Offset: 0x00038AFC
 public GlobalInfo(CustomSyncState wrappedSyncState) : base(wrappedSyncState)
 {
 }
        public override void OpenSyncState(bool autoLoadFilterAndSyncKey, SyncStateStorage syncStateStorage)
        {
            if (!(base.StoreSession is MailboxSession))
            {
                throw new InvalidOperationException();
            }
            RecipientInfoCacheSyncProviderFactory recipientInfoCacheSyncProviderFactory = (RecipientInfoCacheSyncProviderFactory)base.SyncProviderFactory;

            if (base.SyncKey != 0U || autoLoadFilterAndSyncKey)
            {
                base.SyncState = syncStateStorage.GetFolderSyncState(base.SyncProviderFactory, base.CollectionId);
                if (base.SyncState == null)
                {
                    if (autoLoadFilterAndSyncKey)
                    {
                        base.Status          = SyncBase.ErrorCodeStatus.InvalidSyncKey;
                        base.ResponseSyncKey = base.SyncKey;
                        throw new AirSyncPermanentException(false)
                              {
                                  ErrorStringForProtocolLogger = "NoSyncStateInRICacheSync"
                              };
                    }
                    using (CustomSyncState customSyncState = syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]))
                    {
                        if (customSyncState == null || customSyncState[CustomStateDatumType.IdMapping] == null)
                        {
                            base.Status = SyncBase.ErrorCodeStatus.InvalidCollection;
                            throw new AirSyncPermanentException(false)
                                  {
                                      ErrorStringForProtocolLogger = "BadFolderMapTreeInRICacheSync"
                                  };
                        }
                    }
                    base.Status          = SyncBase.ErrorCodeStatus.InvalidSyncKey;
                    base.ResponseSyncKey = base.SyncKey;
                    throw new AirSyncPermanentException(false)
                          {
                              ErrorStringForProtocolLogger = "Sk0ErrorInRICacheSync"
                          };
                }
                else
                {
                    base.CheckProtocolVersion();
                    if (autoLoadFilterAndSyncKey)
                    {
                        if (!base.SyncState.Contains(CustomStateDatumType.SyncKey))
                        {
                            base.Status          = SyncBase.ErrorCodeStatus.InvalidSyncKey;
                            base.ResponseSyncKey = base.SyncKey;
                            throw new AirSyncPermanentException(false)
                                  {
                                      ErrorStringForProtocolLogger = "NoSyncStateKeyInRICacheSync"
                                  };
                        }
                        base.SyncKey = ((UInt32Data)base.SyncState[CustomStateDatumType.SyncKey]).Data;
                        if (base.SyncState.Contains(CustomStateDatumType.RecoverySyncKey))
                        {
                            base.RecoverySyncKey = ((UInt32Data)base.SyncState[CustomStateDatumType.RecoverySyncKey]).Data;
                        }
                        base.FilterType = (AirSyncV25FilterTypes)base.SyncState.GetData <Int32Data, int>(CustomStateDatumType.FilterType, 0);
                        base.SyncState[CustomStateDatumType.MaxItems] = new Int32Data(base.MaxItems);
                    }
                }
            }
            if (base.SyncKey == 0U)
            {
                SyncState syncState = null;
                try
                {
                    syncState = syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]);
                    if ((FolderIdMapping)syncState[CustomStateDatumType.IdMapping] == null)
                    {
                        base.Status          = SyncBase.ErrorCodeStatus.ServerError;
                        base.ResponseSyncKey = 0U;
                        AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "Id Mapping not created on SK0-returning ServerError on RI collection");
                        throw new AirSyncPermanentException(false)
                              {
                                  ErrorStringForProtocolLogger = "NoIdMappingInRICacheSync"
                              };
                    }
                }
                finally
                {
                    if (syncState != null)
                    {
                        syncState.Dispose();
                    }
                }
                syncStateStorage.DeleteFolderSyncState(base.CollectionId);
                base.SyncState = syncStateStorage.CreateFolderSyncState(base.SyncProviderFactory, base.CollectionId);
                base.SyncState.RegisterColdDataKey("IdMapping");
                base.SyncState.RegisterColdDataKey("CustomCalendarSyncFilter");
                base.SyncState[CustomStateDatumType.IdMapping] = new ItemIdMapping(base.CollectionId);
                base.ClassType = "RecipientInfoCache";
                base.SyncState[CustomStateDatumType.AirSyncClassType] = new ConstStringData(StaticStringPool.Instance.Intern(base.ClassType));
            }
            else
            {
                object obj = base.SyncState[CustomStateDatumType.AirSyncClassType];
                if (obj == null || string.IsNullOrEmpty(((ConstStringData)obj).Data))
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ClassType for RI folder was null in sync state");
                    base.ClassType = "RecipientInfoCache";
                }
                else
                {
                    if (!string.Equals("RecipientInfoCache", ((ConstStringData)obj).Data, StringComparison.OrdinalIgnoreCase))
                    {
                        base.Status = SyncBase.ErrorCodeStatus.ObjectNotFound;
                        string text = string.Format("Invalid Class Type in RI sync state: {0}", ((ConstStringData)obj).Data);
                        AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, text);
                        throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, new LocalizedString(text), false)
                              {
                                  ErrorStringForProtocolLogger = "BadClassStateInRICacheSync"
                              };
                    }
                    base.ClassType = ((ConstStringData)obj).Data;
                }
            }
            if (base.SyncState.CustomVersion != null && base.SyncState.CustomVersion.Value > 9)
            {
                throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateVersionInvalid, EASServerStrings.MismatchSyncStateError, true)
                      {
                          ErrorStringForProtocolLogger = "MismatchedSyncStateInRICacheSync"
                      };
            }
            base.SyncState[CustomStateDatumType.AirSyncProtocolVersion] = new Int32Data(base.ProtocolVersion);
        }
Example #13
0
 // Token: 0x06000CCB RID: 3275 RVA: 0x000447B8 File Offset: 0x000429B8
 public MeetingOrganizerSyncState(CustomSyncState wrappedSyncState) : base(wrappedSyncState)
 {
 }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            MailboxSession mailboxSession = null;

            try
            {
                mailboxSession = MailboxSession.OpenAsAdmin(this.principal, CultureInfo.InvariantCulture, "Client=Management;Action=Get-ActiveSyncDeviceStatistics");
                DeviceInfo deviceInfo = MobileDeviceTaskHelper.GetDeviceInfo(mailboxSession, this.Identity);
                if (deviceInfo == null)
                {
                    base.WriteError(new MobileDeviceNotExistException(this.Identity.ToString()), ErrorCategory.InvalidOperation, this.Identity);
                }
                using (SyncStateStorage syncStateStorage = SyncStateStorage.Bind(mailboxSession, deviceInfo.DeviceIdentity, null))
                {
                    if (syncStateStorage == null)
                    {
                        base.WriteError(new MobileDeviceNotExistException(this.Identity.ToString()), ErrorCategory.InvalidOperation, this.Identity);
                    }
                    using (CustomSyncState orCreateGlobalSyncState = AirSyncUtility.GetOrCreateGlobalSyncState(syncStateStorage))
                    {
                        if (this.Cancel)
                        {
                            if (!DeviceInfo.CancelRemoteWipeFromMailbox(orCreateGlobalSyncState))
                            {
                                this.WriteWarning(Strings.CannotCancelWipe(this.Identity.ToString()));
                            }
                        }
                        else
                        {
                            DeviceInfo.StartRemoteWipeFromMailbox(syncStateStorage, orCreateGlobalSyncState, ExDateTime.UtcNow, this.validatedAddresses, this.wipeRequestorSMTP);
                        }
                        orCreateGlobalSyncState.Commit();
                    }
                }
                base.InternalProcessRecord();
            }
            catch (FolderSaveException exception)
            {
                base.WriteError(exception, ErrorCategory.WriteError, this.Identity);
            }
            catch (CorruptSyncStateException ex)
            {
                TaskLogger.LogError(ex);
                base.WriteError(ex, ErrorCategory.ReadError, this.principal);
            }
            catch (InvalidSyncStateVersionException ex2)
            {
                TaskLogger.LogError(ex2);
                base.WriteError(ex2, ErrorCategory.ReadError, this.principal);
            }
            catch (StorageTransientException ex3)
            {
                TaskLogger.LogError(ex3);
                base.WriteError(ex3, ErrorCategory.ReadError, this.principal);
            }
            catch (StoragePermanentException ex4)
            {
                TaskLogger.LogError(ex4);
                base.WriteError(ex4, ErrorCategory.InvalidOperation, this.principal);
            }
            catch (InvalidOperationException ex5)
            {
                TaskLogger.LogError(ex5);
                base.WriteError(ex5, ErrorCategory.InvalidOperation, this.principal);
            }
            finally
            {
                if (mailboxSession != null)
                {
                    mailboxSession.Dispose();
                }
                TaskLogger.LogExit();
            }
        }