Ejemplo n.º 1
0
        // 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: 0x06000AF8 RID: 2808 RVA: 0x000474D0 File Offset: 0x000456D0
        protected override void BuildSmsMessage()
        {
            string text = string.Empty;

            base.BuildSmsMessage();
            int num = base.RemainingChar;

            if (num <= 0)
            {
                return;
            }
            try
            {
                string text2;
                if (ObjectClass.IsOfClass(base.Item.ClassName, "IPM.Note.rpmsg.Microsoft.Voicemail.UM.CA") || ObjectClass.IsOfClass(base.Item.ClassName, "IPM.Note.rpmsg.Microsoft.Voicemail.UM"))
                {
                    text2 = Strings.SMSProtectedVoicemail.ToString(base.GetMailboxCulture());
                }
                else
                {
                    using (Stream stream = base.Item.OpenPropertyStream(MessageItemSchema.AsrData, PropertyOpenMode.ReadOnly))
                    {
                        using (StreamReader streamReader = new StreamReader(stream, Encoding.UTF8))
                        {
                            XmlDocument xmlDocument = new SafeXmlDocument();
                            xmlDocument.Load(streamReader);
                            XmlNode documentElement         = xmlDocument.DocumentElement;
                            float   transcriptionConfidence = SmsVoicemailNotification.GetTranscriptionConfidence(documentElement);
                            text2 = ((transcriptionConfidence > 0.3f) ? this.RenderVoiceMailPreview(documentElement) : Strings.SMSLowConfidenceTranscription.ToString(base.GetMailboxCulture()));
                            ExTraceGlobals.MWITracer.TraceDebug <float, string>((long)this.GetHashCode(), "Confidence: {0}. Text: {1}", transcriptionConfidence, text2);
                        }
                    }
                }
                num--;
                if (text2.Length > num)
                {
                    num -= "...".Length;
                    if (num > 0)
                    {
                        text  = " ";
                        text += text2.Substring(0, num);
                        text += "...";
                    }
                }
                else
                {
                    text  = " ";
                    text += text2;
                }
                base.Body += text;
            }
            catch (ObjectNotFoundException ex)
            {
                ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "ObjectNotFoundException occured while trying to add EVM Text to the SMS. Exception: {0}", ex.Message);
            }
            catch (IOException ex2)
            {
                ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "IOException occured while trying to add EVM Text to the SMS. Exception: {0}", ex2.Message);
            }
            catch (XmlException ex3)
            {
                ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "XmlException occured while trying to add EVM Text to the SMS. Exception: {0}", ex3.Message);
            }
        }