// Token: 0x06000ADA RID: 2778 RVA: 0x00046E2C File Offset: 0x0004502C internal void EnqueueMailbox(MailboxInfo mailbox, MailboxSession mailboxSession) { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo, MailboxSession>((long)this.GetHashCode(), "MwiDelayTable.EnqueueMailbox({0}, {1})", mailbox, mailboxSession); bool flag = false; MwiDelayTable.DelayTableEntry delayTableEntry; lock (this) { if (!this.delayTable.TryGetValue(mailbox.Guid, out delayTableEntry)) { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo>((long)this.GetHashCode(), "MwiDelayTable: Mailbox {0} not present, processing now", mailbox); flag = true; delayTableEntry = new MwiDelayTable.DelayTableEntry(mailbox); this.delayTable[mailbox.Guid] = delayTableEntry; } else { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo>((long)this.GetHashCode(), "MwiDelayTable: Mailbox {0} already present->ProcessWhenExpired=true.", mailbox); delayTableEntry.ProcessWhenExpired = true; } } if (flag) { this.ProcessEntryAndAddToDelayQueue(delayTableEntry, mailboxSession); } }
// Token: 0x06000ABB RID: 2747 RVA: 0x00046114 File Offset: 0x00044314 private void ProcessMailboxForSMS(MailboxInfo mailbox, MailboxSession session, StoreObject item, ADUser user, UMDialPlan dialPlan) { if (mailbox.MapiEvent == null || session == null || item == null) { ExTraceGlobals.MWITracer.TraceDebug((long)this.GetHashCode(), "MwiAssistant.ProcessMailboxForSMS: Skipping for {0} (event={1}, session={2}, item={3})", new object[] { mailbox, mailbox.MapiEvent, session, item }); return; } UMMailbox ummailbox = new UMMailbox(user); if (ummailbox.UMSMSNotificationOption == UMSMSNotificationOptions.None) { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.ProcessMailboxForSMS: Skipping {0}. UMSMSNotificationOptions=None", mailbox); return; } if (MwiAssistant.IsMissedCallMessageEvent(mailbox.MapiEvent) && ummailbox.UMSMSNotificationOption != UMSMSNotificationOptions.VoiceMailAndMissedCalls) { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo, string>((long)this.GetHashCode(), "MwiAssistant.ProcessMailboxForSMS: Skipping {0}. UMSMSNotificationOptions={1}", mailbox, ummailbox.UMSMSNotificationOption.ToString()); return; } this.SendSMSMessage(mailbox, session, item, user, dialPlan); }
// Token: 0x06000ABC RID: 2748 RVA: 0x000461D8 File Offset: 0x000443D8 private List <MailboxInfo> GetAllLocalUserMailboxes() { ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "GetAllLocalUserMailboxes(): Getting user mailboxes for database {0}", base.DatabaseInfo.DisplayName); LocalizedException ex = null; List <MailboxInfo> list = new List <MailboxInfo>(); try { Hashtable umenabledUsersFromAD = this.GetUMEnabledUsersFromAD(); ExTraceGlobals.MWITracer.TraceDebug <int>((long)this.GetHashCode(), "GetAllLocalUserMailboxes:GetUMEnabledUsersFromAD returned {0} records.", umenabledUsersFromAD.Count); if (umenabledUsersFromAD.Count != 0) { using (ExRpcAdmin exRpcAdmin = ExRpcAdmin.Create("Client=EBA", null, null, null, null)) { PropValue[][] mailboxTable = exRpcAdmin.GetMailboxTable(base.DatabaseInfo.Guid, new PropTag[] { PropTag.UserGuid, PropTag.DisplayName, PropTag.DateDiscoveredAbsentInDS }); ExTraceGlobals.MWITracer.TraceError <string, int>((long)this.GetHashCode(), "GetAllLocalUserMailboxes: Database({0}).GetMailboxTable returned {1} records", base.DatabaseInfo.DisplayName, mailboxTable.Length); foreach (PropValue[] array2 in mailboxTable) { if (array2.Length == 3 && array2[0].PropTag == PropTag.UserGuid && array2[1].PropTag == PropTag.DisplayName && array2[2].PropTag != PropTag.DateDiscoveredAbsentInDS) { Guid guid = new Guid(array2[0].GetBytes()); if (base.DatabaseInfo.IsUserMailbox(guid) && umenabledUsersFromAD.Contains(guid)) { MailboxInfo mailboxInfo = new MailboxInfo(guid, array2[1].GetString(), (OrganizationId)umenabledUsersFromAD[guid]); ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo>((long)this.GetHashCode(), "GetAllLocalUserMailboxes(): Adding {0} to the mailbox list", mailboxInfo); list.Add(mailboxInfo); } } } goto IL_1CF; } } ExTraceGlobals.MWITracer.TraceError((long)this.GetHashCode(), "GetAllLocalUserMailboxes:GetUMEnabledUsersFromAD returned 0 records."); IL_1CF :; } catch (MapiPermanentException ex2) { ex = ex2; } catch (MapiRetryableException ex3) { ex = ex3; } if (ex != null) { ExTraceGlobals.MWITracer.TraceError <string, LocalizedException>((long)this.GetHashCode(), "TryGetMailboxEnumerator: Could not get the list of mailboxes for DB {0}: {1}", base.DatabaseInfo.DisplayName, ex); UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_MwiQueryDatabaseFailed, null, new object[] { base.DatabaseInfo.DisplayName, this.syncInterval.TotalMinutes, CommonUtil.ToEventLogString(ex) }); } return(list); }
// Token: 0x06000AB9 RID: 2745 RVA: 0x00045FBC File Offset: 0x000441BC private void ProcessMailbox(MailboxInfo mailbox, MailboxSession session, StoreObject item) { ADUser aduser; UMDialPlan umdialPlan; bool flag; bool flag2; if (this.TryReadUserConfiguration(mailbox, out aduser, out umdialPlan, out flag, out flag2)) { mailbox.DialPlanGuid = aduser.UMRecipientDialPlanId.ObjectGuid; mailbox.UMExtension = aduser.UMExtension; mailbox.DisplayName = aduser.DisplayName; ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo, UMSubscriberType, MapiEvent>((long)this.GetHashCode(), "MwiAssistant.ProcessMailbox: User:{0}. SubsType:{1} MapiEvent:{2}", mailbox, umdialPlan.SubscriberType, mailbox.MapiEvent); if (flag2) { this.ProcessMailboxForMWI(mailbox, session, item, umdialPlan); } else { ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "MwiAssistant.ProcessMailbox: Skip ProcessMailboxForMWI because UMMailboxPolicy.AllowMessageWaitingIndicator is false for User {0}}", aduser.DistinguishedName); } if (flag) { this.ProcessMailboxForSMS(mailbox, session, item, aduser, umdialPlan); return; } ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "MwiAssistant.ProcessMailbox: Skip ProcessMailboxForSMS because UMMailboxPolicy.AllowSMSNotification is false for User {0}}", aduser.DistinguishedName); } }
// Token: 0x06000AB8 RID: 2744 RVA: 0x00045EFC File Offset: 0x000440FC private void DelayTableCallback(MailboxInfo mailbox, MailboxSession session) { bool flag = false; try { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.DelayTableCallback running for {0}", mailbox); if (session == null) { ExchangePrincipal principal = ExchangePrincipal.FromLocalServerMailboxGuid(mailbox.OrganizationId.ToADSessionSettings(), base.DatabaseInfo.Guid, mailbox.Guid); session = base.DatabaseInfo.GetMailbox(principal, ClientType.TimeBased, "MwiAssistant Sync Thread"); flag = true; } ExTraceGlobals.MWITracer.TraceDebug <MailboxSession, MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.DelayTableCallback: Created session {0} for {1}", session, mailbox); this.SendMwiMessage(mailbox, session); } catch (Exception error) { if (!this.TryHandleException(mailbox, error)) { throw; } } finally { if (flag && session != null) { session.Dispose(); session = null; } } }
// Token: 0x06000AB1 RID: 2737 RVA: 0x00045CD8 File Offset: 0x00043ED8 private static bool TryGetNotificationPhoneNumber(MailboxInfo mailbox, MailboxSession session, ADUser user, out string phoneNumber, out CultureInfo notificationPreferredCulture) { phoneNumber = null; notificationPreferredCulture = null; TextMessagingAccount textMessagingAccount = null; if (MwiAssistant.TryReadTextMessagingAccount(session, out textMessagingAccount)) { bool flag = TextMessagingHelper.IsMachineToPersonTextingOnlyAccount(textMessagingAccount); ExTraceGlobals.MWITracer.TraceDebug(0L, "MwiAssistant: TryGetNotificationPhoneNumber User = {0}, EASEnabled = {1}, Phone Number Verified = {2}, Phone Number = {3}, Can send sms = {4}", new object[] { user.DistinguishedName, textMessagingAccount.EasEnabled, textMessagingAccount.NotificationPhoneNumberVerified, (textMessagingAccount.NotificationPhoneNumber != null && textMessagingAccount.NotificationPhoneNumber.Number != null) ? textMessagingAccount.NotificationPhoneNumber.Number : "<null>", flag }); if (flag) { phoneNumber = textMessagingAccount.NotificationPhoneNumber.Number; notificationPreferredCulture = textMessagingAccount.NotificationPreferredCulture; } } else { ExTraceGlobals.MWITracer.TraceWarning <string>(0L, "MwiAssistant: TryGetNotificationPhoneNumber Cannot send SMS because TextMessagingAccount does not exist for User {0}", user.DistinguishedName); } return(phoneNumber != null); }
// Token: 0x06000ABF RID: 2751 RVA: 0x00046714 File Offset: 0x00044914 private bool TryReadUserConfiguration(MailboxInfo mailbox, out ADUser user, out UMDialPlan dialPlan, out bool sendSms, out bool sendMsgWaitingIndicator) { user = null; dialPlan = null; sendSms = false; sendMsgWaitingIndicator = false; IADRecipientLookup iadrecipientLookup = ADRecipientLookupFactory.CreateFromOrganizationId(mailbox.OrganizationId, null); user = (iadrecipientLookup.LookupByExchangeGuid(mailbox.Guid) as ADUser); if (user == null) { ExTraceGlobals.MWITracer.TraceError <Guid>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: Could not find ADUser for mailbox {0}", mailbox.Guid); return(false); } if (!user.UMEnabled || user.UMMailboxPolicy == null || user.UMRecipientDialPlanId == null) { ExTraceGlobals.MWITracer.TraceError((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: ({0}): Invalid user({1}) UMEnabled({2}) UMMbxPol({3}) DialPlan({4})", new object[] { mailbox.Guid, user.DistinguishedName, user.UMEnabled, user.UMMailboxPolicy, user.UMRecipientDialPlanId }); return(false); } IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(user.UMMailboxPolicy), 1108, "TryReadUserConfiguration", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\mwi\\MwiAssistant.cs"); UMMailboxPolicy ummailboxPolicy = tenantOrTopologyConfigurationSession.Read <UMMailboxPolicy>(user.UMMailboxPolicy); if (ummailboxPolicy == null) { ExTraceGlobals.MWITracer.TraceError <ADObjectId, string>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: Could not find UMMailboxPolicy: {0}, User {1}", user.UMMailboxPolicy, user.DistinguishedName); return(false); } sendSms = ummailboxPolicy.AllowSMSNotification; sendMsgWaitingIndicator = ummailboxPolicy.AllowMessageWaitingIndicator; ExTraceGlobals.MWITracer.TraceDebug <bool, bool, string>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: AllowSMSNotification={0}, AllowMessageWaitingIndicator={1}, User {2}", sendSms, sendMsgWaitingIndicator, user.DistinguishedName); bool flag = sendSms || sendMsgWaitingIndicator; if (flag) { dialPlan = tenantOrTopologyConfigurationSession.Read <UMDialPlan>(user.UMRecipientDialPlanId); if (dialPlan == null) { ExTraceGlobals.MWITracer.TraceError <ADObjectId>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: Could not find UMDialPlan: {0}", user.UMRecipientDialPlanId); return(false); } ExTraceGlobals.MWITracer.TraceDebug <string, ADObjectId, UMSubscriberType>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration User {0} DialPlan{1}.SubscriberType={2}.", user.DistinguishedName, dialPlan.Id, dialPlan.SubscriberType); } return(flag); }
// Token: 0x06000AAC RID: 2732 RVA: 0x00045A2C File Offset: 0x00043C2C protected override void HandleEventInternal(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, List <KeyValuePair <string, object> > customDataToLog) { MailboxInfo mailbox = null; try { mailbox = new MailboxInfo(mapiEvent, itemStore.MailboxOwner.MailboxInfo.OrganizationId); this.ProcessMailbox(mailbox, itemStore, item); } catch (Exception error) { if (!this.TryHandleException(mailbox, error)) { throw; } } }
// Token: 0x06000ABA RID: 2746 RVA: 0x00046080 File Offset: 0x00044280 private void ProcessMailboxForMWI(MailboxInfo mailbox, MailboxSession session, StoreObject item, UMDialPlan dialPlan) { bool flag = mailbox.MapiEvent == null; if (dialPlan.SubscriberType == UMSubscriberType.Consumer) { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.ProcessMailboxForMWI: Skipping for {0} (MWI N/A for consumer dialplan)", mailbox); return; } if (!flag && !MwiAssistant.IsVoicemailSearchFolderEvent(mailbox.MapiEvent)) { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.ProcessMailboxForMWI: Skipping for {0} (MWI only av. for healing/search folder events)", mailbox); return; } mailbox.EventTimeUtc = (flag ? ExDateTime.UtcNow : new ExDateTime(ExTimeZone.UtcTimeZone, mailbox.MapiEvent.CreateTime)); this.delayTable.EnqueueMailbox(mailbox, session); }
// Token: 0x06000ABE RID: 2750 RVA: 0x00046574 File Offset: 0x00044774 private void SendSMSMessage(MailboxInfo mailbox, MailboxSession session, StoreObject item, ADUser user, UMDialPlan dialPlan) { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo, MailboxSession, StoreObject>((long)this.GetHashCode(), "MwiAssistant.SendSMSMessage: Mailbox:{0} Session={1} Item={2}", mailbox, session, item); string text; CultureInfo preferredCulture; if (MwiAssistant.TryGetNotificationPhoneNumber(mailbox, session, user, out text, out preferredCulture)) { StoreObjectId storeObjectId = session.GetDefaultFolderId(DefaultFolderType.Drafts) ?? session.GetDefaultFolderId(DefaultFolderType.Outbox); using (Folder.Bind(session, storeObjectId)) { using (MessageItem messageItem = MessageItem.Create(session, storeObjectId)) { messageItem.ClassName = "IPM.Note.Mobile.SMS.Alert.Voicemail"; if (MwiAssistant.IsVoiceMessageEvent(mailbox.MapiEvent)) { SmsVoicemailNotification smsVoicemailNotification = new SmsVoicemailNotification(session, preferredCulture, item, dialPlan); smsVoicemailNotification.PrepareSmsMessage(messageItem); } else { if (!MwiAssistant.IsMissedCallMessageEvent(mailbox.MapiEvent)) { throw new ArgumentException("MapiEvent.ObjectClass"); } SmsMissedCallNotification smsMissedCallNotification = new SmsMissedCallNotification(session, preferredCulture, item, dialPlan); smsMissedCallNotification.PrepareSmsMessage(messageItem); } Participant participant = new Participant(null, text, "MOBILE"); messageItem.Recipients.Add(participant, RecipientItemType.To); string subject = messageItem.Subject; string text2 = string.Format("{0}:{1}", participant.RoutingType, participant.EmailAddress); ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo, string, string>((long)this.GetHashCode(), "MwiAssistant.SendSMSMessage: Mailbox:{0} Recipient:{1} Subject={2}. Sending...", mailbox, text2, subject); messageItem.Send(); UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_MwiTextMessageSent, null, new object[] { subject, mailbox, text, text2 }); } } } }
// Token: 0x06000AB7 RID: 2743 RVA: 0x00045E2C File Offset: 0x0004402C private void SyncTimerCallback(object state) { bool flag = false; MailboxInfo mailbox = null; try { flag = this.syncThreadRunning.WaitOne(0, false); if (!flag) { ExTraceGlobals.MWITracer.TraceWarning((long)this.GetHashCode(), "MwiAssistant.SyncTimerCallback(); Overlaping timer calls."); } else if (this.mailboxesToProcess != null && this.mailboxesToProcess.Count > 0) { mailbox = this.mailboxesToProcess[0]; this.mailboxesToProcess.RemoveAt(0); this.ProcessMailbox(mailbox, null, null); } else { ExTraceGlobals.MWITracer.TraceDebug((long)this.GetHashCode(), "SyncTimerCallback; We need to get a new mailbox list"); this.SetupSyncTimer(); } } catch (Exception error) { if (!this.TryHandleException(mailbox, error)) { throw; } } finally { if (flag) { this.syncThreadRunning.Set(); } } }
// Token: 0x06000AC4 RID: 2756 RVA: 0x00046BAC File Offset: 0x00044DAC private bool TryHandleException(MailboxInfo mailbox, Exception error) { ExTraceGlobals.MWITracer.TraceError <MailboxInfo, string, Exception>((long)this.GetHashCode(), "MwiAssistant.TryHandleException: Mailbox {0} in database {1}: {2}", mailbox, base.DatabaseInfo.DisplayName, error); if (error is StorageTransientException || error is StoragePermanentException || error is LocalServerException || error is DataValidationException || error is DataSourceTransientException || error is DataSourceOperationException) { if (MwiAssistant.ShouldLogException(error)) { UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_MwiSyncMailboxFailed, null, new object[] { mailbox, base.DatabaseInfo.DisplayName, CommonUtil.ToEventLogString(error) }); } return(true); } if (GrayException.IsGrayException(error)) { ExWatson.SendReport(error, ReportOptions.None, null); return(true); } return(false); }
// Token: 0x06000ABD RID: 2749 RVA: 0x00046480 File Offset: 0x00044680 private void SendMwiMessage(MailboxInfo mailbox, MailboxSession itemStore) { StoreObjectId umsearchFolderId = MwiAssistant.GetUMSearchFolderId(itemStore); if (umsearchFolderId == null) { ExTraceGlobals.MWITracer.TraceWarning <MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.SendMwiMessage(): Skipping event. Could not get Voice Mail search folder for {0}.", mailbox); return; } using (SearchFolder searchFolder = SearchFolder.Bind(itemStore, umsearchFolderId, new PropertyDefinition[] { FolderSchema.ItemCount, FolderSchema.UnreadCount })) { int itemCount = searchFolder.ItemCount; int num = (int)searchFolder[FolderSchema.UnreadCount]; ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo, int, int>((long)this.GetHashCode(), "MwiAssistant.SendMwiMessage(): Sending MWI for user {0}, itemCount={1}, unreadCount={2}", mailbox, itemCount, num); IADSystemConfigurationLookup iadsystemConfigurationLookup = ADSystemConfigurationLookupFactory.CreateFromOrganizationId(mailbox.OrganizationId); Guid externalDirectoryOrganizationId = iadsystemConfigurationLookup.GetExternalDirectoryOrganizationId(); MwiMessage message = new MwiMessage(mailbox.Guid, mailbox.DialPlanGuid, mailbox.DisplayName, mailbox.UMExtension, num, itemCount, MwiAssistant.MessageExpirationTime, mailbox.EventTimeUtc, externalDirectoryOrganizationId); this.loadBalancer.SendMessage(message); } }
// Token: 0x06000ADD RID: 2781 RVA: 0x00047138 File Offset: 0x00045338 internal DelayTableEntry(MailboxInfo mailbox) { this.mailbox = mailbox; this.processWhenExpired = false; }