// Token: 0x060001C5 RID: 453 RVA: 0x00010C5C File Offset: 0x0000EE5C
        public static bool CheckNeedPatternChangeConfirmation(UserContext userContext, CalendarItemData calendarItemData)
        {
            Recurrence           recurrence        = null;
            CalendarItemBaseData userContextData   = EditCalendarItemHelper.GetUserContextData(userContext);
            CalendarItemData     calendarItemData2 = userContextData as CalendarItemData;

            if (calendarItemData2 != null)
            {
                recurrence = calendarItemData2.Recurrence;
            }
            RecurrencePattern p = null;

            if (recurrence != null)
            {
                p = recurrence.Pattern;
            }
            bool flag  = !CalendarItemData.IsRecurrencePatternEqual(calendarItemData.Recurrence.Pattern, p);
            bool flag2 = false;

            if (flag && calendarItemData.Id != null)
            {
                using (CalendarItem item = Utilities.GetItem <CalendarItem>(userContext, calendarItemData.Id, new PropertyDefinition[0]))
                {
                    if (item != null && item.Recurrence != null)
                    {
                        IList <OccurrenceInfo> modifiedOccurrences = item.Recurrence.GetModifiedOccurrences();
                        if (modifiedOccurrences != null)
                        {
                            flag2 = (modifiedOccurrences.Count > 0);
                        }
                    }
                }
            }
            return(flag && flag2);
        }
        private EditCalendarItemPreFormAction.RedirectTo DoAction(string commandPost, EditCalendarItemHelper.CalendarItemUpdateFlags storeUpdateFlags, ref PreFormActionResponse response, out InfobarMessage infobarMessage)
        {
            infobarMessage = null;
            EditCalendarItemHelper.CalendarItemUpdateFlags calendarItemUpdateFlags = EditCalendarItemHelper.CalendarItemUpdateFlags.None;
            string text = null;

            EditCalendarItemPreFormAction.CalendarTab calendarTab = (EditCalendarItemPreFormAction.CalendarTab)RequestParser.TryGetIntValueFromForm(this.request, "hidtab", 0);
            if (Utilities.IsPostRequest(this.request) && !string.Equals(commandPost, "new", StringComparison.Ordinal) && !string.Equals(commandPost, "cls", StringComparison.Ordinal))
            {
                if (calendarTab == EditCalendarItemPreFormAction.CalendarTab.Scheduling)
                {
                    calendarItemUpdateFlags = EditCalendarItemHelper.UpdateImportance(this.calendarItemBase, this.request);
                }
                else
                {
                    calendarItemUpdateFlags = EditCalendarItemHelper.UpdateCalendarItemValues(this.calendarItemBase, this.userContext, this.request, out text);
                }
                if (!string.IsNullOrEmpty(text))
                {
                    infobarMessage = InfobarMessage.CreateText(text, InfobarMessageType.Error);
                    return(EditCalendarItemPreFormAction.RedirectTo.EditCalendarItem);
                }
                if (this.calendarItemBase.AttendeesChanged)
                {
                    calendarItemUpdateFlags |= EditCalendarItemHelper.CalendarItemUpdateFlags.AttendeesChanged;
                }
            }
            EditCalendarItemHelper.CalendarItemUpdateFlags calendarItemUpdateFlags2 = calendarItemUpdateFlags | storeUpdateFlags;
            EditCalendarItemHelper.CancelRangeType         cancelRangeType          = EditCalendarItemHelper.CancelRangeType.None;
            ExDateTime cancelFromDateTime = ExDateTime.MinValue;
            string     formParameter      = Utilities.GetFormParameter(this.request, "delprompt", false);

            if (!string.IsNullOrEmpty(formParameter))
            {
                if (string.Equals(formParameter, "2", StringComparison.Ordinal))
                {
                    cancelRangeType = EditCalendarItemHelper.CancelRangeType.All;
                }
                else if (string.Equals(formParameter, "1", StringComparison.Ordinal))
                {
                    cancelRangeType    = EditCalendarItemHelper.CancelRangeType.FromDate;
                    cancelFromDateTime = CalendarUtilities.ParseDateTimeFromForm(this.request, "seldelY", "seldelM", "seldelD", null, this.userContext);
                }
                else
                {
                    if (!string.Equals(formParameter, "0", StringComparison.Ordinal))
                    {
                        throw new OwaInvalidRequestException("Invalid cancel prompt radio button value.");
                    }
                    cancelRangeType = EditCalendarItemHelper.CancelRangeType.Occurrence;
                }
            }
            EditCalendarItemPreFormAction.RedirectTo result = EditCalendarItemPreFormAction.RedirectTo.None;
            if (commandPost != null)
            {
                if (< PrivateImplementationDetails > { 83F 8DD 10 - 61AE - 4283 - B829 - 2F 464F 055E61 }.$$method0x600016f - 1 == null)
Esempio n. 3
0
        public static Item GetItem(UserContext userContext, AddressBook.Mode viewMode, StoreObjectId itemId, string changeKey)
        {
            Item result = null;

            if (viewMode == AddressBook.Mode.EditMessage || viewMode == AddressBook.Mode.EditMeetingResponse)
            {
                if (!string.IsNullOrEmpty(changeKey))
                {
                    result = Utilities.GetItem <MessageItem>(userContext, itemId, changeKey, new PropertyDefinition[0]);
                }
                else
                {
                    result = Utilities.GetItem <MessageItem>(userContext, itemId, new PropertyDefinition[0]);
                }
            }
            else if (viewMode == AddressBook.Mode.EditCalendar)
            {
                CalendarItemBase calendarItemBase;
                EditCalendarItemHelper.GetCalendarItem(userContext, itemId, null, changeKey, true, out calendarItemBase);
                result = calendarItemBase;
            }
            return(result);
        }
        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);
        }
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            applicationElement = ApplicationElement.NotSet;
            type   = string.Empty;
            state  = string.Empty;
            action = string.Empty;
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();

            preFormActionResponse.Type = owaContext.FormsRegistryContext.Type;
            preFormActionResponse.ApplicationElement = ApplicationElement.Item;
            bool flag  = false;
            bool flag2 = false;
            CalendarItemBaseData calendarItemBaseData = EditCalendarItemHelper.GetUserContextData(owaContext.UserContext);
            StoreObjectId        storeObjectId        = QueryStringUtilities.CreateItemStoreObjectId(owaContext.UserContext.MailboxSession, owaContext.HttpContext.Request, false);

            if (calendarItemBaseData != null && calendarItemBaseData.Id != null && storeObjectId != null && !calendarItemBaseData.Id.Equals(storeObjectId))
            {
                EditCalendarItemHelper.ClearUserContextData(owaContext.UserContext);
                calendarItemBaseData = null;
            }
            if (calendarItemBaseData != null)
            {
                flag  = calendarItemBaseData.IsOrganizer;
                flag2 = calendarItemBaseData.IsMeeting;
            }
            else
            {
                if (storeObjectId == null)
                {
                    throw new OwaLostContextException("Lost changes since last save.");
                }
                CalendarItemBase calendarItemBase2;
                CalendarItemBase calendarItemBase = calendarItemBase2 = CalendarItemBase.Bind(owaContext.UserContext.MailboxSession, storeObjectId);
                try
                {
                    flag  = calendarItemBase.IsOrganizer();
                    flag2 = calendarItemBase.IsMeeting;
                }
                finally
                {
                    if (calendarItemBase2 != null)
                    {
                        ((IDisposable)calendarItemBase2).Dispose();
                    }
                }
            }
            if (flag2 && !flag)
            {
                preFormActionResponse.Action = "Read";
            }
            else
            {
                preFormActionResponse.Action = "Open";
            }
            string text = "ae,a,t,s";

            for (int i = 0; i < owaContext.HttpContext.Request.QueryString.Count; i++)
            {
                string text2 = owaContext.HttpContext.Request.QueryString.Keys[i];
                if (text.IndexOf(text2, StringComparison.Ordinal) == -1)
                {
                    preFormActionResponse.AddParameter(text2, owaContext.HttpContext.Request.QueryString[text2]);
                }
            }
            return(preFormActionResponse);
        }
