Exemplo n.º 1
0
 public void NewItemToPeople()
 {
     ExTraceGlobals.ContactsCallTracer.TraceDebug((long)this.GetHashCode(), "AddressBookEventHandler.NewItemToPeople");
     this.BindToData();
     if (base.UserContext.UserOptions.ViewRowCount < this.itemIds.Length)
     {
         throw new OwaInvalidOperationException(string.Format("Sending message to more than {0} item(s) in a single request is not supported", this.itemIds.Length));
     }
     AddressBookItemEventHandler.ItemTypeToPeople itemTypeToPeople = (AddressBookItemEventHandler.ItemTypeToPeople)base.GetParameter("it");
     if (!Enum.IsDefined(typeof(AddressBookItemEventHandler.ItemTypeToPeople), itemTypeToPeople))
     {
         throw new OwaInvalidOperationException(string.Format("Invalid item type '{0}' passed in.", itemTypeToPeople));
     }
     using (Item item = (itemTypeToPeople == AddressBookItemEventHandler.ItemTypeToPeople.Meeting) ? CalendarItem.Create(base.UserContext.MailboxSession, base.UserContext.CalendarFolderId) : MessageItem.Create(base.UserContext.MailboxSession, base.UserContext.DraftsFolderId))
     {
         item[ItemSchema.ConversationIndexTracking] = true;
         if (Globals.ArePerfCountersEnabled)
         {
             OwaSingleCounters.ItemsCreated.Increment();
         }
         this.LoadRecipientsToItem(item, itemTypeToPeople);
         if (itemTypeToPeople == AddressBookItemEventHandler.ItemTypeToPeople.Meeting)
         {
             CalendarItemBase calendarItemBase = (CalendarItemBase)item;
             calendarItemBase[ItemSchema.ReminderIsSet] = base.UserContext.UserOptions.EnableReminders;
             calendarItemBase[ItemSchema.ReminderMinutesBeforeStart] = base.UserContext.CalendarSettings.DefaultReminderTime;
             calendarItemBase.Save(SaveMode.ResolveConflicts);
             calendarItemBase.Load();
             this.Writer.Write("?ae=Item&a=New&t=IPM.Appointment&exdltdrft=1&id=");
             this.Writer.Write(HttpUtility.UrlEncode(calendarItemBase.Id.ObjectId.ToBase64String()));
         }
         else
         {
             MessageItem messageItem = (MessageItem)item;
             if (itemTypeToPeople == AddressBookItemEventHandler.ItemTypeToPeople.TextMessage)
             {
                 messageItem[StoreObjectSchema.ItemClass] = "IPM.Note.Mobile.SMS";
             }
             messageItem.Save(SaveMode.ResolveConflicts);
             messageItem.Load();
             this.Writer.Write((itemTypeToPeople == AddressBookItemEventHandler.ItemTypeToPeople.TextMessage) ? "?ae=Item&a=Reply&t=IPM.Note.Mobile.SMS&exdltdrft=1&id=" : "?ae=Item&a=New&t=IPM.Note&exdltdrft=1&id=");
             this.Writer.Write(HttpUtility.UrlEncode(messageItem.Id.ObjectId.ToBase64String()));
         }
     }
 }
