public static UserConfiguration GetConfiguration(Folder folder, UserConfigurationName configurationName, UserConfigurationTypes type)
 {
     EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(type, "type");
     try
     {
         return(UserConfiguration.GetIgnoringCache(null, folder, configurationName, type));
     }
     catch (ObjectNotFoundException arg)
     {
         ExTraceGlobals.StorageTracer.TraceError <ObjectNotFoundException>(0L, "UserConfiguration::GetConfiguration. User Configuration object not found. Exception = {0}.", arg);
     }
     return(UserConfiguration.Create(folder, configurationName, type));
 }
 private ConfigurationDictionary DeserializeDictionary(byte[] data)
 {
     if (data == null)
     {
         return(null);
     }
     using (MemoryStream memoryStream = new MemoryStream(data))
     {
         this.configDictionary = new ConfigurationDictionary();
         this.configDictionary.ReadXml(UserConfiguration.InternalGetXmlReader(memoryStream));
     }
     return(this.configDictionary);
 }
 private UserConfiguration InternalCreateUserConfiguration(Folder folder, UserConfigurationName configurationName, UserConfigurationTypes dataTypes)
 {
     ExTraceGlobals.StorageTracer.Information <UserConfigurationName, UserConfigurationTypes>((long)this.GetHashCode(), "UserConfigurationManager::InternalCreateUserConfiguration. configurationName = {0}, dataTypes = {1}.", configurationName, dataTypes);
     if (folder == null)
     {
         throw new ArgumentNullException("folder");
     }
     if (!EnumValidator.IsValidValue <UserConfigurationTypes>(dataTypes))
     {
         ExTraceGlobals.StorageTracer.TraceError((long)this.GetHashCode(), "UserConfigurationManager::InternalCreateUserConfiguration. dataTypes is invalid.");
         throw new ArgumentException("dataTypes");
     }
     return(UserConfiguration.Create(folder, configurationName, dataTypes));
 }
        private IReadableUserConfiguration CreateMclConfiguration()
        {
            IReadableUserConfiguration result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                UserConfiguration userConfiguration = this.session.UserConfigurationManager.CreateFolderConfiguration("CategoryList", UserConfigurationTypes.XML, this.session.GetDefaultFolderId(DefaultFolderType.Calendar));
                disposeGuard.Add <UserConfiguration>(userConfiguration);
                userConfiguration.Save();
                disposeGuard.Success();
                result = userConfiguration;
            }
            return(result);
        }
 private void InternalDeleteUserConfiguration(Folder folder, string configurationName)
 {
     ExTraceGlobals.StorageTracer.Information <string>((long)this.GetHashCode(), "Folder::DeleteUserConfiguration. configurationName = {0}.", (configurationName == null) ? "<Null>" : configurationName);
     if (configurationName == null)
     {
         ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "Folder::DeleteUserConfiguration. Argument {0} is Null.", "configurationName");
         throw new ArgumentNullException(ServerStrings.ExNullParameter("configurationName", 1));
     }
     if (configurationName.Length == 0)
     {
         ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "Folder::DeleteUserConfiguration. Argument {0} is Empty.", "configurationName");
         throw new ArgumentException(ServerStrings.ExInvalidParameter("configurationName", 1));
     }
     UserConfiguration.Delete(folder, configurationName, UserConfigurationSearchFlags.FullString);
 }
 public void Save(SaveMode saveMode)
 {
     EnumValidator.ThrowIfInvalid <SaveMode>(saveMode);
     if (!this.IsLoaded)
     {
         throw new InvalidOperationException("The Master Category List is not loaded and thus cannot be saved");
     }
     this.FlushCategoryUsageLog();
     if (!this.IsDirty())
     {
         return;
     }
     this.propertyBag[MasterCategoryListSchema.LastSavedTime] = ExDateTime.GetNow(ExTimeZone.UtcTimeZone);
     using (UserConfiguration folderConfiguration = this.session.UserConfigurationManager.GetFolderConfiguration("CategoryList", UserConfigurationTypes.XML, this.session.GetDefaultFolderId(DefaultFolderType.Calendar)))
     {
         MasterCategoryList masterCategoryList;
         using (Stream xmlStream = folderConfiguration.GetXmlStream())
         {
             masterCategoryList = ((!this.configurationItemId.Equals(folderConfiguration.VersionedId)) ? this.MergeCopies(saveMode, folderConfiguration, xmlStream) : this);
             xmlStream.Position = 0L;
             using (Stream stream = new MemoryStream((int)xmlStream.Length))
             {
                 masterCategoryList.SaveToStream(saveMode, stream, xmlStream);
                 if (stream.Length > 524288L)
                 {
                     throw new StoragePermanentException(ServerStrings.ExMclIsTooBig(stream.Length, 524288L));
                 }
                 stream.Position    = 0L;
                 xmlStream.Position = 0L;
                 xmlStream.SetLength(0L);
                 Util.StreamHandler.CopyStreamData(stream, xmlStream);
             }
         }
         folderConfiguration.Save();
         this.MovePersistentContent(masterCategoryList);
         this.originalMcl         = this.Clone();
         this.configurationItemId = folderConfiguration.VersionedId;
         this.loadedWithProblems  = false;
         this.propertyBag.ClearChangeInfo();
         this.isListModified = false;
     }
 }
