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);
        }
 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;
     }
 }
示例#3
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()));
     }
 }
示例#4
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);
 }