Exemplo n.º 1
0
        // Token: 0x06001B88 RID: 7048 RVA: 0x000699B0 File Offset: 0x00067BB0
        internal bool Execute()
        {
            StoreObjectId defaultFolderId = this.session.GetDefaultFolderId(DefaultFolderType.QuickContacts);
            PersonId      personId        = IdConverter.EwsIdToPersonId(this.personaId.GetId());
            AllPersonContactsEnumerator allPersonContactsEnumerator = AllPersonContactsEnumerator.Create(this.session, personId, RemoveFavorite.ContactProperties);

            ExTraceGlobals.RemoveFavoriteTracer.TraceDebug((long)this.GetHashCode(), "Processing contacts.");
            int num = 0;

            foreach (IStorePropertyBag storePropertyBag in allPersonContactsEnumerator)
            {
                byte[]        valueOrDefault = storePropertyBag.GetValueOrDefault <byte[]>(StoreObjectSchema.ParentEntryId, null);
                StoreObjectId objA           = StoreObjectId.FromProviderSpecificIdOrNull(valueOrDefault);
                if (object.Equals(objA, defaultFolderId))
                {
                    num++;
                    VersionedId valueOrDefault2 = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                    if (valueOrDefault2 != null)
                    {
                        StoreId objectId = valueOrDefault2.ObjectId;
                        this.utilities.RemoveContactFromGroup(objectId, this.favoritesPdlId);
                        this.UnsetIsFavoriteFlagIfContactExists(objectId);
                    }
                }
            }
            this.SetLogValue(RemoveFavoriteMetadata.NumberOfContacts, num);
            if (num == 0)
            {
                ExTraceGlobals.RemoveFavoriteTracer.TraceDebug <ItemId>((long)this.GetHashCode(), "No contacts found with personId: {0}", this.personaId);
            }
            return(true);
        }
Exemplo n.º 2
0
        public static void AddClutterToFavorite(MailboxSession session)
        {
            try
            {
                using (Folder folder = Folder.Bind(session, DefaultFolderType.Clutter))
                {
                    if (folder != null)
                    {
                        StoreObjectId storeObjectId = folder.StoreObjectId;
                        using (Folder folder2 = Folder.Bind(session, DefaultFolderType.CommonViews))
                        {
                            using (QueryResult queryResult = folder2.ItemQuery(ItemQueryType.Associated, ClutterUtilities.FavoriteItemQueryFilter, ClutterUtilities.FavoriteItemSortBy, ClutterUtilities.FavoriteItemProperties))
                            {
                                StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox);
                                if (defaultFolderId == null)
                                {
                                    throw new InvalidOperationException("Inbox ID cannot be null.");
                                }
                                byte[] array  = null;
                                byte[] array2 = null;
                                byte[] array3 = null;
                                for (;;)
                                {
                                    object[][] rows = queryResult.GetRows(10000);
                                    foreach (object[] array5 in rows)
                                    {
                                        byte[] array6 = array5[ClutterUtilities.FavoriteItemPropertiesMap[NavigationNodeSchema.Ordinal]] as byte[];
                                        array = (array ?? array6);
                                        StoreObjectId id = StoreObjectId.FromProviderSpecificIdOrNull(array5[ClutterUtilities.FavoriteItemPropertiesMap[NavigationNodeSchema.NodeEntryId]] as byte[]);
                                        if (storeObjectId.Equals(id))
                                        {
                                            goto Block_11;
                                        }
                                        if (array2 == null)
                                        {
                                            if (defaultFolderId.Equals(id))
                                            {
                                                array2 = array6;
                                            }
                                        }
                                        else if (array3 == null && !array6.SequenceEqual(array2))
                                        {
                                            array3 = array6;
                                        }
                                    }
                                    if (rows.Length <= 0)
                                    {
                                        goto Block_17;
                                    }
                                }
Block_11:
                                return;

Block_17:
                                byte[] nodeBefore;
                                byte[] nodeAfter;
                                if (array2 != null)
                                {
                                    nodeBefore = array2;
                                    nodeAfter  = array3;
                                }
                                else
                                {
                                    nodeBefore = null;
                                    nodeAfter  = array;
                                }
                                using (FavoriteFolderEntry favoriteFolderEntry = FavoriteFolderEntry.Create(session, storeObjectId, FolderTreeDataType.NormalFolder))
                                {
                                    favoriteFolderEntry.FolderDisplayName = folder.DisplayName;
                                    favoriteFolderEntry.SetNodeOrdinal(nodeBefore, nodeAfter);
                                    favoriteFolderEntry.Save(SaveMode.ResolveConflicts);
                                }
                            }
                        }
                    }
                }
            }
            catch (LocalizedException ex)
            {
                InferenceDiagnosticsLog.Log("AddClutterToFavorite", ex.ToString());
            }
        }