Example #1
0
        public static bool?IsOrganizer(MailboxSession mailboxSession, GlobalObjectId globalObjectId, out string subject, out string organizerEmailAddress)
        {
            ExTraceGlobals.SyncTracer.TraceDebug <GlobalObjectId, bool>(0L, "[MeetingOrganizerValidatior.IsOrganizer] Search IsOrganizer GOID: {0}, IsCleanGoID: {1}", globalObjectId, globalObjectId.IsCleanGlobalObjectId);
            subject = null;
            organizerEmailAddress = null;
            if (!globalObjectId.IsCleanGlobalObjectId)
            {
                globalObjectId = new GlobalObjectId(globalObjectId.CleanGlobalObjectIdBytes);
            }
            bool value = false;
            bool flag  = MeetingOrganizerValidator.SearchForCalendarItem(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar), globalObjectId, out value, out subject, out organizerEmailAddress);

            if (!flag)
            {
                ExTraceGlobals.SyncTracer.TraceDebug(0L, "[MeetingOrganizerValidatior.IsOrganizer] Correlated CalendarItem not found in default calendar folder.  Searching in calendar sub folders...");
                using (Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.Calendar))
                {
                    using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, MeetingOrganizerValidator.FetchProperties))
                    {
                        bool flag2 = true;
                        while (flag2)
                        {
                            object[][] rows = queryResult.GetRows(10000);
                            if (rows == null || rows.Length == 0)
                            {
                                break;
                            }
                            for (int i = 0; i < rows.Length; i++)
                            {
                                VersionedId   versionedId         = rows[i][0] as VersionedId;
                                StoreObjectId storeObjectId       = (versionedId != null) ? versionedId.ObjectId : null;
                                int?          num                 = rows[i][1] as int?;
                                int           extendedFolderFlags = (num != null) ? num.Value : 0;
                                if (storeObjectId == null || CalendarFolder.IsCrossOrgShareFolder(extendedFolderFlags) || CalendarFolder.IsInternetCalendar(extendedFolderFlags))
                                {
                                    ExTraceGlobals.SyncTracer.TraceDebug <StoreObjectId>(0L, "[MeetingOrganizerValidator.IsOrganizer] Skipping Calendar '{0}' as it is either a sharing folder or iCal folder", storeObjectId);
                                }
                                else
                                {
                                    flag = MeetingOrganizerValidator.SearchForCalendarItem(mailboxSession, storeObjectId, globalObjectId, out value, out subject, out organizerEmailAddress);
                                    if (flag)
                                    {
                                        flag2 = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    goto IL_16D;
                }
            }
            ExTraceGlobals.SyncTracer.TraceDebug(0L, "[MeetingOrganizerValidatior.IsOrganizer] Correlated CalendarItem found in default calendar folder");
IL_16D:
            if (!flag)
            {
                return(null);
            }
            return(new bool?(value));
        }
Example #2
0
        private static void QueryRelatedItems(Folder folder, GlobalObjectId globalObjectId, ICollection <PropertyDefinition> propertySet, Func <PropertyBag, bool> matchFoundAction, bool fetchResultsInReverseChronologicalOrder, bool sameGoidOnly, string[] itemClassFilter, ExDateTime?startDate, ExDateTime?endDate)
        {
            Func <PropertyBag, bool> readRow = delegate(PropertyBag propertyBag)
            {
                if (itemClassFilter != null)
                {
                    string classFromPropertyBag = propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass);
                    if (!itemClassFilter.Any((string itemClass) => ObjectClass.IsOfClass(classFromPropertyBag, itemClass)))
                    {
                        return(false);
                    }
                }
                byte[] goidBytes = CalendarCorrelationMatch.GetGoidBytes(propertyBag);
                bool   flag      = goidBytes != null && (sameGoidOnly ? GlobalObjectId.Equals(globalObjectId, new GlobalObjectId(goidBytes)) : GlobalObjectId.CompareCleanGlobalObjectIds(globalObjectId.Bytes, goidBytes));
                if (flag)
                {
                    flag = CalendarCorrelationMatch.MatchOriginalLastModifiedTime(propertyBag, startDate, endDate);
                }
                if (flag)
                {
                    flag = matchFoundAction(propertyBag);
                }
                return(flag);
            };
            QueryFilter queryFilter = sameGoidOnly ? new ComparisonFilter(ComparisonOperator.Equal, InternalSchema.GlobalObjectId, globalObjectId.Bytes) : new ComparisonFilter(ComparisonOperator.Equal, InternalSchema.CleanGlobalObjectId, globalObjectId.CleanGlobalObjectIdBytes);

            ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, QueryFilter>(0L, "CalendarCorrelationMatch.QueryRelatedItems: GOID={0}. QueryFilter = {1}.", globalObjectId, queryFilter);
            SortBy[] sortBy;
            if (itemClassFilter != null)
            {
                if (sameGoidOnly)
                {
                    sortBy = (fetchResultsInReverseChronologicalOrder ? CalendarCorrelationMatch.goidRestrictedRelatedItemsByClassChronologicalSortOrder : CalendarCorrelationMatch.goidRestrictedRelatedItemsByClassSortOrder);
                }
                else
                {
                    sortBy = (fetchResultsInReverseChronologicalOrder ? CalendarCorrelationMatch.relatedItemsByClassChronologicalSortOrder : CalendarCorrelationMatch.relatedItemsByClassSortOrder);
                }
                QueryFilter[] array = new QueryFilter[itemClassFilter.Length];
                for (int i = 0; i < itemClassFilter.Length; i++)
                {
                    array[i] = new TextFilter(InternalSchema.ItemClass, itemClassFilter[i], MatchOptions.Prefix, MatchFlags.IgnoreCase);
                }
                queryFilter = new AndFilter(new QueryFilter[]
                {
                    queryFilter,
                    new OrFilter(array)
                });
            }
            else if (sameGoidOnly)
            {
                sortBy = (fetchResultsInReverseChronologicalOrder ? CalendarCorrelationMatch.goidRestrictedRelatedItemsChronologicalSortOrder : CalendarCorrelationMatch.goidRestrictedRelatedItemsSortOrder);
            }
            else
            {
                sortBy = (fetchResultsInReverseChronologicalOrder ? CalendarCorrelationMatch.relatedItemsChronologicalSortOrder : CalendarCorrelationMatch.relatedItemsSortOrder);
            }
            CalendarCorrelationMatch.QueryItemsUsingView(folder, sortBy, queryFilter, propertySet, readRow);
        }
Example #3
0
 private object[] FindItemSnapshotByGoid(GlobalObjectId goid, bool shouldCheckCleanGoid)
 {
     ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "CalendarImporter::FindItemSnapshotByGoid. Looking for matched item of GOID:{0}.", GlobalObjectId.ByteArrayToHexString(goid.Bytes));
     object[] array = this.itemSnapshots.FirstOrDefault((object[] item) => Util.ValueEquals(goid.Bytes, item[this.QueryIndexGoid] as byte[]));
     if (shouldCheckCleanGoid && array == null && !goid.IsCleanGlobalObjectId)
     {
         ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "CalendarImporter::FindItemSnapshotByGoid. No match found according to goid then check the clean GOID:{0}.", GlobalObjectId.ByteArrayToHexString(goid.CleanGlobalObjectIdBytes));
         array = this.itemSnapshots.FirstOrDefault((object[] item) => Util.ValueEquals(goid.CleanGlobalObjectIdBytes, item[this.QueryIndexGoid] as byte[]) && true.Equals(item[this.QueryIndexRecurring]));
     }
     return(array);
 }
        public void Trace(ConversationIndex index)
        {
            Util.ThrowOnNullArgument(index, "index");
            StringBuilder stringBuilder = new StringBuilder(0);

            stringBuilder.Append("[");
            stringBuilder.Append(string.Format("{0}={1}", "CID", index.Guid));
            stringBuilder.Append(";");
            stringBuilder.Append(string.Format("{0}={1}", "IDXHEAD", GlobalObjectId.ByteArrayToHexString(index.Header)));
            stringBuilder.Append(";");
            stringBuilder.Append(string.Format("{0}={1}", "IDXCOUNT", index.Components.Count));
            stringBuilder.Append("]");
            this.Trace("II", stringBuilder.ToString());
        }