示例#7
0
 internal void SaveToCalendar(MailboxSession session, StoreId folderId)
 {
     try
     {
         using (UserConfiguration orCreateWorkingHourConfiguration = WorkHoursInCalendar.GetOrCreateWorkingHourConfiguration(session, folderId))
         {
             using (Stream xmlStream = orCreateWorkingHourConfiguration.GetXmlStream())
             {
                 xmlStream.SetLength(0L);
                 this.SerializeObject(xmlStream);
                 orCreateWorkingHourConfiguration.Save();
             }
         }
     }
     catch (InvalidOperationException ex)
     {
         ExTraceGlobals.WorkHoursTracer.TraceError <string, InvalidOperationException>((long)this.GetHashCode(), "{0}: Could not save work hours configuration item to mailbox. Exception information is {1}.", session.MailboxOwner.MailboxInfo.DisplayName, ex);
         throw new WorkingHoursXmlMalformedException(ServerStrings.SaveConfigurationItem(session.MailboxOwner.MailboxInfo.DisplayName, ex.ToString()));
     }
 }
示例#8
0
        private static UserConfiguration GetOrCreateWorkingHourConfiguration(MailboxSession session, StoreId folderId)
        {
            UserConfigurationManager userConfigurationManager = session.UserConfigurationManager;
            UserConfiguration        userConfiguration        = null;

            try
            {
                userConfiguration = userConfigurationManager.GetFolderConfiguration("WorkHours", UserConfigurationTypes.XML, folderId);
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.WorkHoursTracer.TraceDebug <string>(0L, "WorkHoursInCalendar::GetOrCreateWorkingHourConfiguration. GetOrCreateWorkingHourConfigurationStorageWorkingHours does not exist yet. I am going to create a new one. Mailbox = {0}.", session.MailboxOwner.MailboxInfo.DisplayName);
                userConfiguration = userConfigurationManager.CreateFolderConfiguration("WorkHours", UserConfigurationTypes.XML, folderId);
            }
            if (userConfiguration == null)
            {
                throw new WorkingHoursSaveFailedException(ServerStrings.CreateConfigurationItem(session.MailboxOwner.MailboxInfo.DisplayName));
            }
            return(userConfiguration);
        }
        private UserConfiguration InternalBindAndGetUserConfiguration(StoreId folderId, UserConfigurationName configurationName, UserConfigurationTypes freefetchDataType)
        {
            UserConfiguration result = null;

            using (Folder folder = Folder.Bind(this.mailboxSession, folderId))
            {
                if (folder.IsNew)
                {
                    ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. The folder Id is null maybe it is because the folder has not been saved yet. Id = {0}.", "null");
                    throw new InvalidOperationException(ServerStrings.ExFolderWithoutMapiProp);
                }
                if (!EnumValidator.IsValidValue <UserConfigurationTypes>(freefetchDataType))
                {
                    ExTraceGlobals.StorageTracer.TraceError <UserConfigurationTypes>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. freefetchDataType is not allowed. freefetchDataType = {0}.", freefetchDataType);
                    throw new ArgumentException("freefetchDataType");
                }
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. Hit code GetIgnoringCache. ConfigName = {0}.", configurationName);
                result = UserConfiguration.GetIgnoringCache(this, folder, configurationName, freefetchDataType);
            }
            return(result);
        }
