Esempio n. 1
0
        internal static TaskGroupEntryInfo GetTaskGroupEntryInfoFromRow(IStorePropertyBag row)
        {
            VersionedId versionedId = (VersionedId)row.TryGetProperty(ItemSchema.Id);

            byte[] valueOrDefault  = row.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.NodeEntryId, null);
            byte[] valueOrDefault2 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
            string valueOrDefault3 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty);

            byte[] valueOrDefault4 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null);
            row.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.StoreEntryId, null);
            ExDateTime valueOrDefault5 = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue);

            row.GetValueOrDefault <FolderTreeDataType>(FolderTreeDataSchema.Type, FolderTreeDataType.NormalFolder);
            FolderTreeDataFlags valueOrDefault6 = row.GetValueOrDefault <FolderTreeDataFlags>(FolderTreeDataSchema.FolderTreeDataFlags, FolderTreeDataFlags.None);
            Guid safeGuidFromByteArray          = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault2);

            if (safeGuidFromByteArray.Equals(Guid.Empty))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found TaskGroupEntry with invalid parent group class id. ArrayLength: {0}", (valueOrDefault2 == null) ? -1 : valueOrDefault2.Length);
                return(null);
            }
            if (IdConverter.IsFolderId(valueOrDefault))
            {
                StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault);
                if ((valueOrDefault6 & FolderTreeDataFlags.IsDefaultStore) == FolderTreeDataFlags.IsDefaultStore)
                {
                    return(new TaskGroupEntryInfo(valueOrDefault3, versionedId, storeObjectId, safeGuidFromByteArray, valueOrDefault4, valueOrDefault5));
                }
                ExTraceGlobals.StorageTracer.TraceDebug <StoreObjectType, string, VersionedId>(0L, "Found TaskGroupEntry of type {0} referencing a non-task folder. ObjectType: {0}. TaskFfolderName: {1}. Id: {2}.", storeObjectId.ObjectType, valueOrDefault3, versionedId);
            }
            return(null);
        }
Esempio n. 2
0
        private static FolderTreeDataFlags ReadSharingFlags(CalendarFolder calendarFolder)
        {
            ExtendedFolderFlags valueOrDefault      = calendarFolder.GetValueOrDefault <ExtendedFolderFlags>(FolderSchema.ExtendedFolderFlags);
            FolderTreeDataFlags folderTreeDataFlags = FolderTreeDataFlags.None;

            foreach (ExtendedFolderFlags extendedFolderFlags in CalendarGroupEntry.mapExtendedFolderToSharingFlag.Keys)
            {
                if ((valueOrDefault & extendedFolderFlags) == extendedFolderFlags)
                {
                    folderTreeDataFlags |= CalendarGroupEntry.mapExtendedFolderToSharingFlag[extendedFolderFlags];
                }
            }
            return(folderTreeDataFlags);
        }