Example #5
0
        private CalendarCorrelationMatch(PropertyBag propertyBag, GlobalObjectId globalObjectId)
        {
            this.Id         = propertyBag.GetValueOrDefault <VersionedId>(InternalSchema.ItemId);
            this.documentId = propertyBag.GetValueOrDefault <int>(InternalSchema.DocumentId, int.MinValue);
            byte[] goidBytes = CalendarCorrelationMatch.GetGoidBytes(propertyBag);
            this.goid = ((goidBytes == null) ? null : new GlobalObjectId(goidBytes));
            object obj = propertyBag.TryGetProperty(InternalSchema.AppointmentRecurrenceBlob);

            this.isRecurringMaster         = (obj is byte[] || PropertyError.IsPropertyValueTooBig(obj));
            this.appointmentSequenceNumber = propertyBag.GetValueAsNullable <int>(InternalSchema.AppointmentSequenceNumber);
            this.lastModifiedTime          = propertyBag.GetValueAsNullable <ExDateTime>(InternalSchema.LastModifiedTime);
            this.ownerCriticalChangeTime   = propertyBag.GetValueAsNullable <ExDateTime>(InternalSchema.OwnerCriticalChangeTime);
            this.IsCorrelated = this.CheckIsCorrelated(globalObjectId, out this.isMasterMatchingTheOccurrence);
            this.properties   = propertyBag;
        }
