Esempio n. 1
0
        public static Item CreatePostReplyItem(BodyFormat bodyFormat, PostItem item, UserContext userContext, StoreObjectId parentFolderId)
        {
            PostItem postItem = null;
            bool     flag     = true;

            try
            {
                string bodyPrefix = ReplyForwardUtilities.CreateReplyForwardHeader(bodyFormat, item, userContext, parentFolderId);
                string legacyDN   = null;
                OwaStoreObjectIdType owaStoreObjectIdType = Utilities.GetOwaStoreObjectIdType(userContext, item);
                if (owaStoreObjectIdType == OwaStoreObjectIdType.OtherUserMailboxObject)
                {
                    legacyDN = Utilities.GetMailboxSessionLegacyDN(item);
                }
                OwaStoreObjectId destinationFolderId        = OwaStoreObjectId.CreateFromFolderId(parentFolderId, owaStoreObjectIdType, legacyDN);
                OwaStoreObjectId scratchPadForImplicitDraft = Utilities.GetScratchPadForImplicitDraft(StoreObjectType.Post, destinationFolderId);
                try
                {
                    ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat);
                    replyForwardConfiguration.ConversionOptionsForSmime = Utilities.CreateInboundConversionOptions(userContext);
                    replyForwardConfiguration.AddBodyPrefix(bodyPrefix);
                    postItem = item.ReplyToFolder(scratchPadForImplicitDraft.GetSession(userContext), scratchPadForImplicitDraft.StoreObjectId, replyForwardConfiguration);
                }
                catch (StoragePermanentException ex)
                {
                    if (ex.InnerException is MapiExceptionNoCreateRight)
                    {
                        throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892), ex);
                    }
                    throw ex;
                }
                ReplyForwardUtilities.CopyMessageClassificationProperties(item, postItem, userContext);
                Utilities.SetPostSender(postItem, userContext, Utilities.IsPublic(item));
                postItem.ConversationTopic = item.ConversationTopic;
                flag = false;
            }
            finally
            {
                if (flag && postItem != null)
                {
                    postItem.Dispose();
                    postItem = null;
                }
            }
            return(postItem);
        }
        // Token: 0x06000796 RID: 1942 RVA: 0x00039B98 File Offset: 0x00037D98
        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.Item;
            type   = null;
            action = "Open";
            state  = string.Empty;
            CalendarItemBase calendarItemBase     = null;
            string           queryStringParameter = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "id");
            UserContext      userContext          = owaContext.UserContext;
            OwaStoreObjectId preFormActionId      = OwaStoreObjectId.CreateFromString(queryStringParameter);
            bool             flag  = false;
            Item             item  = null;
            bool             flag2 = false;

            try
            {
                calendarItemBase = Utilities.GetItemForRequest <CalendarItemBase>(owaContext, out item, false, new PropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights
                });
                flag2 = (item != null);
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.CalendarDataTracer.TraceDebug(0L, "calendar item could not be found.");
                string queryStringParameter2 = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "gid", false);
                if (string.IsNullOrEmpty(queryStringParameter2))
                {
                    throw;
                }
                byte[]      globalObjectIdBytes = null;
                VersionedId versionedId         = null;
                try
                {
                    globalObjectIdBytes = Convert.FromBase64String(queryStringParameter2);
                }
                catch (FormatException innerException)
                {
                    throw new OwaInvalidRequestException("Invalid global object id for conflicting calendar item", innerException);
                }
                string           queryStringParameter3 = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "fid", false);
                OwaStoreObjectId owaStoreObjectId      = null;
                if (!string.IsNullOrEmpty(queryStringParameter3))
                {
                    owaStoreObjectId = OwaStoreObjectId.CreateFromString(queryStringParameter3);
                }
                else
                {
                    owaStoreObjectId = userContext.CalendarFolderOwaId;
                }
                using (CalendarFolder folder = Utilities.GetFolder <CalendarFolder>(userContext, owaStoreObjectId, new PropertyDefinition[0]))
                {
                    versionedId = folder.GetCalendarItemId(globalObjectIdBytes);
                }
                if (versionedId == null)
                {
                    throw;
                }
                MailboxSession session = (MailboxSession)owaStoreObjectId.GetSession(userContext);
                calendarItemBase = CalendarItemBase.Bind(session, versionedId, new StorePropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights
                });
                flag = true;
            }
            finally
            {
                using (item)
                {
                    using (calendarItemBase)
                    {
                        if (calendarItemBase != null)
                        {
                            if (!Utilities.IsPublic(calendarItemBase) && calendarItemBase.IsMeeting && !calendarItemBase.IsOrganizer())
                            {
                                type = "IPM.Schedule.Meeting.Request";
                            }
                            else
                            {
                                type = "IPM.Appointment";
                                if (flag2 || !ItemUtility.UserCanEditItem(calendarItemBase) || Utilities.IsItemInExternalSharedInFolder(userContext, calendarItemBase))
                                {
                                    action = string.Empty;
                                }
                            }
                            if (!flag2)
                            {
                                if (flag)
                                {
                                    owaContext.PreFormActionId = OwaStoreObjectId.CreateFromStoreObject(calendarItemBase);
                                }
                                else
                                {
                                    owaContext.PreFormActionId = preFormActionId;
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }