Beispiel #1
0
        public static void RenderAttendees(TextWriter writer, AttendeeType type, CalendarItemBase item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            bool flag = true;
            int  num  = 0;

            foreach (Attendee attendee in item.AttendeeCollection)
            {
                if (attendee.AttendeeType == type)
                {
                    if (!flag && attendee.Participant.RoutingType != null)
                    {
                        writer.Write("; ");
                    }
                    AddressBookHelper.RenderParticipant(writer, num, attendee.Participant);
                    flag = false;
                }
                num++;
            }
            if (flag)
            {
                writer.Write(" ");
            }
        }
Beispiel #2
0
        public static void RenderRecipients(TextWriter writer, RecipientItemType type, MessageItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            bool flag     = true;
            int  num      = 0;
            bool property = ItemUtility.GetProperty <bool>(item, MessageItemSchema.IsResend, false);

            foreach (Recipient recipient in item.Recipients)
            {
                if (recipient.RecipientItemType == type && (!property || !recipient.Submitted))
                {
                    if (!flag && recipient.Participant.RoutingType != null)
                    {
                        writer.Write("; ");
                    }
                    AddressBookHelper.RenderParticipant(writer, num, recipient.Participant);
                    flag = false;
                }
                num++;
            }
            if (flag)
            {
                writer.Write("&nbsp;");
            }
        }
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            UserContext userContext = owaContext.UserContext;
            HttpRequest request     = owaContext.HttpContext.Request;

            string[] array = null;
            applicationElement = ApplicationElement.Item;
            type   = string.Empty;
            action = string.Empty;
            state  = string.Empty;
            if (!Utilities.IsPostRequest(request))
            {
                return(userContext.LastClientViewState.ToPreFormActionResponse());
            }
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();
            string        formParameter = Utilities.GetFormParameter(request, "hidAB");
            int           num           = 0;
            StoreObjectId storeObjectId = null;
            string        changeKey     = null;

            string[] array2 = formParameter.Split(new char[]
            {
                ';'
            });
            if (array2 != null && array2.Length > 0)
            {
                if (string.CompareOrdinal(array2[0], "Ad") == 0)
                {
                    num = 1;
                }
                else
                {
                    if (string.CompareOrdinal(array2[0], "Con") != 0)
                    {
                        throw new OwaInvalidRequestException("Invalid search location for addressbook");
                    }
                    num = 2;
                }
            }
            string action2 = owaContext.FormsRegistryContext.Action;

            if (action2 == null)
            {
                throw new OwaInvalidRequestException("Action query string parameter is missing");
            }
            object obj = AddressBookPreFormAction.actionParser.Parse(action2);

            AddressBookPreFormAction.Action action3 = (AddressBookPreFormAction.Action)obj;
            string text = request.Form["chkRcpt"];

            if (!string.IsNullOrEmpty(text))
            {
                array = text.Split(new char[]
                {
                    ','
                });
            }
            AddressBook.Mode mode = AddressBookHelper.TryReadAddressBookMode(request, AddressBook.Mode.None);
            if (AddressBook.IsEditingMode(mode))
            {
                string formParameter2 = Utilities.GetFormParameter(request, "hidid", false);
                changeKey = Utilities.GetFormParameter(request, "hidchk", false);
                if (!string.IsNullOrEmpty(formParameter2))
                {
                    storeObjectId = Utilities.CreateStoreObjectId(userContext.MailboxSession, formParameter2);
                    if (storeObjectId == null)
                    {
                        throw new OwaInvalidRequestException("ItemId cannot be null");
                    }
                }
            }
            switch (action3)
            {
            case AddressBookPreFormAction.Action.Done:
                if (AddressBook.IsEditingMode(mode))
                {
                    using (Item item = AddressBookHelper.GetItem(userContext, mode, storeObjectId, changeKey))
                    {
                        if (array != null && array.Length > 0)
                        {
                            RecipientItemType type2          = RecipientItemType.To;
                            string            formParameter3 = Utilities.GetFormParameter(request, "hidrw");
                            if (!string.IsNullOrEmpty(formParameter3))
                            {
                                int num2;
                                if (!int.TryParse(formParameter3, out num2) || num2 < 1 || num2 > 3)
                                {
                                    type2 = RecipientItemType.To;
                                }
                                else
                                {
                                    type2 = (RecipientItemType)num2;
                                }
                            }
                            if (num == 1)
                            {
                                AddressBookHelper.AddRecipientsToDraft(array, item, type2, userContext);
                            }
                            else if (num == 2)
                            {
                                AddressBookHelper.AddContactsToDraft(item, type2, userContext, array);
                            }
                        }
                        preFormActionResponse = AddressBookHelper.RedirectToEdit(userContext, item, mode);
                        break;
                    }
                }
                throw new OwaInvalidRequestException("This action must be in editing mode");

            case AddressBookPreFormAction.Action.Mail:
                if (array != null && array.Length > 0)
                {
                    using (Item item2 = MessageItem.Create(userContext.MailboxSession, userContext.DraftsFolderId))
                    {
                        item2[ItemSchema.ConversationIndexTracking] = true;
                        if (num == 1)
                        {
                            AddressBookHelper.AddRecipientsToDraft(array, item2, RecipientItemType.To, userContext);
                        }
                        else if (num == 2)
                        {
                            AddressBookHelper.AddContactsToDraft(item2, RecipientItemType.To, userContext, array);
                        }
                        preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                        preFormActionResponse.Type   = "IPM.Note";
                        preFormActionResponse.Action = "Open";
                        preFormActionResponse.State  = "Draft";
                        preFormActionResponse.AddParameter("id", item2.Id.ObjectId.ToBase64String());
                        break;
                    }
                }
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type   = "IPM.Note";
                preFormActionResponse.Action = "New";
                break;

            case AddressBookPreFormAction.Action.MeetingRequest:
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type = "IPM.Appointment";
                if (array != null && array.Length > 0)
                {
                    using (CalendarItemBase calendarItemBase = EditCalendarItemHelper.CreateDraft(userContext, userContext.CalendarFolderId))
                    {
                        calendarItemBase.IsMeeting = true;
                        if (num == 1)
                        {
                            AddressBookHelper.AddRecipientsToDraft(array, calendarItemBase, RecipientItemType.To, userContext);
                        }
                        else if (num == 2)
                        {
                            AddressBookHelper.AddContactsToDraft(calendarItemBase, RecipientItemType.To, userContext, array);
                        }
                        preFormActionResponse.Action = "Open";
                        EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase);
                        break;
                    }
                }
                preFormActionResponse.AddParameter("mr", "1");
                preFormActionResponse.Action = "New";
                break;

            case AddressBookPreFormAction.Action.Close:
                if (AddressBook.IsEditingMode(mode))
                {
                    using (Item item3 = AddressBookHelper.GetItem(userContext, mode, storeObjectId, changeKey))
                    {
                        preFormActionResponse = AddressBookHelper.RedirectToEdit(userContext, item3, mode);
                        break;
                    }
                }
                throw new OwaInvalidRequestException("This action must be in editing mode");

            case AddressBookPreFormAction.Action.AddToContacts:
            {
                string type3 = "IPM.Contact";
                string text2 = null;
                if (array == null || array.Length != 1)
                {
                    throw new OwaInvalidRequestException("User must select some recipient to add and can only add one recipient to contacts at one time");
                }
                ADObjectId adobjectId = DirectoryAssistance.ParseADObjectId(array[0]);
                if (adobjectId == null)
                {
                    throw new OwaADObjectNotFoundException();
                }
                IRecipientSession recipientSession = Utilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.FullyConsistent, true, userContext);
                ADRecipient       adrecipient      = recipientSession.Read(adobjectId);
                if (adrecipient == null)
                {
                    throw new OwaADObjectNotFoundException();
                }
                using (ContactBase contactBase = ContactUtilities.AddADRecipientToContacts(userContext, adrecipient))
                {
                    if (contactBase != null)
                    {
                        contactBase.Load();
                        text2 = contactBase.Id.ObjectId.ToBase64String();
                        type3 = contactBase.ClassName;
                    }
                }
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type = type3;
                if (text2 != null)
                {
                    preFormActionResponse.Action = "Open";
                    preFormActionResponse.State  = "Draft";
                    preFormActionResponse.AddParameter("id", text2);
                }
                else
                {
                    preFormActionResponse.Action = "New";
                }
                break;
            }

            default:
                throw new OwaInvalidRequestException("Invalid request for addressbook preformaction");
            }
            return(preFormActionResponse);
        }