Example #6
0
        internal VersionedId GetCorrelatedId(GlobalObjectId globalObjectId)
        {
            VersionedId result;

            if (this.isMasterMatchingTheOccurrence)
            {
                OccurrenceStoreObjectId itemId = new OccurrenceStoreObjectId(this.Id.ObjectId.ProviderLevelItemId, globalObjectId.Date);
                result = new VersionedId(itemId, this.Id.ChangeKeyAsByteArray());
            }
            else
            {
                result = this.Id;
            }
            return(result);
        }
Example #7
0
        private void UpdateItemSnapshots(GlobalObjectId goid, VersionedId newItemId, Item promotedItem)
        {
            object[] array = this.FindItemSnapshotByGoid(goid, false);
            bool     flag  = array == null;

            if (flag)
            {
                array = new object[InternetCalendarSchema.ImportQuery.Length];
                this.itemSnapshots.Add(array);
            }
            for (int i = 0; i < InternetCalendarSchema.ImportQuery.Length; i++)
            {
                array[i] = promotedItem.TryGetProperty(InternetCalendarSchema.ImportQuery[i]);
            }
            array[this.QueryIndexId] = newItemId;
        }
Example #8
0
        public CalendarItemBase GetCachedCorrelatedOccurrence()
        {
            if (!(base.Session is MailboxSession))
            {
                return(null);
            }
            if (this.cachedCorrelatedOccurrence != null)
            {
                return(this.cachedCorrelatedOccurrence);
            }
            GlobalObjectId globalObjectId = this.ReminderOccurrenceGlobalObjectId;

            if (globalObjectId == null)
            {
                globalObjectId = this.ReminderItemGlobalObjectId;
            }
            this.cachedCorrelatedOccurrence = this.GetCorrelatedItem(globalObjectId);
            return(this.cachedCorrelatedOccurrence);
        }
