예제 #1
0
        internal static CalendarItemBase FindMatchingItem(MailboxSession session, CalendarFolder calendarFolder, CalendarItemType itemType, byte[] globalId, ref string errorString)
        {
            VersionedId calendarItemId = calendarFolder.GetCalendarItemId(globalId);

            if (calendarItemId == null)
            {
                errorString = string.Format("FindMatchingItem: Could not find calendar item, itemId is null. ", new object[0]);
                return(null);
            }
            CalendarItemBase result;

            try
            {
                result = CalendarItemBase.Bind(session, calendarItemId, CalendarQuery.CalendarQueryProps);
            }
            catch (ObjectNotFoundException ex)
            {
                errorString = string.Format("[{0}(UTC)] FindMatchingItem: Could not find calendar item, exception = {1}. ", ExDateTime.UtcNow, ex.GetType());
                result      = null;
            }
            catch (ArgumentException ex2)
            {
                errorString = string.Format("[{0}(UTC)] FindMatchingItem: Could not bind to item as CalendarItemBase, exception = {1}. ", ExDateTime.UtcNow, ex2.GetType());
                result      = null;
            }
            return(result);
        }
예제 #2
0
 private MeetingInquiryMessage.ExistingCalendarItemError CheckExistingCalendarItem(CalendarFolder calFolder, out VersionedId existingCalendarItemId)
 {
     MeetingInquiryMessage.ExistingCalendarItemError result = MeetingInquiryMessage.ExistingCalendarItemError.None;
     existingCalendarItemId = calFolder.GetCalendarItemId(this.GlobalObjectId.CleanGlobalObjectIdBytes);
     if (existingCalendarItemId != null)
     {
         if (this.GlobalObjectId.IsCleanGlobalObjectId)
         {
             ExTraceGlobals.MeetingMessageTracer.TraceDebug <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::CheckExistingCalendarItem. The inquired meeting (GOID: {0}) already exists in the calendar folder of the user ({1})", this.GlobalObjectId, this.MailboxSession.DisplayName);
             result = MeetingInquiryMessage.ExistingCalendarItemError.MeetingAlreadyExists;
         }
         else
         {
             result = MeetingInquiryMessage.ExistingCalendarItemError.OccurrenceInquiry;
         }
     }
     return(result);
 }
 public VersionedId FetchCorrelatedItemId(CalendarFolder calendarFolder, bool shouldDetectDuplicateIds, out IEnumerable <VersionedId> detectedDuplicatesIds)
 {
     if (!shouldDetectDuplicateIds && this.correlatedItemId != null)
     {
         detectedDuplicatesIds = null;
         return(this.correlatedItemId);
     }
     byte[] array = base.TryGetProperty(InternalSchema.GlobalObjectId) as byte[];
     if (array == null)
     {
         throw new CorruptDataException(ServerStrings.ExInvalidGlobalObjectId);
     }
     if (!(calendarFolder.Session is MailboxSession))
     {
         throw new NotSupportedException();
     }
     this.correlatedItemId            = calendarFolder.GetCalendarItemId(array, shouldDetectDuplicateIds, out detectedDuplicatesIds);
     this.fetchCorrelatedItemIdCalled = true;
     return(this.correlatedItemId);
 }