Beispiel #4
0
        // Token: 0x06000127 RID: 295 RVA: 0x00009A0C File Offset: 0x00007C0C
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            UserContext userContext = owaContext.UserContext;
            HttpRequest request     = owaContext.HttpContext.Request;

            string[] array = null;
            applicationElement = ApplicationElement.NotSet;
            type   = string.Empty;
            action = string.Empty;
            state  = string.Empty;
            if (!Utilities.IsPostRequest(request))
            {
                return(userContext.LastClientViewState.ToPreFormActionResponse());
            }
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();
            string queryStringParameter = Utilities.GetQueryStringParameter(request, "a", true);
            object obj = ContactViewPreFormAction.actionParser.Parse(queryStringParameter);

            ContactViewPreFormAction.Action action2 = (ContactViewPreFormAction.Action)obj;
            string text = request.Form["chkRcpt"];

            if (!string.IsNullOrEmpty(text))
            {
                array = text.Split(new char[]
                {
                    ','
                });
            }
            switch (action2)
            {
            case ContactViewPreFormAction.Action.Mail:
                if (array != null && array.Length > 0)
                {
                    using (MessageItem messageItem = MessageItem.Create(userContext.MailboxSession, userContext.DraftsFolderId))
                    {
                        messageItem[ItemSchema.ConversationIndexTracking] = true;
                        AddressBookHelper.AddContactsToDraft(messageItem, RecipientItemType.To, userContext, array);
                        preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                        preFormActionResponse.Type   = "IPM.Note";
                        preFormActionResponse.Action = "Open";
                        preFormActionResponse.State  = "Draft";
                        preFormActionResponse.AddParameter("id", messageItem.Id.ObjectId.ToBase64String());
                        break;
                    }
                }
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type   = "IPM.Note";
                preFormActionResponse.Action = "New";
                break;

            case ContactViewPreFormAction.Action.MeetingRequest:
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type = "IPM.Appointment";
                if (array != null && array.Length > 0)
                {
                    using (CalendarItemBase calendarItemBase = EditCalendarItemHelper.CreateDraft(userContext, userContext.CalendarFolderId))
                    {
                        calendarItemBase.IsMeeting = true;
                        AddressBookHelper.AddContactsToDraft(calendarItemBase, RecipientItemType.To, userContext, array);
                        preFormActionResponse.Action = "Open";
                        EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase);
                        break;
                    }
                }
                preFormActionResponse.AddParameter("mr", "1");
                preFormActionResponse.Action = "New";
                break;

            default:
                throw new OwaInvalidRequestException("Invalid request for addressbook preformaction");
            }
            return(preFormActionResponse);
        }