Example #9
0
        private bool CheckIsCorrelated(GlobalObjectId globalObjectId, out bool isOccurrenceMatchedToMaster)
        {
            bool result = false;

            isOccurrenceMatchedToMaster = false;
            if (this.Id != null && this.Id.ObjectId.ObjectType == StoreObjectType.CalendarItem)
            {
                if (globalObjectId.Date == this.goid.Date)
                {
                    result = true;
                }
                else if (!globalObjectId.IsCleanGlobalObjectId && this.goid.IsCleanGlobalObjectId && this.isRecurringMaster)
                {
                    result = true;
                    isOccurrenceMatchedToMaster = true;
                }
            }
            else if (this.Id != null && this.Id.ObjectId.ObjectType == StoreObjectType.CalendarItemSeries)
            {
                result = this.goid.Equals(globalObjectId);
            }
            return(result);
        }
Example #10
0
        private CalendarItemBase ConvertToCalendarItem(GlobalObjectId goid, Item promotedItem, object[] matchedItem)
        {
            CalendarItemBase calendarItemBase = null;
            bool             itemCreated      = true;
            bool             flag             = false;

            promotedItem[InternalSchema.BodyTag] = promotedItem.Body.CalculateBodyTag();
            try
            {
                if (matchedItem == null)
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, object, object>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. No matched existing object found, then create a new one. GOID:{0}; Subject:{1}; StartTime:{2}.", goid, promotedItem.TryGetProperty(ItemSchema.Subject), promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime));
                    calendarItemBase = CalendarItem.Create(this.session, this.folder.Id);
                }
                else if (this.IsMeetingChanged(goid, promotedItem, matchedItem))
                {
                    StoreObjectId storeObjectId = ((VersionedId)matchedItem[this.QueryIndexId]).ObjectId;
                    if (!goid.IsCleanGlobalObjectId && true.Equals(matchedItem[this.QueryIndexRecurring]))
                    {
                        storeObjectId = new OccurrenceStoreObjectId(storeObjectId.ProviderLevelItemId, goid.Date);
                    }
                    try
                    {
                        calendarItemBase = CalendarItemBase.Bind(this.session, storeObjectId);
                        calendarItemBase.OpenAsReadWrite();
                        itemCreated = false;
                    }
                    catch (OccurrenceNotFoundException)
                    {
                        ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Tried to bind to an occurrence not existing", storeObjectId.ToString());
                        calendarItemBase = CalendarItem.Create(this.session, this.folder.Id);
                    }
                }
                if (calendarItemBase != null)
                {
                    try
                    {
                        this.CopyToCalendarItem(promotedItem, calendarItemBase, itemCreated);
                        flag = true;
                        goto IL_154;
                    }
                    catch (RecurrenceException arg)
                    {
                        ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, RecurrenceException>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to copy the iCal to a calendarItem for ID:{0}, Exception = {1}", goid, arg);
                        flag = false;
                        goto IL_154;
                    }
                    catch (AttachmentExceededException arg2)
                    {
                        ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, AttachmentExceededException>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to copy the iCal to a calendarItem for ID:{0}, Exception = {1}", goid, arg2);
                        flag = false;
                        goto IL_154;
                    }
                }
                flag = true;
                IL_154 :;
            }
            finally
            {
                if (!flag)
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to convert to XSO calendar item. GOID:{0}.", goid);
                    this.results.RawErrors.Add(ServerStrings.SyncFailedToCreateNewItemOrBindToExistingOne);
                    Util.DisposeIfPresent(calendarItemBase);
                    calendarItemBase = null;
                }
            }
            return(calendarItemBase);
        }
 private void AdjustOccurrenceColumnsForExpansion(object[] occurrence, PropertyDefinition[] columns, OccurrenceInfo occurrenceInfo, int codePage, byte[] createdTimeZoneBlobCache, bool isException)
 {
     for (int i = 0; i < columns.Length; i++)
     {
         PropertyDefinition propertyDefinition = columns[i];
         if (propertyDefinition.Equals(InternalSchema.ItemId))
         {
             occurrence[i] = occurrenceInfo.VersionedId;
         }
         else if (propertyDefinition.Equals(InternalSchema.IsRecurring))
         {
             occurrence[i] = true;
         }
         else if (propertyDefinition.Equals(InternalSchema.IsException))
         {
             occurrence[i] = isException;
         }
         else if (propertyDefinition.Equals(InternalSchema.AppointmentRecurring))
         {
             occurrence[i] = false;
         }
         else if (propertyDefinition.Equals(InternalSchema.AppointmentRecurrenceBlob))
         {
             occurrence[i] = new PropertyError(columns[i], PropertyErrorCode.NotFound);
         }
         else if (propertyDefinition.Equals(InternalSchema.MapiStartTime) || propertyDefinition.Equals(InternalSchema.MapiPRStartDate))
         {
             occurrence[i] = occurrenceInfo.StartTime;
         }
         else if (propertyDefinition.Equals(InternalSchema.MapiEndTime) || propertyDefinition.Equals(InternalSchema.MapiPREndDate))
         {
             occurrence[i] = occurrenceInfo.EndTime;
         }
         else if (propertyDefinition.Equals(InternalSchema.TimeZoneDefinitionStart) || propertyDefinition.Equals(InternalSchema.TimeZoneDefinitionEnd))
         {
             if (occurrence[i] is PropertyError)
             {
                 occurrence[i] = createdTimeZoneBlobCache;
             }
         }
         else if (propertyDefinition.Equals(InternalSchema.ItemClass))
         {
             occurrence[i] = (isException ? (occurrence[i] = "IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}") : (occurrence[i] = "IPM.Appointment.Occurrence"));
         }
         else if (propertyDefinition.Equals(InternalSchema.GlobalObjectId))
         {
             object obj   = occurrence[Array.IndexOf <PropertyDefinition>(columns, InternalSchema.CleanGlobalObjectId)];
             byte[] array = obj as byte[];
             if (array != null)
             {
                 occurrence[i] = new GlobalObjectId(array)
                 {
                     Date = ((OccurrenceStoreObjectId)occurrenceInfo.VersionedId.ObjectId).OccurrenceId
                 }.Bytes;
             }
             else
             {
                 PropertyError propertyError = obj as PropertyError;
                 occurrence[i] = new PropertyError(InternalSchema.GlobalObjectId, propertyError.PropertyErrorCode, propertyError.PropertyErrorDescription);
             }
         }
         else if (propertyDefinition.Equals(InternalSchema.Codepage))
         {
             occurrence[i] = codePage;
         }
     }
 }