예제 #4
0
        private MeetingInquiryAction TryReviveMeeting(CalendarItemBase deletedVersion)
        {
            bool flag = false;

            if (this.GlobalObjectId.IsCleanGlobalObjectId)
            {
                using (CalendarItemBase calendarItemBase = (CalendarItemBase)Microsoft.Exchange.Data.Storage.Item.CloneItem(base.Session, this.MailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar), deletedVersion, false, true, null))
                {
                    calendarItemBase.LocationIdentifierHelperInstance.SetLocationIdentifier(43287U, LastChangeAction.Resurrect);
                    calendarItemBase.Save(SaveMode.NoConflictResolution);
                    flag = true;
                    goto IL_207;
                }
            }
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(this.MailboxSession, DefaultFolderType.Calendar))
            {
                StoreId calendarItemId = calendarFolder.GetCalendarItemId(this.GlobalObjectId.CleanGlobalObjectIdBytes);
                if (calendarItemId != null)
                {
                    using (CalendarItem calendarItem = CalendarItem.Bind(this.MailboxSession, calendarItemId))
                    {
                        if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster)
                        {
                            try
                            {
                                calendarItem.RecoverDeletedOccurrenceByDateId(this.GlobalObjectId.Date);
                                calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(59671U, LastChangeAction.Resurrect);
                                ConflictResolutionResult conflictResolutionResult = calendarItem.Save(SaveMode.ResolveConflicts);
                                if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict)
                                {
                                    ExTraceGlobals.MeetingMessageTracer.TraceError <string, GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::ReviveDeletedVersionIfNoCancellation for Mailbox {0} and GOID {1} hit a save conflict.", this.MailboxSession.DisplayName, this.GlobalObjectId);
                                    throw new SaveConflictException(ServerStrings.ExSaveFailedBecauseOfConflicts(base.InternalObjectId), conflictResolutionResult);
                                }
                                flag = true;
                            }
                            catch (OccurrenceNotFoundException)
                            {
                                ExTraceGlobals.MeetingMessageTracer.TraceError <string, GlobalObjectId, ExDateTime>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::ReviveDeletedVersionIfNoCancellation for Mailbox {0} and GOID {1}. There's no occurrence on {2}", this.MailboxSession.DisplayName, this.GlobalObjectId, this.GlobalObjectId.Date);
                            }
                            catch (ObjectValidationException ex)
                            {
                                if (ex.Errors.Count != 1 || (!(ex.Errors[0].Constraint is OrganizerPropertiesConstraint) && !(ex.Errors[0].Constraint is CalendarOriginatorIdConstraint)))
                                {
                                    throw;
                                }
                                ExTraceGlobals.MeetingMessageTracer.TraceError <string, GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::ReviveDeletedVersionIfNoCancellation for Mailbox {0} and GOID {1}. Object validation failed : {2}", this.MailboxSession.DisplayName, this.GlobalObjectId, ex.Message);
                            }
                        }
                        goto IL_1FB;
                    }
                }
                ExTraceGlobals.MeetingMessageTracer.TraceError <string, byte[]>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::ReviveDeletedVersionIfNoCancellation for Mailbox {0}. Couldn't find calendar item with CGOID {1}", this.MailboxSession.DisplayName, this.GlobalObjectId.CleanGlobalObjectIdBytes);
                IL_1FB :;
            }
            IL_207 :
            if (!flag)
            {
                return(MeetingInquiryAction.FailedToRevive);
            }
            return(MeetingInquiryAction.ReviveMeeting);
        }
예제 #5
0
        public CalendarItemBase GetCorrelatedItem(GlobalObjectId globalObjectId)
        {
            MailboxSession mailboxSession  = (MailboxSession)base.Session;
            StoreObjectId  defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar);

            if (defaultFolderId == null)
            {
                ExTraceGlobals.MeetingMessageTracer.Information((long)this.GetHashCode(), "ReminderMessage::GetCorrelatedItem. Calendar folder is not found. We treat it as correlated calendar item has been deleted.");
                return(null);
            }
            CalendarItemBase calendarItemBase = null;
            bool             flag             = false;

            try
            {
                using (CalendarFolder calendarFolder = CalendarFolder.Bind(mailboxSession, defaultFolderId))
                {
                    int i = 0;
                    while (i < 2)
                    {
                        ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, int>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Retrying fetch count={1}", globalObjectId, i);
                        this.correlatedItemId = calendarFolder.GetCalendarItemId(globalObjectId.Bytes);
                        if (this.correlatedItemId != null)
                        {
                            try
                            {
                                calendarItemBase = CalendarItemBase.Bind(mailboxSession, this.correlatedItemId.ObjectId);
                            }
                            catch (OccurrenceNotFoundException arg)
                            {
                                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, OccurrenceNotFoundException>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Occurrence not found. Exception: {1}", globalObjectId, arg);
                                this.correlatedItemId = null;
                                break;
                            }
                            catch (ObjectNotFoundException arg2)
                            {
                                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, ObjectNotFoundException>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Calendar item id was found but calendar item got deleted. Exception: {1}", globalObjectId, arg2);
                                this.correlatedItemId = null;
                                goto IL_106;
                            }
                            catch (WrongObjectTypeException innerException)
                            {
                                throw new CorruptDataException(ServerStrings.ExNonCalendarItemReturned("Unknown"), innerException);
                            }
                            catch (ArgumentException innerException2)
                            {
                                throw new CorruptDataException(ServerStrings.ExNonCalendarItemReturned("Unknown"), innerException2);
                            }
                            goto IL_FF;
IL_106:
                            i++;
                            continue;
IL_FF:
                            flag = true;
                            return(calendarItemBase);
                        }
                        break;
                    }
                }
            }
            finally
            {
                if (!flag)
                {
                    Util.DisposeIfPresent(calendarItemBase);
                }
            }
            return(null);
        }
        // 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);
        }