// Token: 0x06000920 RID: 2336 RVA: 0x0003D85C File Offset: 0x0003BA5C
        private static CalendarNotificationType AnalyzeEvent(MapiEvent mapiEvent, MeetingMessage meeting)
        {
            CalendarNotificationType result = CalendarNotificationType.Uninteresting;

            if (meeting is MeetingRequest)
            {
                MeetingRequest     meetingRequest     = (MeetingRequest)meeting;
                MeetingMessageType meetingRequestType = meetingRequest.MeetingRequestType;
                if (meetingRequestType <= MeetingMessageType.FullUpdate)
                {
                    if (meetingRequestType != MeetingMessageType.NewMeetingRequest)
                    {
                        if (meetingRequestType != MeetingMessageType.FullUpdate)
                        {
                            return(result);
                        }
                        goto IL_4A;
                    }
                }
                else
                {
                    if (meetingRequestType == MeetingMessageType.InformationalUpdate || meetingRequestType == MeetingMessageType.SilentUpdate)
                    {
                        goto IL_4A;
                    }
                    if (meetingRequestType != MeetingMessageType.PrincipalWantsCopy)
                    {
                        return(result);
                    }
                }
                return(CalendarNotificationType.NewUpdate);

IL_4A:
                if (CalendarChangeProcessor.InterestingFlagsExists(meetingRequest.ChangeHighlight, MapiExtendedEventFlags.NoReminderPropertyModified))
                {
                    result = CalendarNotificationType.ChangedUpdate;
                }
            }
            else if (meeting is MeetingCancellation)
            {
                result = CalendarNotificationType.DeletedUpdate;
            }
            return(result);
        }
        // Token: 0x0600091E RID: 2334 RVA: 0x0003D7E8 File Offset: 0x0003B9E8
        private static CalendarNotificationType AnalyzeEvent(MailboxData mailboxData, MapiEvent mapiEvent, StoreObject item)
        {
            StoreObjectId defaultCalendarFolderId = mailboxData.DefaultCalendarFolderId;

            if (item == null)
            {
                return(CalendarNotificationType.DeletedUpdate);
            }
            AppointmentStateFlags     valueOrDefault            = item.GetValueOrDefault <AppointmentStateFlags>(CalendarItemBaseSchema.AppointmentState);
            ChangeHighlightProperties changeHighlightProperties = item.GetValueOrDefault <ChangeHighlightProperties>(CalendarItemBaseSchema.ChangeHighlight);
            CalendarItemType          valueOrDefault2           = item.GetValueOrDefault <CalendarItemType>(CalendarItemBaseSchema.CalendarItemType, CalendarItemType.Single);
            ResponseType valueOrDefault3 = item.GetValueOrDefault <ResponseType>(CalendarItemBaseSchema.ResponseType, ResponseType.None);

            if (changeHighlightProperties == ChangeHighlightProperties.None && valueOrDefault2 != CalendarItemType.Single)
            {
                changeHighlightProperties = (ChangeHighlightProperties)(-1);
            }
            return(CalendarChangeProcessor.AnalyzeEvent(mapiEvent, defaultCalendarFolderId, valueOrDefault, changeHighlightProperties, valueOrDefault3));
        }
        // Token: 0x06000925 RID: 2341 RVA: 0x0003DD58 File Offset: 0x0003BF58
        private static void UpdateReminder(CalendarNotificationType type, MailboxData mailboxData, StoreObjectId calItemId, IList <CalendarInfo> calEvents, IList <CalendarInfo> eventsToBeRemoved)
        {
            switch (type)
            {
            case CalendarNotificationType.NewUpdate:
            case CalendarNotificationType.ChangedUpdate:
                if (0 < calEvents.Count || 0 < eventsToBeRemoved.Count)
                {
                    CalendarChangeProcessor.UpdateReminderAccordingToChangedUpdate(mailboxData, calEvents, eventsToBeRemoved);
                    return;
                }
                CalendarChangeProcessor.UpdateReminderAccordingToDeletedUpdate(mailboxData, calItemId);
                return;

            case CalendarNotificationType.DeletedUpdate:
                CalendarChangeProcessor.UpdateReminderAccordingToDeletedUpdate(mailboxData, calItemId);
                return;

            default:
                throw new InvalidOperationException("unsupported CalendarNotificationType");
            }
        }
        // Token: 0x06000926 RID: 2342 RVA: 0x0003DDB4 File Offset: 0x0003BFB4
        internal void HandleEvent(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item)
        {
            MailboxData fromCache = MailboxData.GetFromCache(mapiEvent.MailboxGuid);

            if (fromCache == null)
            {
                return;
            }
            using (fromCache.CreateReadLock())
            {
                ExDateTime eventTime = new ExDateTime(fromCache.Settings.TimeZone.ExTimeZone, mapiEvent.CreateTime);
                try
                {
                    if (ObjectClass.IsMeetingMessage(mapiEvent.ObjectClass))
                    {
                        CalendarChangeProcessor.HandleMeetingEvent(eventTime, fromCache, mapiEvent, itemStore, item);
                    }
                    else if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(mapiEvent.ObjectClass))
                    {
                        CalendarChangeProcessor.HandleCalendarEvent(eventTime, fromCache, mapiEvent, itemStore, item);
                    }
                    else
                    {
                        ExTraceGlobals.AssistantTracer.TraceDebug <IExchangePrincipal, MapiEvent>((long)this.GetHashCode(), "why runs to here?! unhandled event for user {0}, event: {1}", itemStore.MailboxOwner, mapiEvent);
                    }
                }
                catch (ConnectionFailedTransientException arg)
                {
                    ExTraceGlobals.AssistantTracer.TraceDebug <IExchangePrincipal, MapiEvent, ConnectionFailedTransientException>((long)this.GetHashCode(), "Exception is caught for user {0} when processing event: {1}\n{2}", itemStore.MailboxOwner, mapiEvent, arg);
                }
                catch (AdUserNotFoundException arg2)
                {
                    ExTraceGlobals.AssistantTracer.TraceDebug <IExchangePrincipal, MapiEvent, AdUserNotFoundException>((long)this.GetHashCode(), "Exception is caught for user {0} when processing event: {1}\n{2}", itemStore.MailboxOwner, mapiEvent, arg2);
                }
            }
        }
            // Token: 0x06000A2B RID: 2603 RVA: 0x00042F58 File Offset: 0x00041158
            public void Emit(MailboxSession session, CalendarNotificationType type, IList <CalendarInfo> events)
            {
                ExTraceGlobals.AssistantTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Text Emitter is invoked, subject: {0} for user {1}", events[0].NormalizedSubject, this.MailboxData.Settings.LegacyDN);
                if (type == CalendarNotificationType.Uninteresting)
                {
                    return;
                }
                Emitter emitter = null;

                foreach (Emitter emitter2 in this.MailboxData.Settings.Text.TextNotification.CalendarNotificationSettings.Emitters)
                {
                    if (EmitterType.TextMessaging == emitter2.Type)
                    {
                        emitter = emitter2;
                        break;
                    }
                }
                if (emitter == null || emitter.PhoneNumbers.Count == 0)
                {
                    return;
                }
                MailboxRegionalConfiguration regionalConfiguration = this.MailboxData.Settings.Text.RegionalConfiguration;
                CultureInfo cultureInfo = regionalConfiguration.Language ?? CultureInfo.InvariantCulture;
                string      text        = regionalConfiguration.TimeFormat;

                if (string.IsNullOrEmpty(text))
                {
                    text = cultureInfo.DateTimeFormat.ShortTimePattern;
                }
                string text2 = regionalConfiguration.DateFormat;

                if (string.IsNullOrEmpty(text2))
                {
                    text2 = cultureInfo.DateTimeFormat.ShortDatePattern;
                }
                bool flag = false;

                try
                {
                    if (session == null)
                    {
                        ExchangePrincipal mailboxOwner = ExchangePrincipal.FromLocalServerMailboxGuid(this.MailboxData.Settings.GetADSettings(), this.MailboxData.DatabaseGuid, this.MailboxData.MailboxGuid);
                        session = MailboxSession.OpenAsSystemService(mailboxOwner, CultureInfo.InvariantCulture, "Client=TBA;Action=Emit");
                        flag    = true;
                    }
                    ExTraceGlobals.AssistantTracer.TraceDebug <string>((long)this.GetHashCode(), "Text Emitter is emitting for user {0}", this.MailboxData.Settings.LegacyDN);
                    if (CalendarNotificationType.Summary == type)
                    {
                        CalendarNotificationContentVersion1Point0 calendarNotificationContentVersion1Point = new CalendarNotificationContentVersion1Point0();
                        calendarNotificationContentVersion1Point.CalNotifType     = type;
                        calendarNotificationContentVersion1Point.CalNotifTypeDesc = Strings.notifTypeSummary.ToString(cultureInfo);
                        string agendaDateFormat = TextNotificationFactory.TextMessagingEmitter.GetAgendaDateFormat(text2);
                        string timeOfStartTime  = string.Empty;
                        foreach (CalendarInfo calendarInfo in events)
                        {
                            timeOfStartTime = calendarInfo.StartTime.ToString("H:mm", cultureInfo);
                            if (calendarInfo.EndTime.Subtract(calendarInfo.StartTime).Equals(TimeSpan.FromDays(1.0)) && calendarInfo.StartTime.Hour == 0 && calendarInfo.StartTime.Minute == 0)
                            {
                                timeOfStartTime = string.Empty;
                            }
                            calendarNotificationContentVersion1Point.CalEvents.Add(new CalendarEvent(cultureInfo.DateTimeFormat.GetDayName(calendarInfo.StartTime.DayOfWeek), calendarInfo.StartTime.ToString(agendaDateFormat, cultureInfo), timeOfStartTime, cultureInfo.DateTimeFormat.GetDayName(calendarInfo.EndTime.DayOfWeek), calendarInfo.EndTime.ToString(agendaDateFormat, cultureInfo), calendarInfo.EndTime.ToString("H:mm", cultureInfo), calendarInfo.NormalizedSubject ?? string.Empty, calendarInfo.Location ?? string.Empty));
                        }
                        TextNotificationFactory.TextMessagingEmitter.SendTextMessage(session, emitter.PhoneNumbers, calendarNotificationContentVersion1Point.ToString(), CalNotifsCounters.NumberOfAgendasSent);
                    }
                    else
                    {
                        foreach (CalendarInfo calendarInfo2 in events)
                        {
                            CalendarNotificationContentVersion1Point0 calendarNotificationContentVersion1Point2 = new CalendarNotificationContentVersion1Point0();
                            calendarNotificationContentVersion1Point2.CalNotifType = type;
                            bool flag2 = false;
                            ExPerformanceCounter perfcounter;
                            switch (type)
                            {
                            case CalendarNotificationType.Reminder:
                                calendarNotificationContentVersion1Point2.CalNotifTypeDesc = Strings.notifTypeReminder.ToString(cultureInfo);
                                perfcounter = CalNotifsCounters.NumberOfTextRemindersSent;
                                break;

                            case CalendarNotificationType.NewUpdate:
                                calendarNotificationContentVersion1Point2.CalNotifTypeDesc = Strings.notifTypeNewUpdate.ToString(cultureInfo);
                                perfcounter = CalNotifsCounters.NumberOfUpdatesSent;
                                flag2       = true;
                                break;

                            case CalendarNotificationType.ChangedUpdate:
                                calendarNotificationContentVersion1Point2.CalNotifTypeDesc = Strings.notifTypeChangedUpdate.ToString(cultureInfo);
                                perfcounter = CalNotifsCounters.NumberOfUpdatesSent;
                                flag2       = true;
                                break;

                            case CalendarNotificationType.DeletedUpdate:
                                calendarNotificationContentVersion1Point2.CalNotifTypeDesc = Strings.notifTypeDeletedUpdate.ToString(cultureInfo);
                                perfcounter = CalNotifsCounters.NumberOfUpdatesSent;
                                flag2       = true;
                                break;

                            default:
                                throw new InvalidOperationException("unsupported CalendarNotificationType");
                            }
                            if (flag2)
                            {
                                CalendarChangeProcessor.UpdateAverageProcessingLatency(calendarInfo2.CreationRequestTime);
                            }
                            calendarNotificationContentVersion1Point2.CalEvents.Add(new CalendarEvent(cultureInfo.DateTimeFormat.GetDayName(calendarInfo2.StartTime.DayOfWeek), calendarInfo2.StartTime.ToString(text2, cultureInfo), calendarInfo2.StartTime.ToString(text, cultureInfo), cultureInfo.DateTimeFormat.GetDayName(calendarInfo2.EndTime.DayOfWeek), calendarInfo2.EndTime.ToString(text2, cultureInfo), calendarInfo2.EndTime.ToString(text, cultureInfo), calendarInfo2.NormalizedSubject ?? string.Empty, calendarInfo2.Location ?? string.Empty));
                            TextNotificationFactory.TextMessagingEmitter.SendTextMessage(session, emitter.PhoneNumbers, calendarNotificationContentVersion1Point2.ToString(), perfcounter);
                        }
                    }
                    ExTraceGlobals.AssistantTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Text Emitter is emitted, subject: {0}, user: {1}", events[0].NormalizedSubject, this.MailboxData.Settings.LegacyDN);
                }
                finally
                {
                    if (flag)
                    {
                        session.Dispose();
                        session = null;
                    }
                }
            }
        // Token: 0x0600091D RID: 2333 RVA: 0x0003D75C File Offset: 0x0003B95C
        private static CalendarNotificationType AnalyzeEvent(MapiEvent mapiEvent, StoreObjectId defaultCalFldrId, AppointmentStateFlags flags, ChangeHighlightProperties changeHilite, ResponseType responseType)
        {
            CalendarNotificationType result = CalendarNotificationType.Uninteresting;

            if ((AppointmentStateFlags.Cancelled & flags) != AppointmentStateFlags.None || (MapiEventTypeFlags.ObjectDeleted & mapiEvent.EventMask) != (MapiEventTypeFlags)0)
            {
                result = CalendarNotificationType.DeletedUpdate;
            }
            else if (((MapiEventTypeFlags.ObjectCreated | MapiEventTypeFlags.ObjectCopied) & mapiEvent.EventMask) != (MapiEventTypeFlags)0)
            {
                result = CalendarNotificationType.NewUpdate;
            }
            else if ((MapiEventTypeFlags.ObjectModified & mapiEvent.EventMask) != (MapiEventTypeFlags)0 && (CalendarChangeProcessor.InterestingFlagsExists(changeHilite, mapiEvent.ExtendedEventFlags) || ResponseType.Organizer == responseType))
            {
                result = CalendarNotificationType.ChangedUpdate;
            }
            else if ((MapiEventTypeFlags.ObjectMoved & mapiEvent.EventMask) != (MapiEventTypeFlags)0)
            {
                if (object.Equals(defaultCalFldrId, StoreObjectId.FromProviderSpecificId(mapiEvent.ParentEntryId)))
                {
                    result = CalendarNotificationType.NewUpdate;
                }
                else if (object.Equals(defaultCalFldrId, StoreObjectId.FromProviderSpecificId(mapiEvent.OldParentEntryId)))
                {
                    result = CalendarNotificationType.DeletedUpdate;
                }
            }
            return(result);
        }
        // Token: 0x06000927 RID: 2343 RVA: 0x0003DEC0 File Offset: 0x0003C0C0
        private static void HandleMeetingEvent(ExDateTime eventTime, MailboxData mailboxData, MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item)
        {
            if (item == null || !NotificationFactories.Instance.IsInterestedInCalendarMeetingEvent(mailboxData.Settings))
            {
                ExTraceGlobals.AssistantTracer.TraceDebug <MailboxData, MapiEvent>((long)typeof(CalendarChangeProcessor).GetHashCode(), "Ignore event because update is disabled for user {0}, event: {1}", mailboxData, mapiEvent);
                return;
            }
            if (object.Equals(item.Id.ObjectId, mailboxData.DefaultDeletedItemsFolderId) || object.Equals(item.Id.ObjectId, mailboxData.DefaultJunkEmailFolderId))
            {
                ExTraceGlobals.AssistantTracer.TraceDebug <MailboxData, MapiEvent>((long)typeof(CalendarChangeProcessor).GetHashCode(), "Ignore event because item has been deleted for user {0}, event: {1}", mailboxData, mapiEvent);
                return;
            }
            MeetingMessage meetingMessage = item as MeetingMessage;

            if (meetingMessage == null)
            {
                ExTraceGlobals.AssistantTracer.TraceDebug <MailboxData, MapiEvent>((long)typeof(CalendarChangeProcessor).GetHashCode(), "Meeting event handler could do nothing because the item is not meeting message for user {0}, event: {1}", mailboxData, mapiEvent);
                return;
            }
            if (meetingMessage.IsDelegated() || meetingMessage.IsMailboxOwnerTheSender() || meetingMessage.IsOutOfDate())
            {
                ExTraceGlobals.AssistantTracer.TraceDebug <MailboxData, MapiEvent>((long)typeof(CalendarChangeProcessor).GetHashCode(), "Ignore event because mtg is delegated or out of data or is ornizer for user {0}, event: {1}", mailboxData, mapiEvent);
                return;
            }
            CalendarNotificationType calendarNotificationType = CalendarChangeProcessor.AnalyzeEvent(mapiEvent, meetingMessage);

            if (calendarNotificationType == CalendarNotificationType.Uninteresting)
            {
                ExTraceGlobals.AssistantTracer.TraceDebug <MailboxData, MapiEvent>((long)typeof(CalendarChangeProcessor).GetHashCode(), "Ignore mtg event due to uninteresting for user {0}, event: {1}", mailboxData, mapiEvent);
                return;
            }
            List <CalendarInfo>   list             = null;
            Interval <ExDateTime> interval         = new Interval <ExDateTime>(eventTime, false, eventTime + TimeSpan.FromDays((double)mailboxData.Settings.Text.TextNotification.NextDays), true);
            CalendarItemBase      calendarItemBase = null;

            try
            {
                calendarItemBase = meetingMessage.GetCorrelatedItem();
                if (!meetingMessage.TryUpdateCalendarItem(ref calendarItemBase, false))
                {
                    ExTraceGlobals.AssistantTracer.TraceDebug <MailboxData, MapiEvent>((long)typeof(CalendarChangeProcessor).GetHashCode(), "Ignore mtg event because TryUpdateCalendarItem failed for user {0}, event: {1}", mailboxData, mapiEvent);
                    return;
                }
                list = OccurrenceLoader.Load(eventTime, mailboxData.Settings.TimeZone.ExTimeZone, itemStore, meetingMessage as MeetingRequest, calendarItemBase, mailboxData.Settings.Text.TextNotification.CalendarNotificationSettings.UpdateSettings.Duration.NonWorkHoursExcluded ? mailboxData.Settings.Text.WorkingHours : null, interval.Minimum, interval.Maximum);
            }
            finally
            {
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                    calendarItemBase = null;
                }
            }
            int num = 0;

            foreach (CalendarInfo calendarInfo in list)
            {
                if (calendarInfo.IsInteresting(calendarNotificationType))
                {
                    CalendarNotificationInitiator.ScheduleAction(new UpdateEmitting(mailboxData, calendarInfo, calendarNotificationType), "HandleMeetingEvent");
                    num++;
                }
            }
            ExTraceGlobals.AssistantTracer.TraceDebug((long)typeof(CalendarChangeProcessor).GetHashCode(), "{0} updates has been sent according to mtg msg {1} for user {2}, type: {3}, event: {4}", new object[]
            {
                num,
                meetingMessage.Id.ObjectId,
                mailboxData,
                calendarNotificationType,
                mapiEvent
            });
        }
        // Token: 0x06000924 RID: 2340 RVA: 0x0003DBB0 File Offset: 0x0003BDB0
        private static void UpdateReminderAccordingToChangedUpdate(MailboxData mailboxData, IList <CalendarInfo> calEvents, IList <CalendarInfo> eventsToBeRemoved)
        {
            List <CalendarInfo> eventsToBeAdded        = new List <CalendarInfo>(calEvents);
            ExDateTime          nextReminderReloadTime = ExDateTime.MinValue;

            mailboxData.Actions.ForEach(delegate(CalendarNotificationAction action)
            {
                if (typeof(ReminderReloading) == action.GetType())
                {
                    nextReminderReloadTime = action.ExpectedTime;
                    return;
                }
                if (typeof(ReminderEmitting) != action.GetType())
                {
                    return;
                }
                CalendarInfo calendarInfo2 = ((ReminderEmitting)action).CalendarInfo;
                IList <CalendarInfo> list  = null;
                CalendarInfo calendarInfo3 = null;
                if (CalendarChangeProcessor.TryGetMatched(eventsToBeRemoved, calendarInfo2.CalendarItemIdentity, calendarInfo2.CalendarItemOccurrenceIdentity, true, out list, out calendarInfo3) && calendarInfo3 != null)
                {
                    CalendarNotificationInitiator.CompleteAction(action, "UpdateReminderAccordingToChangedUpdate");
                }
                list          = null;
                calendarInfo3 = null;
                if (CalendarChangeProcessor.TryGetMatched(eventsToBeAdded, calendarInfo2.CalendarItemIdentity, calendarInfo2.CalendarItemOccurrenceIdentity, true, out list, out calendarInfo3))
                {
                    eventsToBeAdded.Remove(calendarInfo3);
                    ReminderEmitting action3;
                    if (!calendarInfo3.ReminderIsSet || !calendarInfo3.IsInteresting(CalendarNotificationType.ChangedUpdate) || calendarInfo3.ReminderTime < calendarInfo3.CreationRequestTime || !NotificationFactories.Instance.TryCreateReminderEmitting(calendarInfo3, action.Context, out action3))
                    {
                        CalendarNotificationInitiator.CompleteAction(action, "UpdateReminderAccordingToChangedUpdate");
                        return;
                    }
                    CalendarNotificationInitiator.UpdateAction(action, action3, "UpdateReminderAccordingToChangedUpdate");
                }
            });
            foreach (CalendarInfo calendarInfo in eventsToBeAdded)
            {
                if (calendarInfo.ReminderIsSet)
                {
                    if (calendarInfo.ReminderTime < calendarInfo.CreationRequestTime)
                    {
                        ExTraceGlobals.AssistantTracer.TraceDebug((long)typeof(CalendarChangeProcessor).GetHashCode(), "Reminder is out of date, subj: {0}, usr: {1}, event_t: {2}, rmd_t: {3}, s_t: {4}, e_t: {5}", new object[]
                        {
                            calendarInfo.NormalizedSubject,
                            mailboxData.Settings.LegacyDN,
                            calendarInfo.CreationRequestTime,
                            calendarInfo.ReminderTime,
                            calendarInfo.StartTime,
                            calendarInfo.EndTime
                        });
                    }
                    else if (nextReminderReloadTime == ExDateTime.MinValue || calendarInfo.ReminderTime <= nextReminderReloadTime)
                    {
                        ReminderEmitting action2;
                        if (NotificationFactories.Instance.TryCreateReminderEmitting(calendarInfo, mailboxData, out action2))
                        {
                            CalendarNotificationInitiator.ScheduleAction(action2, "UpdateReminderAccordingToChangedUpdate");
                        }
                    }
                    else
                    {
                        ExTraceGlobals.AssistantTracer.TraceDebug <ExDateTime, ExDateTime>((long)typeof(CalendarChangeProcessor).GetHashCode(), "We didn't process this event because reminderTime {0} is greater nextReminderReloadTime {1}. ", calendarInfo.ReminderTime, nextReminderReloadTime);
                    }
                }
            }
        }