// Token: 0x06000B7A RID: 2938 RVA: 0x0004A418 File Offset: 0x00048618
        private static bool InternalCheckForAutomaticBooking(bool isEventForConfigObject, MailboxSession itemStore, CachedState cachedState)
        {
            cachedState.LockForRead();
            CalendarConfiguration calendarConfiguration;

            try
            {
                calendarConfiguration = (cachedState.State[0] as CalendarConfiguration);
                if (calendarConfiguration == null || isEventForConfigObject)
                {
                    LockCookie lockCookie = cachedState.UpgradeToWriterLock();
                    try
                    {
                        using (CalendarConfigurationDataProvider calendarConfigurationDataProvider = new CalendarConfigurationDataProvider(itemStore))
                        {
                            calendarConfiguration = (CalendarConfiguration)calendarConfigurationDataProvider.Read <CalendarConfiguration>(null);
                            if (calendarConfiguration == null)
                            {
                                Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_CorruptCalendarConfiguration, null, new object[]
                                {
                                    itemStore.MailboxOwner.LegacyDn
                                });
                                calendarConfigurationDataProvider.Delete(new CalendarConfiguration());
                                calendarConfiguration = new CalendarConfiguration();
                            }
                        }
                        if (calendarConfiguration.AutomateProcessing == CalendarProcessingFlags.AutoAccept)
                        {
                            calendarConfiguration.AddNewRequestsTentatively = true;
                        }
                        cachedState.State[0] = calendarConfiguration;
                        ResourceCheck.Tracer.TraceDebug((long)itemStore.GetHashCode(), "{0}: The calendar settings object was new or has been changed - (re)reading contents.", new object[]
                        {
                            TraceContext.Get()
                        });
                    }
                    catch (ObjectNotFoundException innerException)
                    {
                        ResourceCheck.Tracer.TraceError((long)itemStore.GetHashCode(), "{0}: The calendar configuration was deleted while we were looking at it. Back off and retry.", new object[]
                        {
                            TraceContext.Get()
                        });
                        throw new TransientMailboxException(innerException);
                    }
                    finally
                    {
                        cachedState.DowngradeFromWriterLock(ref lockCookie);
                    }
                }
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            ResourceCheck.Tracer.TraceDebug <object, CalendarProcessingFlags>((long)itemStore.GetHashCode(), "{0}: MailboxType {1}", TraceContext.Get(), calendarConfiguration.AutomateProcessing);
            ResourceCheck.TracerPfd.TracePfd <int, object, CalendarProcessingFlags>((long)itemStore.GetHashCode(), "PFD IWR {0} {1}: ResourceMailbox: {2}", 19223, TraceContext.Get(), calendarConfiguration.AutomateProcessing);
            return(calendarConfiguration.AutomateProcessing == CalendarProcessingFlags.AutoAccept);
        }
Esempio n. 2
0
 internal bool CommitChanges(MailboxSession mailboxSession)
 {
     if (mailboxSession == null)
     {
         throw new ArgumentNullException("mailboxSession");
     }
     try
     {
         using (CalendarConfigurationDataProvider calendarConfigurationDataProvider = new CalendarConfigurationDataProvider(mailboxSession))
         {
             CalendarConfiguration calendarConfiguration = (CalendarConfiguration)calendarConfigurationDataProvider.Read <CalendarConfiguration>(null);
             if (calendarConfiguration == null)
             {
                 string message = string.Format("Unable to load Calendar configuration object for mailbox {0}", mailboxSession.MailboxOwner.LegacyDn);
                 ExTraceGlobals.CalendarCallTracer.TraceDebug(0L, message);
                 calendarConfigurationDataProvider.Delete(new CalendarConfiguration());
                 calendarConfiguration = (CalendarConfiguration)calendarConfigurationDataProvider.Read <CalendarConfiguration>(null);
                 if (calendarConfiguration == null)
                 {
                     message = string.Format("Unable to re-create Calendar configuration object for mailbox {0}", mailboxSession.MailboxOwner.LegacyDn);
                     ExTraceGlobals.CalendarCallTracer.TraceDebug(0L, message);
                     return(false);
                 }
             }
             calendarConfiguration.AddNewRequestsTentatively           = this.addNewRequestsTentatively;
             calendarConfiguration.RemoveOldMeetingMessages            = this.removeOldMeetingMessages;
             calendarConfiguration.RemoveForwardedMeetingNotifications = this.removeForwardedMeetingNotifications;
             calendarConfiguration.DefaultReminderTime            = this.defaultReminderTime;
             calendarConfiguration.ProcessExternalMeetingMessages = this.processExternalMeetingMessages;
             calendarConfigurationDataProvider.Save(calendarConfiguration);
         }
     }
     catch (ObjectExistedException ex)
     {
         string message2 = string.Format("Unable to load Calendar configuration object for mailbox. Exception {0}", ex.Message);
         ExTraceGlobals.CalendarCallTracer.TraceDebug(0L, message2);
         return(false);
     }
     catch (StoragePermanentException ex2)
     {
         string message3 = string.Format("Unable to load Calendar configuration object for mailbox. Exception {0}", ex2.Message);
         ExTraceGlobals.CalendarCallTracer.TraceDebug(0L, message3);
         return(false);
     }
     catch (StorageTransientException ex3)
     {
         string message4 = string.Format("Unable to load Calendar configuration object for mailbox. Exception {0}", ex3.Message);
         ExTraceGlobals.CalendarCallTracer.TraceDebug(0L, message4);
         return(false);
     }
     return(true);
 }