Example #1
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;
                }
            }
        }
Example #2
0
        public void CopyOrMoveAppointment()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "CalendarViewEventHandler.CrossCalendarCopyMove");
            OwaStoreObjectId owaStoreObjectId  = (OwaStoreObjectId)base.GetParameter("Id");
            string           changeKey         = (string)base.GetParameter("CK");
            OwaStoreObjectId owaStoreObjectId2 = (OwaStoreObjectId)base.GetParameter("fId");
            bool             flag             = (bool)base.GetParameter("fC");
            StoreObjectId    storeObjectId    = owaStoreObjectId2.StoreObjectId;
            CalendarItemBase calendarItemBase = null;

            if (Utilities.IsELCRootFolder(owaStoreObjectId2, base.UserContext))
            {
                throw new OwaInvalidRequestException("Cannot move messages to the root ELC folder.");
            }
            if (owaStoreObjectId.IsGSCalendar)
            {
                throw new OwaInvalidRequestException("Item id cannot be GS Calendar folder id");
            }
            if (owaStoreObjectId2.IsGSCalendar)
            {
                throw new OwaInvalidRequestException("Cannot copy/move to GS Calendar");
            }
            MailboxSession mailboxSession = owaStoreObjectId2.GetSessionForFolderContent(base.UserContext) as MailboxSession;

            if (mailboxSession == null)
            {
                throw new OwaInvalidRequestException("Cannot copy/move to public folder by this function");
            }
            if (storeObjectId.ObjectType != StoreObjectType.CalendarFolder)
            {
                throw new OwaInvalidRequestException("This function only support to copy/move to calendar folder");
            }
            try
            {
                calendarItemBase = Utilities.GetItem <CalendarItemBase>(base.UserContext, owaStoreObjectId, changeKey, new PropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights
                });
                if (calendarItemBase.ParentId.Equals(storeObjectId))
                {
                    this.RenderCopyMoveFail(-612884101);
                }
                else
                {
                    MailboxSession mailboxSession2 = calendarItemBase.Session as MailboxSession;
                    if (mailboxSession2 == null)
                    {
                        throw new OwaInvalidRequestException("Cannot copy/move from public folder by this function");
                    }
                    if (!StringComparer.OrdinalIgnoreCase.Equals(mailboxSession2.MailboxOwner.LegacyDn, mailboxSession.MailboxOwner.LegacyDn))
                    {
                        if (flag)
                        {
                            this.RenderCopyMoveFail(-1539006262);
                        }
                        else
                        {
                            this.RenderCopyMoveFail(1992576846);
                        }
                    }
                    else
                    {
                        bool flag2 = Utilities.CanCreateItemInFolder(base.UserContext, owaStoreObjectId2) && !Utilities.IsExternalSharedInFolder(base.UserContext, owaStoreObjectId2);
                        if (!flag)
                        {
                            flag2 = (flag2 && CalendarUtilities.UserCanDeleteCalendarItem(calendarItemBase) && !Utilities.IsItemInExternalSharedInFolder(base.UserContext, calendarItemBase));
                        }
                        if (!flag2)
                        {
                            ExTraceGlobals.CalendarTracer.TraceDebug(0L, "User have no rights to remove item from source folder or create new item in target folder.");
                            this.Writer.Write("<div id=divOp _sOp=\"np\"></div>");
                        }
                        else
                        {
                            if (flag)
                            {
                                calendarItemBase.CopyToFolder(mailboxSession, storeObjectId);
                            }
                            else
                            {
                                calendarItemBase.MoveToFolder(mailboxSession, storeObjectId);
                            }
                            this.Writer.Write("<div id=divOp _sOp=\"rf\"></div>");
                            TargetFolderMRU.AddAndGetFolders(owaStoreObjectId2, base.UserContext);
                        }
                    }
                }
            }
            catch (CalendarItemExistsException)
            {
                this.RenderCopyMoveFail(-95861205);
            }
            catch (FutureMeetingException)
            {
                this.RenderCopyMoveFail(((bool)base.GetParameter("rcr")) ? 225743507 : -989731968);
            }
            catch (PrimaryCalendarFolderException)
            {
                this.RenderCopyMoveFail(-812685732);
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.CalendarDataTracer.TraceDebug((long)this.GetHashCode(), "Calendar item could not be found");
                throw;
            }
            finally
            {
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                    calendarItemBase = null;
                }
            }
        }