Beispiel #5
0
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            HttpContext httpContext = owaContext.HttpContext;
            UserContext userContext = owaContext.UserContext;
            HttpRequest request     = httpContext.Request;

            applicationElement = ApplicationElement.Item;
            type   = string.Empty;
            action = string.Empty;
            state  = string.Empty;
            if (!Utilities.IsPostRequest(request))
            {
                return(userContext.LastClientViewState.ToPreFormActionResponse());
            }
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();

            if (owaContext.FormsRegistryContext.Action == null)
            {
                throw new OwaInvalidRequestException("Action is missing");
            }
            string        formParameter = Utilities.GetFormParameter(request, "hidid", true);
            StoreObjectId storeObjectId = Utilities.CreateStoreObjectId(userContext.MailboxSession, formParameter);
            string        action2;

            if ((action2 = owaContext.FormsRegistryContext.Action) != null)
            {
                if (!(action2 == "Mail"))
                {
                    if (!(action2 == "MeetingRequest"))
                    {
                        if (action2 == "Delete")
                        {
                            goto IL_1E9;
                        }
                        if (!(action2 == "AddRcpt"))
                        {
                            goto IL_33E;
                        }
                        AddressBook.Mode mode = AddressBookHelper.TryReadAddressBookMode(request, AddressBook.Mode.None);
                        if (mode != AddressBook.Mode.EditMessage && mode != AddressBook.Mode.EditMeetingResponse && mode != AddressBook.Mode.EditCalendar)
                        {
                            throw new OwaInvalidRequestException("Not in edit mode");
                        }
                        string        queryStringParameter = Utilities.GetQueryStringParameter(request, "id", false);
                        StoreObjectId itemId = null;
                        if (!string.IsNullOrEmpty(queryStringParameter))
                        {
                            itemId = Utilities.CreateStoreObjectId(userContext.MailboxSession, queryStringParameter);
                        }
                        string            queryStringParameter2 = Utilities.GetQueryStringParameter(request, "chk", false);
                        RecipientItemType type2 = (RecipientItemType)RequestParser.TryGetIntValueFromQueryString(request, "rw", 1);
                        using (Item item = AddressBookHelper.GetItem(userContext, mode, itemId, queryStringParameter2))
                        {
                            Participant participant = Utilities.CreateParticipantFromQueryString(userContext, request);
                            if (participant != null)
                            {
                                AddressBookHelper.AddParticipantToItem(item, type2, participant);
                                CalendarItemBase calendarItemBase = item as CalendarItemBase;
                                if (calendarItemBase != null)
                                {
                                    EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase);
                                }
                                else if (item is MessageItem)
                                {
                                    AddressBookHelper.SaveItem(item);
                                }
                            }
                            return(AddressBookHelper.RedirectToEdit(userContext, item, mode));
                        }
                        goto IL_33E;
                    }
                }
                else
                {
                    using (MessageItem messageItem = MessageItem.Create(userContext.MailboxSession, userContext.DraftsFolderId))
                    {
                        messageItem[ItemSchema.ConversationIndexTracking] = true;
                        AddressBookHelper.AddContactsToDraft(messageItem, RecipientItemType.To, userContext, new string[]
                        {
                            storeObjectId.ToBase64String()
                        });
                        preFormActionResponse.AddParameter("id", messageItem.Id.ObjectId.ToBase64String());
                        preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                        preFormActionResponse.Type   = "IPM.Note";
                        preFormActionResponse.Action = "Open";
                        preFormActionResponse.State  = "Draft";
                        return(preFormActionResponse);
                    }
                }
                using (CalendarItemBase calendarItemBase2 = EditCalendarItemHelper.CreateDraft(userContext, userContext.CalendarFolderId))
                {
                    calendarItemBase2.IsMeeting = true;
                    AddressBookHelper.AddContactsToDraft(calendarItemBase2, RecipientItemType.To, userContext, new string[]
                    {
                        storeObjectId.ToBase64String()
                    });
                    preFormActionResponse.Action             = "Open";
                    preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                    preFormActionResponse.Type = calendarItemBase2.ClassName;
                    EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase2);
                    return(preFormActionResponse);
                }