Example #12
0
            public void AddMatch(GlobalObjectId globalObjectId, PropertyBag propertyBag)
            {
                CalendarCorrelationMatch matchData = new CalendarCorrelationMatch(propertyBag, globalObjectId);

                this.UpdateMatchCollection(matchData);
            }
Example #13
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);
        }
Example #14
0
 public static bool WouldTryToRepairIfMissing(CalendarVersionStoreGateway cvsGateway, GlobalObjectId globalObjectId, MailboxSession session, byte[] calendarFolderId, out MeetingInquiryAction predictedAction)
 {
     return(MeetingInquiryMessage.WouldTryToRepairIfMissing(cvsGateway, globalObjectId, session, null, false, calendarFolderId, out predictedAction));
 }
Example #15
0
 public static void QueryRelatedItems(Folder folder, GlobalObjectId globalObjectId, string schemaKey, ICollection <PropertyDefinition> propertiesToFetch, bool useCachedPropertySetIfPresent, Func <PropertyBag, bool> matchFoundAction, bool fetchResultsInReverseChronologicalOrder, bool sameGoidOnly, string[] itemClassFilter, ExDateTime?startDate, ExDateTime?endDate)
 {
     Util.ThrowOnNullArgument(matchFoundAction, "matchFoundAction");
     CalendarCorrelationMatch.QueryRelatedItems(folder, globalObjectId, CalendarCorrelationMatch.GetPropertySet(schemaKey, propertiesToFetch, useCachedPropertySetIfPresent), matchFoundAction, fetchResultsInReverseChronologicalOrder, sameGoidOnly, itemClassFilter, startDate, endDate);
 }