示例#10
0
        public static UserConfiguration Create(Folder folder, UserConfigurationName configurationName, UserConfigurationTypes type)
        {
            EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(type, "type");
            IList <IStorePropertyBag> list = null;

            try
            {
                list = UserConfiguration.QueryConfigurations(folder, null, configurationName, UserConfigurationSearchFlags.FullString, 1, new PropertyDefinition[0]);
            }
            catch (InvalidOperationException innerException)
            {
                throw new InvalidOperationException(ServerStrings.ExCannotQueryAssociatedTable, innerException);
            }
            if (list.Count > 0)
            {
                ExTraceGlobals.StorageTracer.TraceError <UserConfigurationName>(0L, "UserConfiguration::Create. The configuration object has existed. ConfigName = {0}.", configurationName);
                throw new ObjectExistedException(ServerStrings.ExConfigExisted(configurationName.Name));
            }
            ConfigurationItem configurationItem = null;
            bool flag = false;
            UserConfiguration result;

            try
            {
                configurationItem = ItemBuilder.CreateNewItem <ConfigurationItem>(folder.Session, folder.Id, ItemCreateInfo.ConfigurationItemInfo, CreateMessageType.Associated);
                bool openMode = false;
                UserConfiguration userConfiguration = new UserConfiguration(configurationItem, folder.StoreObjectId, configurationName, type, openMode);
                flag   = true;
                result = userConfiguration;
            }
            finally
            {
                if (!flag)
                {
                    Util.DisposeIfPresent(configurationItem);
                }
            }
            return(result);
        }
示例#11
0
        public static ExTimeZone GetUserTimeZone(MailboxSession mailboxSession)
        {
            ExTimeZone        result = null;
            UserConfiguration mailboxConfiguration = UserConfigurationHelper.GetMailboxConfiguration(mailboxSession, "OWA.UserOptions", UserConfigurationTypes.Dictionary, false);

            if (mailboxConfiguration == null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>(0L, "{0}: UserOption doesn't exist.", mailboxSession.MailboxOwner);
            }
            else
            {
                using (mailboxConfiguration)
                {
                    IDictionary dictionary = null;
                    try
                    {
                        dictionary = mailboxConfiguration.GetDictionary();
                    }
                    catch (CorruptDataException)
                    {
                        ExTraceGlobals.StorageTracer.TraceError <IExchangePrincipal>(0L, "{0}: Dictionary exists but is corrupt.", mailboxSession.MailboxOwner);
                    }
                    catch (InvalidOperationException)
                    {
                        ExTraceGlobals.StorageTracer.TraceError <IExchangePrincipal>(0L, "{0}: Dictionary is invalid.", mailboxSession.MailboxOwner);
                    }
                    if (dictionary != null)
                    {
                        string text = dictionary[MailboxRegionalConfigurationSchema.TimeZone.Name] as string;
                        ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal, string>(0L, "{0}: Get timezone from dictionary of configuration. KeyName = {1}", mailboxSession.MailboxOwner, text);
                        if (string.IsNullOrEmpty(text) || !ExTimeZoneEnumerator.Instance.TryGetTimeZoneByName(text, out result))
                        {
                            ExTraceGlobals.StorageTracer.TraceError <IExchangePrincipal, string>(0L, "{0}: The KeyName of TimeZone is invalid. KeyName = {1}", mailboxSession.MailboxOwner, text);
                        }
                    }
                }
            }
            return(result);
        }
 IList <IStorePropertyBag> IUserConfigurationManager.FetchAllConfigurations(IFolder folder, SortBy[] sorts, int maxRow, params PropertyDefinition[] columns)
 {
     return(UserConfiguration.FetchAllConfigurations(folder, sorts, maxRow, columns));
 }