IL_1E9:
                string formParameter2 = Utilities.GetFormParameter(request, "hidcmdpst", true);
                if (formParameter2 == "d")
                {
                    Utilities.DeleteItems(userContext, DeleteItemFlags.SoftDelete, new StoreId[]
                    {
                        storeObjectId
                    });
                }
                else
                {
                    if (!(formParameter2 == "m"))
                    {
                        throw new OwaInvalidRequestException("Unknown delete command");
                    }
                    Utilities.DeleteItems(userContext, DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                    {
                        storeObjectId
                    });
                }
                userContext.ForceNewSearch = true;
                preFormActionResponse      = userContext.LastClientViewState.ToPreFormActionResponse();
                return(preFormActionResponse);
            }
IL_33E:
            throw new OwaInvalidRequestException("Invalid action for readcontact preformaction");
        }
Beispiel #6
0
        public static void AddContactsToDraft(Item draft, RecipientItemType type, UserContext userContext, params string[] ids)
        {
            if (draft == null)
            {
                throw new ArgumentNullException("draft");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("usercontext");
            }
            if (ids == null || ids.Length == 0)
            {
                throw new ArgumentException("ids is null or empty.", "ids");
            }
            Participant    participant    = null;
            RecipientCache recipientCache = AutoCompleteCache.TryGetCache(OwaContext.Current.UserContext);
            int            i = 0;

            while (i < ids.Length)
            {
                StoreObjectId storeObjectId = Utilities.CreateStoreObjectId(userContext.MailboxSession, ids[i]);
                if (storeObjectId.ObjectType == StoreObjectType.DistributionList)
                {
                    using (DistributionList item = Utilities.GetItem <DistributionList>(userContext, storeObjectId, new PropertyDefinition[]
                    {
                        StoreObjectSchema.DisplayName
                    }))
                    {
                        participant = item.GetAsParticipant();
                        goto IL_113;
                    }
                    goto IL_9B;
                }
                goto IL_9B;
IL_113:
                if (participant != null)
                {
                    if (recipientCache != null && userContext.UserOptions.AddRecipientsToAutoCompleteCache)
                    {
                        string participantProperty = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.SmtpAddress, null);
                        recipientCache.AddEntry(participant.DisplayName, participantProperty, participant.EmailAddress, string.Empty, participant.RoutingType, AddressOrigin.Store, 0, storeObjectId.ToBase64String(), ((StoreParticipantOrigin)participant.Origin).EmailAddressIndex);
                    }
                    AddressBookHelper.AddParticipantToItem(draft, type, participant);
                    participant = null;
                }
                i++;
                continue;
IL_9B:
                using (Contact item2 = Utilities.GetItem <Contact>(userContext, storeObjectId, AddressBookHelper.contactsProperties))
                {
                    foreach (KeyValuePair <EmailAddressIndex, Participant> keyValuePair in item2.EmailAddresses)
                    {
                        if (keyValuePair.Value != null && !string.IsNullOrEmpty(keyValuePair.Value.EmailAddress))
                        {
                            participant = keyValuePair.Value;
                            break;
                        }
                    }
                }
                goto IL_113;
            }
            if (recipientCache != null && recipientCache.IsDirty)
            {
                recipientCache.Commit(true);
            }
            CalendarItemBase calendarItemBase = draft as CalendarItemBase;

            if (calendarItemBase != null)
            {
                EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase);
                return;
            }
            if (draft is MessageItem)
            {
                AddressBookHelper.SaveItem(draft);
            }
        }
