protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder)
        {
            base.SetPropertiesInternal(context, folder);
            folder.Save();
            SearchFolder searchFolder = (SearchFolder)folder;

            StoreObjectId[] folderScope;
            if (MailboxSession.DefaultFoldersToForceInit != null && MailboxSession.DefaultFoldersToForceInit.Contains(DefaultFolderType.MyContacts))
            {
                folderScope = this.contactsSearchFolderCriteria.GetExistingDefaultFolderScope(context);
            }
            else
            {
                folderScope = this.contactsSearchFolderCriteria.GetDefaultFolderScope(context.Session, true);
            }
            SearchFolderCriteria searchFolderCriteria = ContactsSearchFolderCriteria.CreateSearchCriteria(folderScope);

            ContactsSearchFolderCriteria.ApplyContinuousSearchFolderCriteria(XSOFactory.Default, context.Session, searchFolder, searchFolderCriteria);
            bool flag = context.Session.MailboxOwner.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox || !context.Session.ClientInfoString.Contains("Client=WebServices;Action=ConfigureGroupMailbox");

            MyContactsFolderValidation.Tracer.TraceDebug <string, RecipientTypeDetails, bool>((long)context.Session.GetHashCode(), "SearchFolder criteria applied. ClientInfoString={0}, RecipientTypeDetails={1}, ShouldWaitForNotification={2}", context.Session.ClientInfoString, context.Session.MailboxOwner.RecipientTypeDetails, flag);
            if (flag)
            {
                ContactsSearchFolderCriteria.WaitForSearchFolderPopulation(XSOFactory.Default, context.Session, searchFolder);
            }
            folder.Load(null);
        }
Exemplo n.º 2
0
        public static void UpdateFolderScope(IXSOFactory xsoFactory, IMailboxSession mailboxSession, ISearchFolder searchFolder, StoreObjectId[] folderScope)
        {
            ArgumentValidator.ThrowIfNull("xsoFactory", xsoFactory);
            ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession);
            ArgumentValidator.ThrowIfNull("searchFolder", searchFolder);
            ArgumentValidator.ThrowIfNull("folderScope", folderScope);
            SearchFolderCriteria searchFolderCriteria;

            try
            {
                searchFolderCriteria = searchFolder.GetSearchCriteria();
            }
            catch (ObjectNotInitializedException)
            {
                searchFolderCriteria = null;
            }
            if (searchFolderCriteria != null && ContactsSearchFolderCriteria.MatchFolderScope(searchFolderCriteria.FolderScope, folderScope))
            {
                return;
            }
            SearchFolderCriteria searchFolderCriteria2 = ContactsSearchFolderCriteria.CreateSearchCriteria(folderScope);

            ContactsSearchFolderCriteria.Tracer.TraceDebug <SearchFolderCriteria, SearchFolderCriteria>((long)searchFolder.GetHashCode(), "Updating MyContactsFolder Search Criteria since it is different from the current one. Current:{0}, New:{1}.", searchFolderCriteria, searchFolderCriteria2);
            ContactsSearchFolderCriteria.ApplyContinuousSearchFolderCriteria(xsoFactory, mailboxSession, searchFolder, searchFolderCriteria2);
            ContactsSearchFolderCriteria.WaitForSearchFolderPopulation(xsoFactory, mailboxSession, searchFolder);
        }
 internal MyContactsFolderValidation(ContactsSearchFolderCriteria contactsSearchFolderCriteria) : base(new IValidator[]
 {
     new MatchMapiFolderType(FolderType.Search)
 })
 {
     this.contactsSearchFolderCriteria = contactsSearchFolderCriteria;
 }
Exemplo n.º 4
0
        public static StoreObjectId[] RemoveDeletedFoldersFromCollection(IXSOFactory xsoFactory, IMailboxSession mailboxSession, IEnumerable <StoreObjectId> folderIds)
        {
            ArgumentValidator.ThrowIfNull("xsoFactory", xsoFactory);
            ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession);
            ArgumentValidator.ThrowIfNull("folderIds", folderIds);
            List <StoreObjectId> list = new List <StoreObjectId>(folderIds);

            list.RemoveAll((StoreObjectId folderId) => ContactsSearchFolderCriteria.IsDeletedFolder(mailboxSession, folderId));
            return(list.ToArray());
        }
Exemplo n.º 5
0
        public static StoreObjectId[] GetMyContactExtendedFolders(IMailboxSession mailboxSession, StoreObjectId[] myContactsFolders, bool forceCreate)
        {
            ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession);
            ArgumentValidator.ThrowIfNull("myContactsFolders", myContactsFolders);
            StoreObjectId[]         folderIds = ContactsSearchFolderCriteria.GetFolderIds(mailboxSession, forceCreate, ContactsSearchFolderCriteria.BaseScopeForMyContactExtended);
            HashSet <StoreObjectId> hashSet   = new HashSet <StoreObjectId>(StoreId.EqualityComparer);

            hashSet.UnionWith(folderIds);
            hashSet.UnionWith(myContactsFolders);
            StoreObjectId[] array = new StoreObjectId[hashSet.Count];
            hashSet.CopyTo(array);
            return(array);
        }