示例#13
0
        internal static UserConfiguration GetIgnoringCache(UserConfigurationManager manager, Folder folder, UserConfigurationName configurationName, UserConfigurationTypes freefetchType)
        {
            EnumValidator.AssertValid <UserConfigurationTypes>(freefetchType);
            UserConfiguration userConfiguration = null;

            PropertyDefinition[] columns;
            if ((freefetchType & UserConfigurationTypes.Dictionary) > (UserConfigurationTypes)0)
            {
                columns = new PropertyDefinition[]
                {
                    InternalSchema.UserConfigurationDictionary
                };
            }
            else
            {
                columns = UserConfiguration.ZeroProperties;
            }
            SortBy[] sorts = new SortBy[]
            {
                new SortBy(InternalSchema.CreationTime, SortOrder.Ascending),
                new SortBy(InternalSchema.MID, SortOrder.Ascending)
            };
            IList <IStorePropertyBag> list = null;

            try
            {
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Hit Query. ConfigName = {0}.", configurationName);
                list = UserConfiguration.QueryConfigurations(folder, sorts, configurationName, UserConfigurationSearchFlags.FullString, 2, columns);
            }
            catch (InvalidOperationException innerException)
            {
                throw new InvalidOperationException(ServerStrings.ExCannotQueryAssociatedTable, innerException);
            }
            if (list.Count <= 0)
            {
                ExTraceGlobals.StorageTracer.TraceError <UserConfigurationName, UserConfigurationTypes>(0L, "UserConfiguration::GetIgnoringCache. The configuration object was not found. Name = {0}, type = {1}.", configurationName, freefetchType);
                throw new ObjectNotFoundException(ServerStrings.ExConfigurationNotFound(configurationName.Name));
            }
            ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Find the config item and build user config object from it. ConfigName = {0}.", configurationName);
            bool flag = false;
            UserConfiguration result2;

            try
            {
                userConfiguration = UserConfiguration.BuildConfigurationFromQueryItem(folder, list[0], (freefetchType & UserConfigurationTypes.Dictionary) > (UserConfigurationTypes)0);
                if (list.Count > 1)
                {
                    ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Found duplicate items. Conflict resolution. ConfigName = {0}.", configurationName);
                    List <VersionedId> list2 = new List <VersionedId>();
                    list = UserConfiguration.QueryConfigurations(folder, sorts, configurationName, UserConfigurationSearchFlags.FullString, 100, new PropertyDefinition[0]);
                    for (int i = 1; i < list.Count; i++)
                    {
                        list2.Add((VersionedId)list[i][InternalSchema.ItemId]);
                    }
                    if (list2.Count > 0)
                    {
                        AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.HardDelete, list2.ToArray());
                        UserConfiguration.CheckOperationResults(result, "DeleteDuplicates");
                    }
                }
                flag    = true;
                result2 = userConfiguration;
            }
            finally
            {
                if (!flag && userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
            }
            return(result2);
        }
