Beispiel #1
0
        public static void DeleteCalendarItem(StoreObjectId calendarItemId, DeleteItemFlags deleteFlag)
        {
            if (calendarItemId == null)
            {
                throw new ArgumentNullException("calendarItemId");
            }
            UserContext userContext = UserContextManager.GetUserContext();

            using (CalendarItemBase calendarItemBase = (CalendarItemBase)Item.Bind(userContext.MailboxSession, calendarItemId, ItemBindOption.LoadRequiredPropertiesOnly))
            {
                calendarItemBase.DeleteMeeting(deleteFlag);
            }
        }
Beispiel #2
0
        public static void DeleteMeetingMessageCalendarItem(StoreObjectId meetingMessageId)
        {
            if (meetingMessageId == null)
            {
                throw new ArgumentNullException("meetingRequestId");
            }
            MeetingMessage   meetingMessage   = null;
            CalendarItemBase calendarItemBase = null;
            UserContext      userContext      = UserContextManager.GetUserContext();

            try
            {
                try
                {
                    meetingMessage = (MeetingMessage)Item.Bind(userContext.MailboxSession, meetingMessageId, ItemBindOption.LoadRequiredPropertiesOnly);
                }
                catch (ObjectNotFoundException)
                {
                    ExTraceGlobals.CalendarDataTracer.TraceDebug(0L, "Meeting request could not be found.");
                    throw;
                }
                calendarItemBase = MeetingUtilities.TryGetCorrelatedItem(meetingMessage);
                if (calendarItemBase != null)
                {
                    if (!calendarItemBase.IsOrganizer())
                    {
                        MeetingRequest meetingRequest = meetingMessage as MeetingRequest;
                        if (meetingRequest != null)
                        {
                            if (meetingRequest.MeetingRequestType == MeetingMessageType.InformationalUpdate || meetingRequest.MeetingRequestType == MeetingMessageType.Outdated || calendarItemBase.ResponseType == ResponseType.Accept || calendarItemBase.ResponseType == ResponseType.Tentative)
                            {
                                return;
                            }
                        }
                        else
                        {
                            if (!(meetingMessage is MeetingCancellation))
                            {
                                throw new OwaInvalidRequestException("Meeting message must be either a meeting invite or meeting cancellation");
                            }
                            if (meetingMessage.IsOutOfDate(calendarItemBase))
                            {
                                return;
                            }
                        }
                        calendarItemBase.DeleteMeeting(DeleteItemFlags.MoveToDeletedItems);
                    }
                }
            }
            finally
            {
                if (meetingMessage != null)
                {
                    meetingMessage.Dispose();
                    meetingMessage = null;
                }
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                    calendarItemBase = null;
                }
            }
        }
Beispiel #3
0
        public void Delete()
        {
            ExTraceGlobals.CalendarCallTracer.TraceDebug((long)this.GetHashCode(), "CalendarViewEventHandler.Delete");
            OwaStoreObjectId owaStoreObjectId  = (OwaStoreObjectId)base.GetParameter("Id");
            OwaStoreObjectId owaStoreObjectId2 = (OwaStoreObjectId)base.GetParameter("fId");
            Item             item             = null;
            CalendarItemBase calendarItemBase = null;
            bool             flag             = true;

            try
            {
                item = Utilities.GetItem <Item>(base.UserContext, owaStoreObjectId, new PropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights,
                    CalendarItemBaseSchema.MeetingRequestWasSent,
                    CalendarItemBaseSchema.IsOrganizer
                });
                calendarItemBase = (item as CalendarItemBase);
                if (calendarItemBase != null)
                {
                    if (!CalendarUtilities.UserCanDeleteCalendarItem(calendarItemBase) || Utilities.IsItemInExternalSharedInFolder(base.UserContext, calendarItemBase))
                    {
                        base.ResponseContentType = OwaEventContentType.Html;
                        this.Writer.Write("<div id=divOp _sOp=np></div>");
                        flag = false;
                    }
                    else if (!base.IsParameterSet("FD") && calendarItemBase.IsMeeting && calendarItemBase.MeetingRequestWasSent && calendarItemBase.IsOrganizer())
                    {
                        base.ResponseContentType = OwaEventContentType.Html;
                        this.Writer.Write("<div id=divOp _sOp=sc></div>");
                        flag = false;
                    }
                    else if (!base.IsParameterSet("FD") && !calendarItemBase.IsOrganizer() && !calendarItemBase.IsCancelled && !MeetingUtilities.IsCalendarItemEndTimeInPast(calendarItemBase))
                    {
                        base.ResponseContentType = OwaEventContentType.Html;
                        this.Writer.Write("<div id=divOp _sOp=sr></div>");
                        flag = false;
                    }
                    else if (!base.IsParameterSet("FD") && (owaStoreObjectId2.IsOtherMailbox || owaStoreObjectId2.IsGSCalendar))
                    {
                        base.ResponseContentType = OwaEventContentType.Html;
                        this.Writer.Write("<div id=divOp _sOp=sn></div>");
                        flag = false;
                    }
                }
                else if (!ItemUtility.UserCanDeleteItem(item))
                {
                    base.ResponseContentType = OwaEventContentType.Html;
                    this.Writer.Write("<div id=divOp _sOp=np></div>");
                    flag = false;
                }
                if (flag)
                {
                    bool flag2 = false;
                    if (base.IsParameterSet("Ntfy"))
                    {
                        flag2 = (bool)base.GetParameter("Ntfy");
                    }
                    if (flag2)
                    {
                        PrincipalNotificationMessage principalNotificationMessage = new PrincipalNotificationMessage(owaStoreObjectId.ToBase64String(), owaStoreObjectId2, base.UserContext, this.HttpContext, PrincipalNotificationMessage.ActionType.Delete, false, calendarItemBase.IsMeeting);
                        principalNotificationMessage.SendNotificationMessage();
                    }
                    bool flag3 = false;
                    if (base.IsParameterSet("Prm"))
                    {
                        flag3 = (bool)base.GetParameter("Prm");
                    }
                    DeleteItemFlags deleteItemFlags = DeleteItemFlags.None;
                    if (!owaStoreObjectId2.IsPublic)
                    {
                        if (calendarItemBase.IsOrganizer())
                        {
                            if (calendarItemBase.IsMeeting)
                            {
                                goto IL_269;
                            }
                            deleteItemFlags = DeleteItemFlags.CancelCalendarItem;
                            MeetingCancellation meetingCancellation = null;
                            try
                            {
                                try
                                {
                                    calendarItemBase.OpenAsReadWrite();
                                    meetingCancellation = calendarItemBase.CancelMeeting(null, null);
                                }
                                catch (ObjectNotFoundException)
                                {
                                }
                                catch (AccessDeniedException)
                                {
                                }
                                goto IL_269;
                            }
                            finally
                            {
                                if (meetingCancellation != null)
                                {
                                    meetingCancellation.Dispose();
                                }
                                meetingCancellation = null;
                            }
                        }
                        deleteItemFlags = DeleteItemFlags.DeclineCalendarItemWithoutResponse;
                    }
IL_269:
                    calendarItemBase.DeleteMeeting((flag3 ? DeleteItemFlags.SoftDelete : DeleteItemFlags.MoveToDeletedItems) | deleteItemFlags);
                    this.RenderPayload(new OwaStoreObjectId[]
                    {
                        owaStoreObjectId2
                    });
                }
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.CalendarDataTracer.TraceDebug((long)this.GetHashCode(), "Calendar item could not be found.");
                throw;
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
            }
        }