Esempio n. 6
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);
        }
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext", "owaContext is null.");
            }
            if (owaContext.HttpContext == null)
            {
                throw new ArgumentNullException("owaContext", "owaContext.HttpContext is null.");
            }
            applicationElement = ApplicationElement.NotSet;
            type   = null;
            state  = null;
            action = null;
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();

            preFormActionResponse.ApplicationElement = ApplicationElement.Item;
            preFormActionResponse.Type   = "IPM.Appointment";
            preFormActionResponse.Action = string.Empty;
            preFormActionResponse.State  = string.Empty;
            this.request     = owaContext.HttpContext.Request;
            this.userContext = owaContext.UserContext;
            InfobarMessage infobarMessage = null;
            StoreObjectId  storeObjectId  = null;
            string         changeKey      = null;
            string         action2        = owaContext.FormsRegistryContext.Action;
            string         text;

            if (string.Equals(action2, "New", StringComparison.Ordinal))
            {
                text = "new";
            }
            else
            {
                if (!Utilities.IsPostRequest(this.request))
                {
                    return(this.userContext.LastClientViewState.ToPreFormActionResponse());
                }
                text = Utilities.GetFormParameter(this.request, "hidcmdpst");
                string formParameter = Utilities.GetFormParameter(this.request, "hidid", false);
                changeKey = Utilities.GetFormParameter(this.request, "hidchk", false);
                if (!string.IsNullOrEmpty(formParameter))
                {
                    storeObjectId = Utilities.CreateStoreObjectId(this.userContext.MailboxSession, formParameter);
                }
            }
            StoreObjectId calendarFolderId = EditCalendarItemHelper.GetCalendarFolderId(this.request, this.userContext);
            bool          syncCalendarItem = true;

            if (text.Equals("attch", StringComparison.Ordinal))
            {
                syncCalendarItem = false;
            }
            bool flag = true;

            try
            {
                EditCalendarItemHelper.CalendarItemUpdateFlags storeUpdateFlags = EditCalendarItemHelper.CalendarItemUpdateFlags.None;
                if (!text.Equals("cls", StringComparison.Ordinal))
                {
                    storeUpdateFlags = EditCalendarItemHelper.GetCalendarItem(this.userContext, storeObjectId, calendarFolderId, changeKey, syncCalendarItem, out this.calendarItemBase);
                }
                switch (this.DoAction(text, storeUpdateFlags, ref preFormActionResponse, out infobarMessage))
                {
                case EditCalendarItemPreFormAction.RedirectTo.None:
                    throw new OwaInvalidRequestException("Unhandled redirection.");

                case EditCalendarItemPreFormAction.RedirectTo.AddressBook:
                    preFormActionResponse = EditMessageHelper.RedirectToPeoplePicker(owaContext, this.calendarItemBase, AddressBook.Mode.EditCalendar);
                    EditCalendarItemHelper.CreateUserContextData(this.userContext, this.calendarItemBase);
                    break;

                case EditCalendarItemPreFormAction.RedirectTo.ADPage:
                    preFormActionResponse = EditMessageHelper.RedirectToRecipient(owaContext, this.calendarItemBase, AddressBook.Mode.EditCalendar);
                    EditCalendarItemHelper.CreateUserContextData(this.userContext, this.calendarItemBase);
                    break;

                case EditCalendarItemPreFormAction.RedirectTo.AttachmentManager:
                    if (this.calendarItemBase.Id == null)
                    {
                        CalendarUtilities.SaveCalendarItem(this.calendarItemBase, this.userContext, out infobarMessage);
                    }
                    using (CalendarItemBase calendarItemBase = EditCalendarItemHelper.CreateDraft(this.userContext, null))
                    {
                        CalendarItemBaseData userContextData = EditCalendarItemHelper.GetUserContextData(this.userContext);
                        userContextData.CopyTo(calendarItemBase);
                        string text2;
                        EditCalendarItemHelper.UpdateCalendarItemValues(calendarItemBase, this.userContext, this.request, out text2);
                        EditCalendarItemHelper.CreateUserContextData(this.userContext, calendarItemBase);
                        if (this.calendarItemBase.Id != null)
                        {
                            CalendarItemBaseData userContextData2 = EditCalendarItemHelper.GetUserContextData(this.userContext);
                            userContextData2.Id        = this.calendarItemBase.Id.ObjectId;
                            userContextData2.ChangeKey = this.calendarItemBase.Id.ChangeKeyAsBase64String();
                        }
                    }
                    if (infobarMessage == null)
                    {
                        this.RedirectToAttachmentManager(owaContext, preFormActionResponse);
                    }
                    else
                    {
                        owaContext.PreFormActionData = this.calendarItemBase;
                        flag = false;
                        this.RedirectToEdit(owaContext, infobarMessage, preFormActionResponse);
                    }
                    break;

                case EditCalendarItemPreFormAction.RedirectTo.CalendarDailyView:
                    EditCalendarItemHelper.ClearUserContextData(this.userContext);
                    preFormActionResponse = this.userContext.LastClientViewState.ToPreFormActionResponse();
                    break;

                case EditCalendarItemPreFormAction.RedirectTo.EditCalendarItem:
                    EditCalendarItemHelper.CreateUserContextData(this.userContext, this.calendarItemBase);
                    owaContext.PreFormActionData = this.calendarItemBase;
                    flag = false;
                    this.RedirectToEdit(owaContext, infobarMessage, preFormActionResponse);
                    break;

                case EditCalendarItemPreFormAction.RedirectTo.EditRecurrence:
                    EditCalendarItemHelper.CreateUserContextData(this.userContext, this.calendarItemBase);
                    owaContext.PreFormActionData = CalendarItemBaseData.Create(this.calendarItemBase);
                    preFormActionResponse.Action = "EditRecurrence";
                    if (this.calendarItemBase.IsDirty)
                    {
                        preFormActionResponse.AddParameter("cd", "1");
                    }
                    break;

                case EditCalendarItemPreFormAction.RedirectTo.SchedulingTab:
                    EditCalendarItemHelper.CreateUserContextData(this.userContext, this.calendarItemBase);
                    owaContext.PreFormActionData = this.calendarItemBase;
                    this.RedirectToSchedulingTab(owaContext, infobarMessage, preFormActionResponse);
                    flag = false;
                    break;

                default:
                    throw new OwaInvalidRequestException("Unhandled redirection enum value in EditCalendarItemPreFormAction.");
                }
            }
            catch
            {
                flag = true;
                EditCalendarItemHelper.ClearUserContextData(this.userContext);
                throw;
            }
            finally
            {
                if (flag && this.calendarItemBase != null)
                {
                    this.calendarItemBase.Dispose();
                    this.calendarItemBase = null;
                }
            }
            return(preFormActionResponse);
        }
Esempio n. 8
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");
        }
Esempio n. 9
0
 public virtual EditCalendarItemHelper.CalendarItemUpdateFlags CopyTo(CalendarItemBase calendarItemBase)
 {
     if (calendarItemBase.Id != null && (this.id == null || this.id.CompareTo(calendarItemBase.Id.ObjectId) != 0))
     {
         throw new OwaLostContextException("Lost changes since last save.");
     }
     EditCalendarItemHelper.CalendarItemUpdateFlags calendarItemUpdateFlags = EditCalendarItemHelper.CalendarItemUpdateFlags.None;
     if (EditCalendarItemHelper.BodyChanged(this.bodyText, calendarItemBase))
     {
         if (!string.IsNullOrEmpty(this.bodyText))
         {
             if (this.bodyFormat == BodyFormat.TextHtml)
             {
                 ItemUtility.SetItemBody(calendarItemBase, BodyFormat.TextHtml, this.bodyText);
                 calendarItemUpdateFlags |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
             }
             else
             {
                 if (this.bodyFormat != BodyFormat.TextPlain)
                 {
                     throw new ArgumentOutOfRangeException("calendarItemBase", "Unhandled body format type : " + this.bodyFormat);
                 }
                 ItemUtility.SetItemBody(calendarItemBase, BodyFormat.TextPlain, this.bodyText);
                 calendarItemUpdateFlags |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
             }
         }
         else
         {
             ItemUtility.SetItemBody(calendarItemBase, BodyFormat.TextPlain, string.Empty);
             calendarItemUpdateFlags |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
         }
     }
     if (this.freeBusyStatus != calendarItemBase.FreeBusyStatus)
     {
         calendarItemBase.FreeBusyStatus = this.freeBusyStatus;
         calendarItemUpdateFlags        |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
     }
     if (calendarItemBase.Importance != this.importance)
     {
         calendarItemBase.Importance = this.importance;
         calendarItemUpdateFlags    |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
     }
     if (calendarItemBase.IsAllDayEvent != this.isAllDayEvent)
     {
         calendarItemBase.IsAllDayEvent = this.isAllDayEvent;
         calendarItemUpdateFlags       |= EditCalendarItemHelper.CalendarItemUpdateFlags.TimeChanged;
     }
     if (calendarItemBase.IsMeeting != this.isMeeting)
     {
         calendarItemBase.IsMeeting = this.isMeeting;
         calendarItemUpdateFlags   |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
     }
     if (CalendarItemBaseData.GetIsResponseRequested(calendarItemBase) != this.isResponseRequested)
     {
         CalendarItemBaseData.SetIsResponseRequested(calendarItemBase, this.isResponseRequested);
         calendarItemUpdateFlags |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
     }
     if (!CalendarUtilities.StringsEqualNullEmpty(calendarItemBase.Location, this.location, StringComparison.CurrentCulture))
     {
         calendarItemUpdateFlags  |= EditCalendarItemHelper.CalendarItemUpdateFlags.LocationChanged;
         calendarItemBase.Location = ((this.location != null) ? this.location : string.Empty);
     }
     CalendarItemBaseData.SyncAttendeesToCalendarItem(this, calendarItemBase);
     if (calendarItemBase.AttendeesChanged)
     {
         calendarItemUpdateFlags |= EditCalendarItemHelper.CalendarItemUpdateFlags.AttendeesChanged;
     }
     if (calendarItemBase.Sensitivity != this.sensitivity)
     {
         calendarItemBase.Sensitivity = this.sensitivity;
         calendarItemUpdateFlags     |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
     }
     if (calendarItemBase.EndTime != this.endTime)
     {
         calendarItemUpdateFlags |= EditCalendarItemHelper.CalendarItemUpdateFlags.TimeChanged;
         calendarItemBase.EndTime = this.endTime;
     }
     if (calendarItemBase.StartTime != this.startTime)
     {
         calendarItemUpdateFlags   |= EditCalendarItemHelper.CalendarItemUpdateFlags.TimeChanged;
         calendarItemBase.StartTime = this.startTime;
     }
     if (!CalendarUtilities.StringsEqualNullEmpty(calendarItemBase.Subject, this.subject, StringComparison.CurrentCulture))
     {
         calendarItemBase.Subject = ((this.subject != null) ? this.subject : string.Empty);
         calendarItemUpdateFlags |= EditCalendarItemHelper.CalendarItemUpdateFlags.OtherChanged;
     }
     return(calendarItemUpdateFlags);
 }
        // Token: 0x060001C8 RID: 456 RVA: 0x00010DA0 File Offset: 0x0000EFA0
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext", "owaContext is null");
            }
            if (owaContext.HttpContext == null)
            {
                throw new ArgumentNullException("owaContext", "owaContext.HttpContext is null");
            }
            if (owaContext.HttpContext.Request == null)
            {
                throw new ArgumentNullException("owaContext", "owaContext.HttpContext.Request is null");
            }
            applicationElement = ApplicationElement.NotSet;
            type   = null;
            state  = null;
            action = null;
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();

            preFormActionResponse.ApplicationElement = ApplicationElement.Item;
            preFormActionResponse.Type   = "IPM.Appointment";
            preFormActionResponse.Action = string.Empty;
            preFormActionResponse.State  = string.Empty;
            this.request     = owaContext.HttpContext.Request;
            this.userContext = owaContext.UserContext;
            if (!Utilities.IsPostRequest(this.request))
            {
                return(this.userContext.LastClientViewState.ToPreFormActionResponse());
            }
            InfobarMessage   value = null;
            string           queryStringParameter = Utilities.GetQueryStringParameter(this.request, "a", false);
            CalendarItemData calendarItemData     = EditRecurrencePreFormAction.CreateCalendarItemDataFromRequest(this.request, this.userContext);
            bool             flag = false;
            string           a;

            EditRecurrencePreFormAction.RedirectTo redirectTo;
            if ((a = queryStringParameter) != null)
            {
                if (a == "ChangeRecurrenceMode")
                {
                    if (!string.IsNullOrEmpty(Utilities.GetQueryStringParameter(this.request, "d", false)))
                    {
                        preFormActionResponse.AddParameter("d", "1");
                    }
                    string formParameter = Utilities.GetFormParameter(this.request, "hidcidrt", true);
                    int    num;
                    if (!string.IsNullOrEmpty(formParameter) && int.TryParse(formParameter, out num) && num > 0)
                    {
                        preFormActionResponse.AddParameter("cd", "1");
                    }
                    redirectTo = EditRecurrencePreFormAction.RedirectTo.EditRecurrence;
                    goto IL_217;
                }
                if (a == "CloseRecurrence")
                {
                    redirectTo = EditRecurrencePreFormAction.RedirectTo.EditCalendarItem;
                    goto IL_217;
                }
                if (a == "RemoveRecurrence")
                {
                    calendarItemData.Recurrence = null;
                    flag       = true;
                    redirectTo = EditRecurrencePreFormAction.RedirectTo.EditCalendarItem;
                    goto IL_217;
                }
                if (!(a == "SaveRecurrence"))
                {
                    if (a == "ConfirmedSaveRecurrence")
                    {
                        flag       = true;
                        redirectTo = EditRecurrencePreFormAction.RedirectTo.EditCalendarItem;
                        goto IL_217;
                    }
                }
                else
                {
                    bool flag2 = EditRecurrencePreFormAction.ValidateCalendarItemData(this.userContext, calendarItemData, out value);
                    if (!flag2)
                    {
                        redirectTo = EditRecurrencePreFormAction.RedirectTo.EditRecurrence;
                        goto IL_217;
                    }
                    if (EditRecurrencePreFormAction.CheckNeedPatternChangeConfirmation(this.userContext, calendarItemData))
                    {
                        redirectTo = EditRecurrencePreFormAction.RedirectTo.EditRecurrence;
                        preFormActionResponse.AddParameter("pcp", "1");
                        goto IL_217;
                    }
                    flag       = true;
                    redirectTo = EditRecurrencePreFormAction.RedirectTo.EditCalendarItem;
                    goto IL_217;
                }
            }
            redirectTo = EditRecurrencePreFormAction.RedirectTo.EditRecurrence;