Exemplo n.º 2
0
        // Token: 0x06002D4E RID: 11598 RVA: 0x000FE4B4 File Offset: 0x000FC6B4
        protected override void LoadRecipientsToItem(Item item, AddressBookItemEventHandler.ItemTypeToPeople itemType)
        {
            MessageItem      messageItem      = null;
            CalendarItemBase calendarItemBase = null;

            if (itemType == AddressBookItemEventHandler.ItemTypeToPeople.Meeting)
            {
                calendarItemBase           = (item as CalendarItemBase);
                calendarItemBase.IsMeeting = true;
            }
            else
            {
                messageItem = (item as MessageItem);
            }
            for (int i = 0; i < this.results.Length; i++)
            {
                ADRecipient data = this.results[i].Data;
                if (data != null)
                {
                    if (itemType == AddressBookItemEventHandler.ItemTypeToPeople.TextMessage)
                    {
                        string emailAddress;
                        if (!string.IsNullOrEmpty(emailAddress = Utilities.NormalizePhoneNumber(data[ADOrgPersonSchema.MobilePhone] as string)))
                        {
                            Participant participant = new Participant(data.DisplayName, emailAddress, "MOBILE");
                            messageItem.Recipients.Add(participant, RecipientItemType.To);
                        }
                    }
                    else
                    {
                        Participant primaryLegacyExchangeParticipant = DirectoryItemEventHandler.GetPrimaryLegacyExchangeParticipant(data);
                        if (primaryLegacyExchangeParticipant != null && itemType == AddressBookItemEventHandler.ItemTypeToPeople.Message)
                        {
                            messageItem.Recipients.Add(primaryLegacyExchangeParticipant, RecipientItemType.To);
                        }
                        else if (primaryLegacyExchangeParticipant != null)
                        {
                            calendarItemBase.AttendeeCollection.Add(primaryLegacyExchangeParticipant, AttendeeType.Required, null, null, false);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 // Token: 0x06002C52 RID: 11346
 protected abstract void LoadRecipientsToItem(Item item, AddressBookItemEventHandler.ItemTypeToPeople itemType);
        // Token: 0x06002D18 RID: 11544 RVA: 0x000FD534 File Offset: 0x000FB734
        protected override void LoadRecipientsToItem(Item item, AddressBookItemEventHandler.ItemTypeToPeople itemType)
        {
            MessageItem      messageItem      = null;
            CalendarItemBase calendarItemBase = null;

            if (itemType == AddressBookItemEventHandler.ItemTypeToPeople.Meeting)
            {
                calendarItemBase           = (item as CalendarItemBase);
                calendarItemBase.IsMeeting = true;
            }
            else
            {
                messageItem = (item as MessageItem);
            }
            for (int i = 0; i < this.itemIds.Length; i++)
            {
                Item item2 = null;
                try
                {
                    if (itemType == AddressBookItemEventHandler.ItemTypeToPeople.TextMessage)
                    {
                        item2 = Utilities.GetItem <Item>(base.UserContext, (OwaStoreObjectId)this.itemIds[i], new PropertyDefinition[]
                        {
                            ContactSchema.MobilePhone
                        });
                    }
                    else
                    {
                        item2 = Utilities.GetItem <Item>(base.UserContext, (OwaStoreObjectId)this.itemIds[i], new PropertyDefinition[0]);
                    }
                    if (item2 is DistributionList)
                    {
                        if (itemType != AddressBookItemEventHandler.ItemTypeToPeople.TextMessage)
                        {
                            Participant asParticipant = ((DistributionList)item2).GetAsParticipant();
                            if (itemType == AddressBookItemEventHandler.ItemTypeToPeople.Message)
                            {
                                messageItem.Recipients.Add(asParticipant, RecipientItemType.To);
                            }
                            else
                            {
                                calendarItemBase.AttendeeCollection.Add(asParticipant, AttendeeType.Required, null, null, false);
                            }
                        }
                    }
                    else if (item2 is Contact)
                    {
                        Contact contact = (Contact)item2;
                        IDictionary <EmailAddressIndex, Participant> emailAddresses = contact.EmailAddresses;
                        if (itemType == AddressBookItemEventHandler.ItemTypeToPeople.TextMessage)
                        {
                            string emailAddress;
                            if (!string.IsNullOrEmpty(emailAddress = Utilities.NormalizePhoneNumber(contact.GetValueOrDefault <string>(ContactSchema.MobilePhone))))
                            {
                                Participant participant = new Participant(contact.DisplayName, emailAddress, "MOBILE");
                                messageItem.Recipients.Add(participant, RecipientItemType.To);
                            }
                        }
                        else if (itemType == AddressBookItemEventHandler.ItemTypeToPeople.Message)
                        {
                            if (emailAddresses[EmailAddressIndex.Email1] != null && !string.IsNullOrEmpty(emailAddresses[EmailAddressIndex.Email1].EmailAddress))
                            {
                                Participant participant2 = emailAddresses[EmailAddressIndex.Email1];
                                messageItem.Recipients.Add(participant2, RecipientItemType.To);
                            }
                            if (emailAddresses[EmailAddressIndex.Email2] != null && !string.IsNullOrEmpty(emailAddresses[EmailAddressIndex.Email2].EmailAddress))
                            {
                                Participant participant3 = emailAddresses[EmailAddressIndex.Email2];
                                messageItem.Recipients.Add(participant3, RecipientItemType.To);
                            }
                            if (emailAddresses[EmailAddressIndex.Email3] != null && !string.IsNullOrEmpty(emailAddresses[EmailAddressIndex.Email3].EmailAddress))
                            {
                                Participant participant4 = emailAddresses[EmailAddressIndex.Email3];
                                messageItem.Recipients.Add(participant4, RecipientItemType.To);
                            }
                        }
                        else
                        {
                            if (emailAddresses[EmailAddressIndex.Email1] != null && !string.IsNullOrEmpty(emailAddresses[EmailAddressIndex.Email1].EmailAddress))
                            {
                                Participant participant5 = emailAddresses[EmailAddressIndex.Email1];
                                calendarItemBase.AttendeeCollection.Add(participant5, AttendeeType.Required, null, null, false);
                            }
                            if (emailAddresses[EmailAddressIndex.Email2] != null && !string.IsNullOrEmpty(emailAddresses[EmailAddressIndex.Email2].EmailAddress))
                            {
                                Participant participant6 = emailAddresses[EmailAddressIndex.Email2];
                                calendarItemBase.AttendeeCollection.Add(participant6, AttendeeType.Required, null, null, false);
                            }
                            if (emailAddresses[EmailAddressIndex.Email3] != null && !string.IsNullOrEmpty(emailAddresses[EmailAddressIndex.Email3].EmailAddress))
                            {
                                Participant participant7 = emailAddresses[EmailAddressIndex.Email3];
                                calendarItemBase.AttendeeCollection.Add(participant7, AttendeeType.Required, null, null, false);
                            }
                        }
                    }
                }
                catch (ObjectNotFoundException)
                {
                    throw new OwaEventHandlerException("The message could not be created because one of the contacts could not be found.", LocalizedStrings.GetNonEncoded(1863833891));
                }
                finally
                {
                    if (item2 != null)
                    {
                        item2.Dispose();
                        item2 = null;
                    }
                }
            }
        }