internal void Load(bool forceReload)
        {
            if (this.IsLoaded && !forceReload)
            {
                return;
            }
            IReadableUserConfiguration readableUserConfiguration = null;

            this.loadedWithProblems = false;
            try
            {
                try
                {
                    readableUserConfiguration = this.session.UserConfigurationManager.GetReadOnlyFolderConfiguration("CategoryList", UserConfigurationTypes.XML, this.session.GetDefaultFolderId(DefaultFolderType.Calendar));
                    ExTraceGlobals.StorageTracer.TraceDebug((long)this.GetHashCode(), "MasterCategoryList::Load - newly loaded configurationItem");
                    if (this.configurationItemId != null && this.configurationItemId.Equals(readableUserConfiguration.VersionedId))
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug((long)this.GetHashCode(), "MasterCategoryList::Load - returning without reloading since this.configurationItemId.Equals(configurationItem.VersionedId.");
                        return;
                    }
                }
                catch (ObjectNotFoundException)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug((long)this.GetHashCode(), "MasterCategoryList::Load - ObjectNotFoundException: creating and saving a new MCL");
                    try
                    {
                        readableUserConfiguration = this.CreateMclConfiguration();
                    }
                    catch (ObjectExistedException ex)
                    {
                        ExTraceGlobals.StorageTracer.TraceWarning <string, string>((long)this.GetHashCode(), "MclConfiguration already created. Error: {0}. Stack: {1}.", ex.Message, ex.StackTrace);
                        readableUserConfiguration = this.session.UserConfigurationManager.GetFolderConfiguration("CategoryList", UserConfigurationTypes.XML, this.session.GetDefaultFolderId(DefaultFolderType.Calendar));
                    }
                }
                using (Stream xmlStream = readableUserConfiguration.GetXmlStream())
                {
                    this.Load(xmlStream);
                    this.originalMcl         = this.Clone();
                    this.configurationItemId = readableUserConfiguration.VersionedId;
                }
                this.isListModified = false;
            }
            finally
            {
                if (readableUserConfiguration != null)
                {
                    readableUserConfiguration.Dispose();
                }
            }
        }
 internal static ConfigurableObject Fill(ConfigurableObject configObject, ProviderPropertyDefinition property, UserConfigurationXmlHelper.GetReadableXmlUserConfigurationDelegate getXmlUserConfigurationDelegate)
 {
     Util.ThrowOnNullArgument(configObject, "configObject");
     Util.ThrowOnNullArgument(property, "property");
     using (IReadableUserConfiguration readableUserConfiguration = getXmlUserConfigurationDelegate(false))
     {
         if (readableUserConfiguration == null)
         {
             return(null);
         }
         using (Stream xmlStream = readableUserConfiguration.GetXmlStream())
         {
             DataContractSerializer dataContractSerializer = new DataContractSerializer(property.Type);
             configObject[property] = dataContractSerializer.ReadObject(xmlStream);
         }
     }
     return(configObject);
 }
Example #3
0
        internal static WorkHoursInCalendar GetFromCalendar(MailboxSession session, StoreId folderId)
        {
            WorkHoursInCalendar workHoursInCalendar = null;

            try
            {
                UserConfigurationManager userConfigurationManager = session.UserConfigurationManager;
                using (IReadableUserConfiguration readOnlyFolderConfiguration = userConfigurationManager.GetReadOnlyFolderConfiguration("WorkHours", UserConfigurationTypes.XML, folderId))
                {
                    if (readOnlyFolderConfiguration == null)
                    {
                        ExTraceGlobals.WorkHoursTracer.TraceDebug <string>(-1L, "{0}: Work hours configuration item was not found", session.MailboxOwner.MailboxInfo.DisplayName);
                    }
                    else
                    {
                        using (Stream xmlStream = readOnlyFolderConfiguration.GetXmlStream())
                        {
                            workHoursInCalendar = WorkHoursInCalendar.DeserializeObject(xmlStream);
                            if (workHoursInCalendar == null)
                            {
                                ExTraceGlobals.WorkHoursTracer.TraceDebug <string>(-1L, "{0}: Work hours configuration item was found, but no content was found", session.MailboxOwner.MailboxInfo.DisplayName);
                            }
                        }
                    }
                }
            }
            catch (ObjectNotFoundException arg)
            {
                ExTraceGlobals.WorkHoursTracer.TraceError <string, ObjectNotFoundException>(-1L, "{0}: Could not retrieve working hours. Exception information is {1}", session.MailboxOwner.MailboxInfo.DisplayName, arg);
            }
            catch (InvalidOperationException ex)
            {
                ExTraceGlobals.WorkHoursTracer.TraceError <string, InvalidOperationException>(-1L, "{0}: Malformed working hours XML in mailbox. Exception information is {1}", session.MailboxOwner.MailboxInfo.DisplayName, ex);
                throw new WorkingHoursXmlMalformedException(ServerStrings.MalformedWorkingHours(session.MailboxOwner.MailboxInfo.DisplayName, ex.ToString()), ex);
            }
            catch (XmlException ex2)
            {
                ExTraceGlobals.WorkHoursTracer.TraceError <string, XmlException>(-1L, "{0}: Hit an XmlException deserializing working hours XML in mailbox. Exception information is {1}", session.MailboxOwner.MailboxInfo.DisplayName, ex2);
                throw new WorkingHoursXmlMalformedException(ServerStrings.MalformedWorkingHours(session.MailboxOwner.MailboxInfo.DisplayName, ex2.ToString()), ex2);
            }
            return(workHoursInCalendar);
        }
Example #4
0
        internal static PolicyTagList GetPolicyTagListFromMailboxSession(RetentionActionType type, MailboxSession session)
        {
            StoreId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox);
            IReadableUserConfiguration readableUserConfiguration = null;

            try
            {
                readableUserConfiguration = session.UserConfigurationManager.GetReadOnlyFolderConfiguration("MRM", UserConfigurationTypes.Stream | UserConfigurationTypes.XML | UserConfigurationTypes.Dictionary, defaultFolderId);
                if (readableUserConfiguration != null)
                {
                    using (Stream xmlStream = readableUserConfiguration.GetXmlStream())
                    {
                        string sessionCultureName = null;
                        if (session.Capabilities.CanHaveCulture)
                        {
                            sessionCultureName = session.PreferedCulture.Name;
                        }
                        return(PolicyTagList.GetPolicyTakListFromXmlStream(type, xmlStream, sessionCultureName));
                    }
                }
            }
            catch (ObjectNotFoundException)
            {
            }
            catch (CorruptDataException)
            {
            }
            finally
            {
                if (readableUserConfiguration != null)
                {
                    readableUserConfiguration.Dispose();
                }
            }
            return(null);
        }