IL_217:
            if (flag)
            {
                CalendarItemData calendarItemData2 = EditCalendarItemHelper.GetUserContextData(this.userContext) as CalendarItemData;
                if (calendarItemData2 == null)
                {
                    throw new OwaInvalidRequestException("UserContext didn't have a CalendarItemData object.");
                }
                calendarItemData2.Recurrence = calendarItemData.Recurrence;
                if (calendarItemData.Recurrence != null)
                {
                    calendarItemData2.StartTime     = calendarItemData.StartTime;
                    calendarItemData2.EndTime       = calendarItemData.EndTime;
                    calendarItemData2.IsAllDayEvent = calendarItemData.IsAllDayEvent;
                }
            }
            switch (redirectTo)
            {
            case EditRecurrencePreFormAction.RedirectTo.None:
                throw new OwaInvalidRequestException("Unhandled redirection in EditRecurrencePreFormAction.");

            case EditRecurrencePreFormAction.RedirectTo.EditRecurrence:
                owaContext.PreFormActionData = calendarItemData;
                preFormActionResponse.Action = "EditRecurrence";
                break;

            case EditRecurrencePreFormAction.RedirectTo.EditCalendarItem:
                preFormActionResponse.Action = "Open";
                if (calendarItemData.Id != null)
                {
                    owaContext.PreFormActionId = OwaStoreObjectId.CreateFromMailboxItemId(calendarItemData.Id);
                }
                break;

            default:
                throw new OwaInvalidRequestException("Unhandled redirection enum value in EditRecurrencePreFormAction.");
            }
            owaContext[OwaContextProperty.InfobarMessage] = value;
            return(preFormActionResponse);
        }
Esempio n. 11
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);
            }
        }
Esempio n. 12
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);
            }
        }