Esempio n. 3
0
        public static CalendarGroupEntry Create(MailboxSession session, CalendarFolder calendarFolder, CalendarGroup parentGroup)
        {
            Util.ThrowOnNullArgument(parentGroup, "parentGroup");
            Util.ThrowOnNullArgument(calendarFolder, "calendarFolder");
            CalendarGroupEntry  calendarGroupEntry  = CalendarGroupEntry.Create(session, calendarFolder.Id.ObjectId, parentGroup.GroupClassId, parentGroup.GroupName);
            FolderTreeDataFlags folderTreeDataFlags = CalendarGroupEntry.ReadSharingFlags(calendarFolder);
            bool flag = !session.MailboxGuid.Equals(((MailboxSession)calendarFolder.Session).MailboxGuid);

            if (flag)
            {
                calendarGroupEntry[FolderTreeDataSchema.Type] = FolderTreeDataType.SharedFolder;
                calendarGroupEntry.StoreEntryId      = Microsoft.Exchange.Data.Storage.StoreEntryId.ToProviderStoreEntryId(((MailboxSession)calendarFolder.Session).MailboxOwner);
                calendarGroupEntry.CalendarRecordKey = (byte[])calendarFolder.TryGetProperty(StoreObjectSchema.RecordKey);
            }
            else
            {
                folderTreeDataFlags |= FolderTreeDataFlags.IsDefaultStore;
            }
            calendarGroupEntry[FolderTreeDataSchema.FolderTreeDataFlags] = folderTreeDataFlags;
            return(calendarGroupEntry);
        }
        public static FavoriteFolderEntry Create(MailboxSession session, StoreObjectId folderId, FolderTreeDataType dataType, FavoriteFolderType favoriteFolderType)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(session, "folderId");
            EnumValidator.ThrowIfInvalid <FolderTreeDataType>(dataType, "dataType");
            EnumValidator.ThrowIfInvalid <FavoriteFolderType>(favoriteFolderType, "favoriteFolderType");
            FolderTreeDataSection groupSection = FavoriteFolderEntry.FavoritesGroupSectionByFolderType[favoriteFolderType];

            byte[] favoritesClassIdValue            = FavoriteFolderEntry.FavoritesClassIdValueByFolderType[favoriteFolderType];
            FavoriteFolderEntry favoriteFolderEntry = ItemBuilder.CreateNewItem <FavoriteFolderEntry>(session, session.GetDefaultFolderId(DefaultFolderType.CommonViews), ItemCreateInfo.FavoriteFolderEntryInfo, CreateMessageType.Associated);

            byte[] favoritesParentGroupClassIdValue           = (FavoriteFolderType.Contact == favoriteFolderType || FavoriteFolderType.Calendar == favoriteFolderType) ? NavigationNodeParentGroup.OtherFoldersClassId.AsBytes : null;
            FolderTreeDataFlags additionalFolderTreeDataFlags = FolderTreeDataFlags.None;

            if (folderId.IsLegacyPublicFolderType())
            {
                additionalFolderTreeDataFlags = FavoriteFolderEntry.PublicFolderTreeDataFlagsByFolderType[favoriteFolderType];
            }
            favoriteFolderEntry.SetPropertiesOfFavoriteFolderEntry(session, folderId, dataType, groupSection, favoritesClassIdValue, favoritesParentGroupClassIdValue, additionalFolderTreeDataFlags);
            return(favoriteFolderEntry);
        }