Example #16
0
 internal static List <CalendarCorrelationMatch> FindMatches(CalendarFolder folder, GlobalObjectId globalObjectId, ICollection <PropertyDefinition> additionalProperties = null)
 {
     CalendarCorrelationMatch.ValidateAdditionalProperties(additionalProperties);
     CalendarCorrelationMatch.CalendarCorrelationMatchCollection matchCollection = new CalendarCorrelationMatch.CalendarCorrelationMatchCollection();
     CalendarCorrelationMatch.QueryRelatedItems(folder, globalObjectId, CalendarCorrelationMatch.GetPropertySet(CalendarCorrelationMatch.BuildSchemaKey(additionalProperties), additionalProperties, true), delegate(PropertyBag match)
     {
         matchCollection.AddMatch(globalObjectId, match);
         return(true);
     }, false, false, null, null, null);
     return(matchCollection.FoundMatches);
 }
Example #17
0
        private static bool WouldTryToRepairIfMissing(CalendarVersionStoreGateway cvsGateway, GlobalObjectId globalObjectId, MailboxSession session, MeetingInquiryMessage message, bool performRepair, byte[] calendarFolderId, out MeetingInquiryAction predictedAction)
        {
            VersionedId versionedId;
            bool        result;

            if (MeetingInquiryMessage.TryGetCancelledVersionIdFromCvs(cvsGateway, globalObjectId, session, calendarFolderId, out versionedId))
            {
                if (performRepair)
                {
                    message.LocationIdentifierHelperInstance.SetLocationIdentifier(47383U, LastChangeAction.SendMeetingCancellations);
                    message.SendCancellationBasedOnFoundIntent(versionedId);
                }
                predictedAction = MeetingInquiryAction.SendCancellation;
                result          = true;
            }
            else
            {
                if (versionedId != null)
                {
                    using (CalendarItemBase calendarItemBase = CalendarItemBase.Bind(session, versionedId))
                    {
                        predictedAction = MeetingInquiryMessage.GetReviveAction(cvsGateway, session, calendarItemBase);
                        if (predictedAction == MeetingInquiryAction.ReviveMeeting)
                        {
                            if (performRepair)
                            {
                                predictedAction = message.TryReviveMeeting(calendarItemBase);
                            }
                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                        return(result);
                    }
                }
                ExTraceGlobals.MeetingMessageTracer.TraceDebug <string, GlobalObjectId>((long)session.GetHashCode(), "Storage.MeetingInquiryMessage::Process. Couldn't find deletion on mailbox {0}. Skipping GOID {1}", session.DisplayName, globalObjectId);
                predictedAction = MeetingInquiryAction.DeletedVersionNotFound;
                result          = false;
            }
            return(result);
        }
Example #18
0
 public static bool Merge(StoreSession session, CalendarItem calendarItem, GlobalObjectId globalObjectId, InternalRecurrence originalRecurrence, InternalRecurrence newRecurrence)
 {
     return(new RecurrenceBlobMerger(session, calendarItem, globalObjectId, originalRecurrence, newRecurrence).Merge());
 }
Example #19
0
        private static bool TryGetCancelledVersionIdFromCvs(CalendarVersionStoreGateway cvsGateway, GlobalObjectId globalObjectId, MailboxSession session, byte[] calendarFolderId, out VersionedId deletedVersionId)
        {
            ClientIntentFlags clientIntentFlags;
            ClientIntentQuery clientIntentQuery;

            if (globalObjectId.IsCleanGlobalObjectId)
            {
                clientIntentFlags = ClientIntentFlags.MeetingCanceled;
                ICalendarItemStateDefinition deletedFromFolderStateDefinition = CompositeCalendarItemStateDefinition.GetDeletedFromFolderStateDefinition(calendarFolderId);
                clientIntentQuery = new ItemDeletionClientIntentQuery(globalObjectId, deletedFromFolderStateDefinition);
            }
            else
            {
                clientIntentFlags = ClientIntentFlags.MeetingExceptionCanceled;
                ICalendarItemStateDefinition targetState = new DeletedOccurrenceCalendarItemStateDefinition(globalObjectId.Date, false);
                clientIntentQuery = new NonTransitionalClientIntentQuery(globalObjectId, targetState);
            }
            ClientIntentQuery.QueryResult queryResult = clientIntentQuery.Execute(session, cvsGateway);
            deletedVersionId = queryResult.SourceVersionId;
            return(ClientIntentQuery.CheckDesiredClientIntent(queryResult.Intent, new ClientIntentFlags[]
            {
                clientIntentFlags
            }));
        }
Example #20
0
        private void ImportItem(Item promotedItem)
        {
            GlobalObjectId globalObjectId = new GlobalObjectId(promotedItem);

            object[] array = this.FindItemSnapshotByGoid(globalObjectId, true);
            if (array != null)
            {
                StoreObjectId objectId = ((VersionedId)array[this.QueryIndexId]).ObjectId;
                this.RemoveItemFromDeletionList(objectId);
            }
            CalendarItemBase calendarItemBase = this.ConvertToCalendarItem(globalObjectId, promotedItem, array);

            if (calendarItemBase != null)
            {
                using (calendarItemBase)
                {
                    if (!this.IsInImportWindow(calendarItemBase))
                    {
                        ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "CalendarImporter::ImportItem. Item is outside of the import window. Ignoring. GOID:{0} WindowStart:{1} WindowEnd:{2}.calItem.StartTime:{2} calItem.EndTime:{3}", new object[]
                        {
                            globalObjectId,
                            this.importWindowStart,
                            this.importWindowEnd,
                            calendarItemBase.StartTime,
                            calendarItemBase.EndTime
                        });
                    }
                    else
                    {
                        this.PostProcessing(calendarItemBase);
                        if (calendarItemBase.Validate().Length != 0)
                        {
                            ExTraceGlobals.SharingTracer.TraceDebug <VersionedId>((long)this.GetHashCode(), "CalendarImporter::ImportItems. Validation error for item ID:{0}", promotedItem.Id);
                            this.results.RawErrors.Add(ServerStrings.ValidationFailureAfterPromotion(calendarItemBase.GlobalObjectId.Uid));
                        }
                        else
                        {
                            try
                            {
                                ConflictResolutionResult conflictResolutionResult = calendarItemBase.Save(SaveMode.ResolveConflicts);
                                if (conflictResolutionResult != ConflictResolutionResult.Success)
                                {
                                    ExTraceGlobals.SharingTracer.TraceDebug <VersionedId>((long)this.GetHashCode(), "CalendarImporter::ImportItems. Failed to save item for ID:{0}", calendarItemBase.Id);
                                    this.results.RawErrors.Add(ServerStrings.SaveFailureAfterPromotion(calendarItemBase.GlobalObjectId.Uid));
                                }
                                else
                                {
                                    ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId>((long)this.GetHashCode(), "CalendarImporter::ImportItem. Saved item. GOID:{0}.", globalObjectId);
                                    this.results.Increment(true);
                                    VersionedId calendarItemId = this.folder.GetCalendarItemId(globalObjectId.Bytes);
                                    if (calendarItemId != null)
                                    {
                                        this.UpdateItemSnapshots(globalObjectId, calendarItemId, promotedItem);
                                    }
                                }
                            }
                            catch (OccurrenceCrossingBoundaryException arg)
                            {
                                ExTraceGlobals.SharingTracer.TraceDebug <VersionedId, OccurrenceCrossingBoundaryException>((long)this.GetHashCode(), "CalendarImporter::ImportItems. Failed to save item for ID:{0}, Exception = {1}", calendarItemBase.Id, arg);
                                this.results.RawErrors.Add(ServerStrings.SaveFailureAfterPromotion(calendarItemBase.GlobalObjectId.Uid));
                            }
                            catch (CorruptDataException arg2)
                            {
                                ExTraceGlobals.SharingTracer.TraceDebug <VersionedId, CorruptDataException>((long)this.GetHashCode(), "CalendarImporter::ImportItems. Got a corrupt data exception during Save for item for ID:{0}, Exception = {1}", calendarItemBase.Id, arg2);
                                this.results.RawErrors.Add(ServerStrings.SaveFailureAfterPromotion(calendarItemBase.GlobalObjectId.Uid));
                            }
                            catch (VirusException arg3)
                            {
                                ExTraceGlobals.SharingTracer.TraceDebug <VersionedId, VirusException>((long)this.GetHashCode(), "CalendarImporter::ImportItems. Got a virus detected exception during Save for item for ID:{0}, Exception = {1}", calendarItemBase.Id, arg3);
                                this.results.RawErrors.Add(ServerStrings.SaveFailureAfterPromotion(calendarItemBase.GlobalObjectId.Uid));
                            }
                            catch (RecurrenceException arg4)
                            {
                                ExTraceGlobals.SharingTracer.TraceDebug <VersionedId, RecurrenceException>((long)this.GetHashCode(), "CalendarImporter::ImportItems. Got a recurrence exception during Save for item for ID:{0}, Exception = {1}", calendarItemBase.Id, arg4);
                                this.results.RawErrors.Add(ServerStrings.SaveFailureAfterPromotion(calendarItemBase.GlobalObjectId.Uid));
                            }
                        }
                    }
                    return;
                }
            }
            ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId>((long)this.GetHashCode(), "CalendarImporter::ImportItem. No changes detected on input item. GOID:{0}.", globalObjectId);
            this.results.Increment(false);
        }