Beispiel #7
0
        public static void AddRecipientsToDraft(string[] ids, Item draft, RecipientItemType type, UserContext userContext)
        {
            if (draft == null)
            {
                throw new ArgumentNullException("draft");
            }
            MessageItem      messageItem      = draft as MessageItem;
            CalendarItemBase calendarItemBase = draft as CalendarItemBase;

            if (messageItem == null && calendarItemBase == null)
            {
                throw new ArgumentException("The draft should be a MessageItem or a CalendarItemBase while it is now a " + draft.GetType().Name);
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("usercontext");
            }
            if (ids == null || ids.Length == 0)
            {
                throw new ArgumentException("ids is null or empty.", "ids");
            }
            IRecipientSession recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, userContext);
            SortBy            sortBy           = new SortBy(ADRecipientSchema.DisplayName, SortOrder.Descending);
            RecipientCache    recipientCache   = AutoCompleteCache.TryGetCache(OwaContext.Current.UserContext);

            for (int i = 0; i < ids.Length; i++)
            {
                Guid          guidFromBase64String = Utilities.GetGuidFromBase64String(ids[i]);
                QueryFilter   filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Guid, guidFromBase64String);
                ADRecipient[] array  = recipientSession.Find(null, QueryScope.SubTree, filter, sortBy, 1);
                if (array != null && array.Length != 0)
                {
                    Participant participant = new Participant(array[0]);
                    if (participant != null)
                    {
                        AddressBookHelper.AddParticipantToItem(draft, type, participant);
                        int recipientFlags = 0;
                        if (draft is CalendarItem && DirectoryAssistance.IsADRecipientRoom(array[0]))
                        {
                            recipientFlags = 2;
                        }
                        if (recipientCache != null && userContext.UserOptions.AddRecipientsToAutoCompleteCache)
                        {
                            string participantProperty = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.SmtpAddress, null);
                            recipientCache.AddEntry(array[0].DisplayName, participantProperty, array[0].LegacyExchangeDN, string.Empty, "EX", AddressOrigin.Directory, recipientFlags, null, EmailAddressIndex.None);
                        }
                    }
                }
            }
            if (recipientCache != null && recipientCache.IsDirty)
            {
                recipientCache.Commit(true);
            }
            if (messageItem != null)
            {
                AddressBookHelper.SaveItem(draft);
                return;
            }
            if (calendarItemBase != null)
            {
                EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase);
            }
        }