示例#14
0
 protected override void InitializeNewItemData(IStoreSession session, IFolder folder, HierarchySyncMetadataItem newMetadataItem)
 {
     if (folder != null)
     {
         bool flag = false;
         HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <VersionedId>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Getting UserConfiguration from folder {0}", folder.Id);
         using (UserConfiguration configuration = UserConfiguration.GetConfiguration(folder as Folder, new UserConfigurationName("PublicFolderSyncInfo", ConfigurationNameKind.Name), UserConfigurationTypes.Dictionary))
         {
             IDictionary dictionary = configuration.GetDictionary();
             ExDateTime  exDateTime;
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <ExDateTime>(dictionary, "FirstFailedSyncTimeAfterLastSuccess", out exDateTime))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <ExDateTime>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found FirstFailedSyncTimeAfterLastSuccess in UserConfiguration. Value {0}", exDateTime);
                 newMetadataItem.FirstFailedSyncTimeAfterLastSuccess = exDateTime;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <ExDateTime>(dictionary, "LastAttemptedSyncTime", out exDateTime))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <ExDateTime>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found LastAttemptedSyncTime in UserConfiguration. Value {0}", exDateTime);
                 newMetadataItem.LastAttemptedSyncTime = exDateTime;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <ExDateTime>(dictionary, "LastFailedSyncTime", out exDateTime))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <ExDateTime>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found LastFailedSyncTime in UserConfiguration. Value {0}", exDateTime);
                 newMetadataItem.LastFailedSyncTime = exDateTime;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <ExDateTime>(dictionary, "LastSuccessfulSyncTime", out exDateTime))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <ExDateTime>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found LastSuccessfulSyncTime in UserConfiguration. Value {0}", exDateTime);
                 newMetadataItem.LastSuccessfulSyncTime = exDateTime;
                 flag = true;
             }
             int num;
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "NumberofAttemptsAfterLastSuccess", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found NumberOfAttemptsAfterLastSuccess in UserConfiguration. Value {0}", num);
                 newMetadataItem.NumberOfAttemptsAfterLastSuccess = num;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "NumberOfBatchesExecuted", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found NumberOfBatchesExecuted in UserConfiguration. Value {0}", num);
                 newMetadataItem.NumberOfBatchesExecuted = num;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "NumberOfFoldersSynced", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found NumberOfFoldersSynced in UserConfiguration. Value {0}", num);
                 newMetadataItem.NumberOfFoldersSynced = num;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "NumberOfFoldersToBeSynced", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found NumberOfFoldersToBeSynced in UserConfiguration. Value {0}", num);
                 newMetadataItem.NumberOfFoldersToBeSynced = num;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "BatchSize", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found BatchSize in UserConfiguration. Value {0}", num);
                 newMetadataItem.BatchSize = num;
                 flag = true;
             }
             string text;
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <string>(dictionary, "LastSyncFailure", out text))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found LastSyncFailure in UserConfiguration. Value {0}", text);
                 newMetadataItem.LastSyncFailure = text;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <string>(dictionary, "SyncState", out text) && !string.IsNullOrWhiteSpace(text))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found SyncState in UserConfiguration. Value {0}", text);
                 using (Stream syncStateOverrideStream = newMetadataItem.GetSyncStateOverrideStream())
                 {
                     HierarchySyncMetadataItemHandler.CopyStringToMetadataAttachment(text, syncStateOverrideStream);
                     flag = true;
                 }
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <string>(dictionary, "FinalJobSyncState", out text) && !string.IsNullOrWhiteSpace(text))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found FinalJobSyncState in UserConfiguration. Value {0}", text);
                 using (Stream finalJobSyncStateWriteStream = newMetadataItem.GetFinalJobSyncStateWriteStream(true))
                 {
                     HierarchySyncMetadataItemHandler.CopyStringToMetadataAttachment(text, finalJobSyncStateWriteStream);
                     flag = true;
                 }
             }
             byte[] array;
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <byte[]>(dictionary, "PartiallyCommittedFolderIds", out array))
             {
                 if (HierarchySyncMetadataItemHandler.PublicFolderTracer.IsTraceEnabled(TraceType.DebugTrace))
                 {
                     HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found PartiallyCommittedFolderIds in UserConfiguration. Value {0}", Convert.ToBase64String(array));
                 }
                 using (Reader reader = Reader.CreateBufferReader(array))
                 {
                     newMetadataItem.SetPartiallyCommittedFolderIds(IdSet.ParseWithReplGuids(reader));
                     flag = true;
                 }
             }
         }
         if (flag)
         {
             HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Metadata Item was updated. Saving and reloading properties.");
             newMetadataItem.Save(SaveMode.FailOnAnyConflict);
             newMetadataItem.Load();
             return;
         }
     }
     else
     {
         HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Skipping import from UserConfiguration as no folder was provided.");
     }
 }
 // Token: 0x06000FC7 RID: 4039 RVA: 0x00040805 File Offset: 0x0003EA05
 public static RecipientInfoCache Create(UserConfiguration userConfiguration)
 {
     return(new RecipientInfoCache(userConfiguration));
 }
示例#16
0
        private static UserConfiguration BuildConfigurationFromQueryItem(Folder folder, IStorePropertyBag row, bool hasLoadedUserConfigurationData)
        {
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.ItemClass)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = ItemClass.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("ItemClass"));
            }
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.ItemId)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = Id.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Id"));
            }
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.UserConfigurationType)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = UserConfigurationType.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("UserConfigurationType"));
            }
            string name = (string)row[InternalSchema.ItemClass];

            if (!UserConfigurationName.IsValidName(name, ConfigurationNameKind.ItemClass))
            {
                return(null);
            }
            UserConfigurationName configurationName = new UserConfigurationName(name, ConfigurationNameKind.ItemClass);

            if (hasLoadedUserConfigurationData)
            {
                object dictionaryObject = UserConfiguration.CheckDictionaryData(row.TryGetProperty(InternalSchema.UserConfigurationDictionary));
                return(new UserConfiguration(configurationName, folder.Session, folder.Id.ObjectId, (VersionedId)row[InternalSchema.ItemId], dictionaryObject, UserConfiguration.CheckUserConfigurationType((int)row[InternalSchema.UserConfigurationType]), row));
            }
            return(new UserConfiguration(configurationName, folder.Session, folder.Id.ObjectId, (VersionedId)row[InternalSchema.ItemId], null, UserConfiguration.CheckUserConfigurationType((int)row[InternalSchema.UserConfigurationType]), row));
        }
