Ejemplo n.º 1
0
        public static UserConfiguration GetInferenceSettingsConfiguration(MailboxSession session)
        {
            StoreId           defaultFolderId   = session.GetDefaultFolderId(DefaultFolderType.Inbox);
            UserConfiguration userConfiguration = null;
            bool deleteOld = false;

            try
            {
                userConfiguration = session.UserConfigurationManager.GetFolderConfiguration("Inference.Settings", UserConfigurationTypes.Dictionary, defaultFolderId, null);
            }
            catch (ObjectNotFoundException arg)
            {
                InferenceDiagnosticsLog.Log("ClutterUtilities.GetInferenceSettingsConfiguration", string.Format("'{0}' is missing. Exception: {1}", "Inference.Settings", arg));
            }
            catch (CorruptDataException arg2)
            {
                deleteOld = true;
                InferenceDiagnosticsLog.Log("ClutterUtilities.GetInferenceSettingsConfiguration", string.Format("'{0}' is corrupt. Exception: {1}", "Inference.Settings", arg2));
            }
            if (userConfiguration == null || userConfiguration.GetDictionary() == null)
            {
                userConfiguration = ClutterUtilities.ResetInferenceSettingsConfiguration(session, deleteOld);
            }
            return(userConfiguration);
        }
Ejemplo n.º 2
0
 private static VariantConfigurationSnapshot LoadSnapshotIfNeeded(MailboxSession session, VariantConfigurationSnapshot snapshot)
 {
     if (snapshot == null)
     {
         InferenceDiagnosticsLog.Log("ClutterUtilities.LoadSnapshotIfNeeded", "VariantConfigurationSnapshot was not provided, so it is being loaded from the MailboxSession.MailboxOwner");
         return(session.MailboxOwner.GetConfiguration());
     }
     return(snapshot);
 }
Ejemplo n.º 3
0
        public static ExTimeZone GetUserTimeZoneOrDefault(MailboxSession session, ExTimeZone defaultTimeZone)
        {
            ExTimeZone exTimeZone = session.ExTimeZone;

            try
            {
                exTimeZone = TimeZoneHelper.GetUserTimeZone(session);
            }
            catch (TransientException arg)
            {
                InferenceDiagnosticsLog.Log("NotificationManager", string.Format("Ignoring transient exception caught while loading user time zone and defaulting to UTC time zone. Exception: {0}", arg));
            }
            catch (LocalizedException arg2)
            {
                InferenceDiagnosticsLog.Log("NotificationManager", string.Format("Ignoring localized exception caught while loading user time zone and defaulting to UTC time zone. Exception: {0}", arg2));
            }
            exTimeZone = (exTimeZone ?? defaultTimeZone);
            return(exTimeZone);
        }
Ejemplo n.º 4
0
        internal static UserConfiguration ResetInferenceSettingsConfiguration(MailboxSession session, bool deleteOld)
        {
            StoreId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox);

            if (deleteOld)
            {
                try
                {
                    session.UserConfigurationManager.DeleteFolderConfigurations(defaultFolderId, new string[]
                    {
                        "Inference.Settings"
                    });
                }
                catch (ObjectNotFoundException arg)
                {
                    InferenceDiagnosticsLog.Log("ClutterUtilities.ResetInferenceSettingsConfiguration", string.Format("ObjectNotFoundException when deleting '{0}'. Exception: {1}", "Inference.Settings", arg));
                }
                catch (Exception arg2)
                {
                    InferenceDiagnosticsLog.Log("ClutterUtilities.ResetInferenceSettingsConfiguration", string.Format("Error deleting '{0}'. Exception: {1}", "Inference.Settings", arg2));
                    throw;
                }
            }
            UserConfiguration userConfiguration = null;

            try
            {
                userConfiguration = session.UserConfigurationManager.CreateFolderConfiguration("Inference.Settings", UserConfigurationTypes.Dictionary, defaultFolderId);
                userConfiguration.Save();
            }
            catch (Exception arg3)
            {
                InferenceDiagnosticsLog.Log("ClutterUtilities.ResetInferenceSettingsConfiguration", string.Format("Error creating '{0}'. Exception: {1}", "Inference.Settings", arg3));
                if (userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
                throw;
            }
            return(userConfiguration);
        }
Ejemplo n.º 5
0
        public static void AddClutterToFavorite(MailboxSession session)
        {
            try
            {
                using (Folder folder = Folder.Bind(session, DefaultFolderType.Clutter))
                {
                    if (folder != null)
                    {
                        StoreObjectId storeObjectId = folder.StoreObjectId;
                        using (Folder folder2 = Folder.Bind(session, DefaultFolderType.CommonViews))
                        {
                            using (QueryResult queryResult = folder2.ItemQuery(ItemQueryType.Associated, ClutterUtilities.FavoriteItemQueryFilter, ClutterUtilities.FavoriteItemSortBy, ClutterUtilities.FavoriteItemProperties))
                            {
                                StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox);
                                if (defaultFolderId == null)
                                {
                                    throw new InvalidOperationException("Inbox ID cannot be null.");
                                }
                                byte[] array  = null;
                                byte[] array2 = null;
                                byte[] array3 = null;
                                for (;;)
                                {
                                    object[][] rows = queryResult.GetRows(10000);
                                    foreach (object[] array5 in rows)
                                    {
                                        byte[] array6 = array5[ClutterUtilities.FavoriteItemPropertiesMap[NavigationNodeSchema.Ordinal]] as byte[];
                                        array = (array ?? array6);
                                        StoreObjectId id = StoreObjectId.FromProviderSpecificIdOrNull(array5[ClutterUtilities.FavoriteItemPropertiesMap[NavigationNodeSchema.NodeEntryId]] as byte[]);
                                        if (storeObjectId.Equals(id))
                                        {
                                            goto Block_11;
                                        }
                                        if (array2 == null)
                                        {
                                            if (defaultFolderId.Equals(id))
                                            {
                                                array2 = array6;
                                            }
                                        }
                                        else if (array3 == null && !array6.SequenceEqual(array2))
                                        {
                                            array3 = array6;
                                        }
                                    }
                                    if (rows.Length <= 0)
                                    {
                                        goto Block_17;
                                    }
                                }
Block_11:
                                return;

Block_17:
                                byte[] nodeBefore;
                                byte[] nodeAfter;
                                if (array2 != null)
                                {
                                    nodeBefore = array2;
                                    nodeAfter  = array3;
                                }
                                else
                                {
                                    nodeBefore = null;
                                    nodeAfter  = array;
                                }
                                using (FavoriteFolderEntry favoriteFolderEntry = FavoriteFolderEntry.Create(session, storeObjectId, FolderTreeDataType.NormalFolder))
                                {
                                    favoriteFolderEntry.FolderDisplayName = folder.DisplayName;
                                    favoriteFolderEntry.SetNodeOrdinal(nodeBefore, nodeAfter);
                                    favoriteFolderEntry.Save(SaveMode.ResolveConflicts);
                                }
                            }
                        }
                    }
                }
            }
            catch (LocalizedException ex)
            {
                InferenceDiagnosticsLog.Log("AddClutterToFavorite", ex.ToString());
            }
        }