Ejemplo n.º 1
0
        public static CalendarUpgrade.CalendarUpgradeStatus MarkMailboxForUpgrade(IMailboxSession session, IXSOFactory xsoFactory)
        {
            ExAssert.RetailAssert(session != null, "session is null");
            ExAssert.RetailAssert(xsoFactory != null, "xsoFactory is null");
            VariantConfigurationSnapshot configuration = session.MailboxOwner.GetConfiguration();

            if (!configuration.DataStorage.CalendarUpgrade.Enabled)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <Guid>(0L, "Mailbox {0}: Not flighted user", session.MailboxGuid);
                return(CalendarUpgrade.CalendarUpgradeStatus.NotFlightedUser);
            }
            if (!CalendarUpgrade.IsInterestingMailboxType(session.MailboxOwner.RecipientTypeDetails))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <Guid>(0L, "Mailbox {0}: Not user mailbox", session.MailboxGuid);
                return(CalendarUpgrade.CalendarUpgradeStatus.NotUserMailbox);
            }
            IXSOMailbox mailbox = session.Mailbox;

            if (!CalendarUpgrade.IsMailboxActive(mailbox))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <Guid>(0L, "Mailbox {0}: Inactive mailbox", session.MailboxGuid);
                return(CalendarUpgrade.CalendarUpgradeStatus.InactiveMailbox);
            }
            if (mailbox.GetValueOrDefault <int?>(MailboxSchema.ItemsPendingUpgrade, null) != null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <Guid>(0L, "Mailbox {0}: Already marked for upgrade", session.MailboxGuid);
                return(CalendarUpgrade.CalendarUpgradeStatus.AlreadyMarkedForUpgrade);
            }
            int?num  = null;
            int?num2 = null;

            CalendarUpgrade.GetCalendarFolderProperties(session, xsoFactory, out num, out num2);
            if (num != null && num == 1)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <Guid>(0L, "Mailbox {0}: Upgrade complete", session.MailboxGuid);
                return(CalendarUpgrade.CalendarUpgradeStatus.UpgradeComplete);
            }
            int minCalendarItemsForUpgrade = VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).DataStorage.CalendarUpgradeSettings.MinCalendarItemsForUpgrade;

            if (num2 == null || num2 < minCalendarItemsForUpgrade)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <Guid>(0L, "Mailbox {0}: Not enough calendar items", session.MailboxGuid);
                return(CalendarUpgrade.CalendarUpgradeStatus.NotEnoughCalendarItems);
            }
            session.Mailbox.SetOrDeleteProperty(MailboxSchema.ItemsPendingUpgrade, num2);
            session.Mailbox.Save();
            ExTraceGlobals.StorageTracer.TraceDebug <Guid>(0L, "Mailbox {0}: Marked for upgrade", session.MailboxGuid);
            return(CalendarUpgrade.CalendarUpgradeStatus.MarkedForUpgrade);
        }
Ejemplo n.º 2
0
        public static bool IsMailboxActive(IXSOMailbox mbx)
        {
            ExDateTime?valueOrDefault = mbx.GetValueOrDefault <ExDateTime?>(MailboxSchema.LastLogonTime, null);

            return(CalendarUpgrade.IsMailboxActive(valueOrDefault));
        }