示例#17
0
 private static bool VerifyAndFixRemindersSearchFolder(DefaultFolderContext context, SearchFolder reminders)
 {
     RemindersSearchFolderValidation.RemindersSearchFolderState remindersSearchFolderState = RemindersSearchFolderValidation.GetRemindersSearchFolderState(context, reminders);
     if (!remindersSearchFolderState.IsUpToDate)
     {
         ExTraceGlobals.DefaultFoldersTracer.TraceDebug <RemindersSearchFolderValidation.RemindersSearchFolderState>(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. We are updating reminder's state: {0}", remindersSearchFolderState);
         if (context.Session.LogonType != LogonType.Owner)
         {
             return(false);
         }
         QueryFilter[] array = (remindersSearchFolderState.Version == RemindersSearchFolderValidation.RemindersSearchFolderVersion.O12) ? RemindersSearchFolderValidation.GetO12RemindersSearchFolderExclusionList(reminders.GetSearchCriteria()) : null;
         if (array != null && array.Length > 30)
         {
             string message = "A maximum allowed number of exclusion entries for a Reminders search folder is reached.Either default folders got re-created numerous times or the folder completeness criteria produced false negatives.";
             ExTraceGlobals.DefaultFoldersTracer.TraceError(-1L, message);
             return(true);
         }
         SearchFolderCriteria searchFolderCriteria = RemindersSearchFolderValidation.CreateRemindersQueryForO12(context, array);
         if (array != null)
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <int, int>(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. Current Reminders search criteria is incomplete: {0} exclusions versus {1} expected", array.Length, RemindersSearchFolderValidation.GetO12RemindersSearchFolderExclusionList(searchFolderCriteria).Length);
         }
         if (remindersSearchFolderState.Version != RemindersSearchFolderValidation.RemindersSearchFolderVersion.O11)
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <RemindersSearchFolderValidation.RemindersSearchFolderState>(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. Reminder starts to apply new criteria on the folder. folderState = {0}.", remindersSearchFolderState);
             reminders.ApplyContinuousSearch(searchFolderCriteria);
         }
         else
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <RemindersSearchFolderValidation.RemindersSearchFolderState>(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. Outlook12. folderState = {0}.", remindersSearchFolderState);
             IAsyncResult asyncResult = reminders.BeginApplyContinuousSearch(searchFolderCriteria, null, null);
             if (RemindersSearchFolderValidation.InternalWaitForRemindersIndexing(asyncResult))
             {
                 reminders.EndApplyContinuousSearch(asyncResult);
             }
             else
             {
                 ExTraceGlobals.DefaultFoldersTracer.TraceDebug(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. Timeout expired waiting for a Reminders search folder to finish population.");
             }
             RemindersSearchFolderValidation.UnsetStaleReminders(context, reminders);
             UserConfiguration userConfiguration = null;
             try
             {
                 try
                 {
                     userConfiguration = context.Session.UserConfigurationManager.GetFolderConfiguration("Calendar", UserConfigurationTypes.Dictionary, context.Session.GetDefaultFolderId(DefaultFolderType.Calendar));
                 }
                 catch (ObjectNotFoundException)
                 {
                     ExTraceGlobals.DefaultFoldersTracer.TraceDebug(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. No existing Calendar configuration was found. We are creating new one.");
                     userConfiguration = context.Session.UserConfigurationManager.CreateFolderConfiguration("Calendar", UserConfigurationTypes.Dictionary, context.Session.GetDefaultFolderId(DefaultFolderType.Calendar));
                 }
                 IDictionary dictionary = userConfiguration.GetDictionary();
                 dictionary["piReminderUpgradeTime"] = Util.ConvertDateTimeToRTime(ExDateTime.GetNow(context.Session.ExTimeZone));
                 userConfiguration.Save();
             }
             finally
             {
                 if (userConfiguration != null)
                 {
                     userConfiguration.Dispose();
                 }
             }
         }
     }
     return(true);
 }