Example #21
0
        private static bool SearchForCalendarItem(MailboxSession session, StoreObjectId folderId, GlobalObjectId globalObjectId, out bool isOrganizer, out string subject, out string organizerEmailAddress)
        {
            StoreId arg = null;

            isOrganizer           = false;
            subject               = null;
            organizerEmailAddress = null;
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, folderId, null))
            {
                PropertyBag calendarItemProperties = calendarFolder.GetCalendarItemProperties(globalObjectId.Bytes, MeetingOrganizerValidator.CalendarOrganizerProperties);
                if (calendarItemProperties == null)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Related Calendar Item not found in calendar folder : '{0}'", calendarFolder.DisplayName);
                    return(false);
                }
                arg = calendarItemProperties.GetValueOrDefault <VersionedId>(InternalSchema.ItemId);
                string valueOrDefault = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.ItemClass);
                AppointmentStateFlags valueOrDefault2 = calendarItemProperties.GetValueOrDefault <AppointmentStateFlags>(InternalSchema.AppointmentStateInternal);
                isOrganizer           = IsOrganizerProperty.GetForCalendarItem(valueOrDefault, valueOrDefault2);
                subject               = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.MapiSubject);
                organizerEmailAddress = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.SentRepresentingEmailAddress);
            }
            ExTraceGlobals.SyncTracer.TraceDebug <StoreId, bool>(0L, "Related Calendar Item found. Id: {0}.  Is Organizer? {1}", arg, isOrganizer);
            return(true);
        }
Example #22
0
 private RecurrenceBlobMerger(StoreSession session, CalendarItem calendarItem, GlobalObjectId globalObjectId, InternalRecurrence originalRecurrence, InternalRecurrence newRecurrence)
 {
     this.Session            = session;
     this.CalendarItem       = calendarItem;
     this.GlobalObjectId     = ((globalObjectId == null) ? string.Empty : globalObjectId.ToString());
     this.OriginalRecurrence = originalRecurrence;
     this.NewRecurrence      = newRecurrence;
 }
 public override string ToString()
 {
     return(GlobalObjectId.ByteArrayToHexString(this.bytes));
 }