Exemplo n.º 6
0
        public void UpdateFolderScope(IXSOFactory xsoFactory, IMailboxSession mailboxSession, StoreObjectId[] scope)
        {
            ArgumentValidator.ThrowIfNull("xsoFactory", xsoFactory);
            ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession);
            ArgumentValidator.ThrowIfNull("scope", scope);
            StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(this.defaultFolderType);

            if (defaultFolderId == null)
            {
                mailboxSession.CreateDefaultFolder(this.defaultFolderType);
                defaultFolderId = mailboxSession.GetDefaultFolderId(this.defaultFolderType);
            }
            using (ISearchFolder searchFolder = xsoFactory.BindToSearchFolder(mailboxSession, defaultFolderId))
            {
                ContactsSearchFolderCriteria.UpdateFolderScope(xsoFactory, mailboxSession, searchFolder, scope);
            }
        }
Exemplo n.º 7
0
 private static void ApplySearchFolderCriteria(IXSOFactory xsoFactory, IMailboxSession mailboxSession, ISearchFolder searchFolder, SearchFolderCriteria searchFolderCriteria, Action <SearchFolderCriteria> applySearchCriteriaAction)
 {
     ArgumentValidator.ThrowIfNull("xsoFactory", xsoFactory);
     ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession);
     ArgumentValidator.ThrowIfNull("searchFolder", searchFolder);
     ArgumentValidator.ThrowIfNull("searchFolderCriteria", searchFolderCriteria);
     ContactsSearchFolderCriteria.Tracer.TraceDebug <SearchFolderCriteria>((long)mailboxSession.GetHashCode(), "Applying search folder criteria: {0}", searchFolderCriteria);
     try
     {
         applySearchCriteriaAction(searchFolderCriteria);
     }
     catch (ObjectNotFoundException)
     {
         List <StoreObjectId> list = new List <StoreObjectId>(searchFolderCriteria.FolderScope.Length);
         foreach (StoreId storeId in searchFolderCriteria.FolderScope)
         {
             list.Add((StoreObjectId)storeId);
         }
         searchFolderCriteria.FolderScope = ContactsSearchFolderCriteria.RemoveDeletedFoldersFromCollection(xsoFactory, mailboxSession, list);
         applySearchCriteriaAction(searchFolderCriteria);
     }
 }
Exemplo n.º 8
0
 public static void WaitForSearchFolderPopulation(IXSOFactory xsoFactory, IMailboxSession mailboxSession, ISearchFolder searchFolder)
 {
     if (ContactsSearchFolderCriteria.IsSearchFolderPopulated(searchFolder))
     {
         ContactsSearchFolderCriteria.Tracer.TraceDebug((long)mailboxSession.GetHashCode(), "Search folder is already populated. No wait required.");
         return;
     }
     ContactsSearchFolderCriteria.Tracer.TraceDebug((long)mailboxSession.GetHashCode(), "Waiting for search folder to complete current population.");
     searchFolder.Load();
     using (SearchFolderAsyncSearch searchFolderAsyncSearch = new SearchFolderAsyncSearch((MailboxSession)mailboxSession, searchFolder.Id.ObjectId, null, null))
     {
         if (ContactsSearchFolderCriteria.IsSearchFolderPopulated(searchFolder))
         {
             ContactsSearchFolderCriteria.Tracer.TraceDebug((long)mailboxSession.GetHashCode(), "Search folder population completed.");
         }
         else
         {
             bool arg = searchFolderAsyncSearch.AsyncResult.AsyncWaitHandle.WaitOne(ContactsSearchFolderCriteria.SearchInProgressTimeout);
             ContactsSearchFolderCriteria.Tracer.TraceDebug <bool>((long)mailboxSession.GetHashCode(), "Done waiting, search folder population completed: {0}.", arg);
         }
     }
 }
Exemplo n.º 9
0
 private void SetFolderIds(IFolder rootFolder, StoreObjectId[] newFolderIds)
 {
     newFolderIds = ContactsSearchFolderCriteria.RemoveDeletedFoldersFromCollection(this.xsoFactory, this.mailboxSession, newFolderIds);
     ContactsSearchFolderCriteria.MyContacts.UpdateFolderScope(this.xsoFactory, this.mailboxSession, newFolderIds);
     ContactsSearchFolderCriteria.MyContactsExtended.UpdateFolderScope(this.xsoFactory, this.mailboxSession, ContactsSearchFolderCriteria.GetMyContactExtendedFolders(this.mailboxSession, newFolderIds, true));
 }
Exemplo n.º 10
0
 public static void ApplyContinuousSearchFolderCriteria(IXSOFactory xsoFactory, IMailboxSession mailboxSession, ISearchFolder searchFolder, SearchFolderCriteria searchFolderCriteria)
 {
     ContactsSearchFolderCriteria.ApplySearchFolderCriteria(xsoFactory, mailboxSession, searchFolder, searchFolderCriteria, new Action <SearchFolderCriteria>(searchFolder.ApplyContinuousSearch));
 }
Exemplo n.º 11
0
 public StoreObjectId[] GetDefaultFolderScope(IMailboxSession session, bool forceCreate)
 {
     ArgumentValidator.ThrowIfNull("session", session);
     return(ContactsSearchFolderCriteria.GetFolderIds(session, forceCreate, this.scopeDefaultFolderTypes));
 }