Esempio n. 5
0
        internal static CalendarGroupEntryInfo GetCalendarGroupEntryInfoFromRow(IStorePropertyBag row)
        {
            VersionedId versionedId = (VersionedId)row.TryGetProperty(ItemSchema.Id);

            byte[] valueOrDefault  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.NodeEntryId, null);
            byte[] valueOrDefault2 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
            string valueOrDefault3 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty);
            LegacyCalendarColor valueOrDefault4 = row.GetValueOrDefault <LegacyCalendarColor>(CalendarGroupEntrySchema.CalendarColor, LegacyCalendarColor.Auto);

            byte[]              valueOrDefault5  = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null);
            byte[]              valueOrDefault6  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.SharerAddressBookEntryId, null);
            byte[]              valueOrDefault7  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.StoreEntryId, null);
            ExDateTime          valueOrDefault8  = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue);
            FolderTreeDataType  valueOrDefault9  = row.GetValueOrDefault <FolderTreeDataType>(FolderTreeDataSchema.Type, FolderTreeDataType.NormalFolder);
            FolderTreeDataFlags valueOrDefault10 = row.GetValueOrDefault <FolderTreeDataFlags>(FolderTreeDataSchema.FolderTreeDataFlags, FolderTreeDataFlags.None);
            Guid safeGuidFromByteArray           = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault2);

            if (safeGuidFromByteArray.Equals(Guid.Empty))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found CalendarGroupEntry with invalid parent group class id. ArrayLength: {0}", (valueOrDefault2 == null) ? -1 : valueOrDefault2.Length);
                return(null);
            }
            if (valueOrDefault9 != FolderTreeDataType.SharedFolder)
            {
                if (IdConverter.IsFolderId(valueOrDefault))
                {
                    StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault);
                    if ((valueOrDefault10 & FolderTreeDataFlags.IsDefaultStore) == FolderTreeDataFlags.IsDefaultStore)
                    {
                        return(new LocalCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId, valueOrDefault5, safeGuidFromByteArray, (valueOrDefault10 & FolderTreeDataFlags.ICalFolder) == FolderTreeDataFlags.ICalFolder || (valueOrDefault10 & FolderTreeDataFlags.SharedIn) == FolderTreeDataFlags.SharedIn, valueOrDefault8));
                    }
                    if ((valueOrDefault10 & FolderTreeDataFlags.PublicFolder) == FolderTreeDataFlags.PublicFolder)
                    {
                        string calendarOwner = Microsoft.Exchange.Data.Storage.StoreEntryId.TryParseStoreEntryIdMailboxDN(valueOrDefault7);
                        storeObjectId = StoreObjectId.FromLegacyFavoritePublicFolderId(storeObjectId);
                        return(new LinkedCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId, calendarOwner, safeGuidFromByteArray, valueOrDefault5, false, true, valueOrDefault8));
                    }
                    ExTraceGlobals.StorageTracer.TraceDebug <StoreObjectType, string, VersionedId>(0L, "Found CalendarGroupEntry of type {0} referencing a non-calendar folder. ObjectType: {0}. CalendarName: {1}. Id: {2}.", storeObjectId.ObjectType, valueOrDefault3, versionedId);
                }
                return(null);
            }
            bool   flag = true;
            Eidt   eidt;
            string text;

            if (!AddressBookEntryId.IsAddressBookEntryId(valueOrDefault6, out eidt, out text))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "AddressBookEntryId is missing, not primary calendar {0}", valueOrDefault3);
                if (valueOrDefault7 == null)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "StoreEntryId is missing for calendar: {0} - invalid entry, skipping.", valueOrDefault3);
                    return(null);
                }
                text = Microsoft.Exchange.Data.Storage.StoreEntryId.TryParseStoreEntryIdMailboxDN(valueOrDefault7);
                flag = false;
            }
            if (text == null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Unable to determine owner of shared calendar: {0}. Skipping.", valueOrDefault3);
                return(null);
            }
            StoreObjectId storeObjectId2 = IdConverter.IsFolderId(valueOrDefault) ? StoreObjectId.FromProviderSpecificId(valueOrDefault) : null;

            if (!flag && storeObjectId2 == null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Secondary shared calendar without a folder id encountered {0}. Skipping.", valueOrDefault3);
                return(null);
            }
            return(new LinkedCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId2, text, safeGuidFromByteArray, valueOrDefault5, flag, false, valueOrDefault8));
        }
 private void SetPropertiesOfFavoriteFolderEntry(MailboxSession session, StoreObjectId folderId, FolderTreeDataType dataType, FolderTreeDataSection groupSection, byte[] favoritesClassIdValue, byte[] favoritesParentGroupClassIdValue, FolderTreeDataFlags additionalFolderTreeDataFlags)
 {
     if (folderId.ObjectType != StoreObjectType.Folder && folderId.ObjectType != StoreObjectType.SearchFolder)
     {
         throw new NotSupportedException("Only folder and search folder types can be added to favorites.");
     }
     this[FolderTreeDataSchema.GroupSection] = groupSection;
     if (favoritesClassIdValue != null)
     {
         this[FolderTreeDataSchema.ClassId] = favoritesClassIdValue;
     }
     if (favoritesParentGroupClassIdValue != null)
     {
         this[FolderTreeDataSchema.ParentGroupClassId] = favoritesParentGroupClassIdValue;
     }
     base.MailboxSession = session;
     this.NodeEntryId    = folderId.ProviderLevelItemId;
     this.StoreEntryId   = Microsoft.Exchange.Data.Storage.StoreEntryId.ToProviderStoreEntryId(session.MailboxOwner, folderId.IsLegacyPublicFolderType());
     if (additionalFolderTreeDataFlags != FolderTreeDataFlags.None)
     {
         base.FolderTreeDataFlags |= additionalFolderTreeDataFlags;
     }
     if (folderId.IsLegacyPublicFolderType())
     {
         byte[] providerLevelItemId = folderId.ProviderLevelItemId;
         providerLevelItemId[0]       = 239;
         providerLevelItemId[20]      = 2;
         this.NavigationNodeRecordKey = providerLevelItemId;
     }
     base.FolderTreeDataType = dataType;
 }