コード例 #1
0
        public override void ResetSearch(FdoCache cache, int currentID,
                                         bool wantExactMatch,
                                         int vernWs, string cf, string uf, string af,
                                         int analWs, string gl, List <ExtantEntryInfo> filters)
        {
            CheckDisposed();

            m_cacheSearch            = cache;
            m_currentID              = currentID;
            m_wantExactMatch         = wantExactMatch;
            m_vernWs                 = vernWs;
            m_cf                     = cf;
            m_uf                     = uf;
            m_af                     = af;
            m_analWs                 = analWs;
            m_gl                     = gl;
            m_filters                = filters;
            m_fResetSearchInProgress = true;
            RecordSorter sorter = null;

            if (!String.IsNullOrEmpty(cf) || !String.IsNullOrEmpty(uf) || !String.IsNullOrEmpty(af))
            {
                sorter = m_bvMatches.CreateSorterForFirstColumn(true, vernWs);
            }
            else if (!String.IsNullOrEmpty(gl))
            {
                sorter = m_bvMatches.CreateSorterForFirstColumn(false, analWs);
            }
            (Clerk as MatchingItemsRecordClerk).SetSorter(sorter);
            DoResetSearch();
        }
コード例 #2
0
        /// <summary>
        /// Searches the specified fields.
        /// </summary>
        /// <param name="fields">The fields.</param>
        /// <param name="filters">The filters.</param>
        public void Search(IEnumerable <SearchField> fields, IEnumerable <ICmObject> filters)
        {
            // If we abort this search (because the user typed), but somehow the system becomes idle before we complete a new
            // search, go ahead and complete the original one.
            m_pendingFields  = fields;
            m_pendingFilters = filters;
            m_mediator.IdleQueue.Add(IdleQueuePriority.High, DoPendingSearchWhenIdle);

            CreateSearchers();

            var       results        = new HashSet <ICmObject>();
            ITsString firstSearchStr = null;

            foreach (SearchField field in fields)
            {
                if (ShouldAbort())
                {
                    return;
                }
                if (firstSearchStr == null)
                {
                    firstSearchStr = field.String;
                }
                results.UnionWith(m_searcher.Search(field.Flid, field.String));
            }

            if (filters != null)
            {
                results.ExceptWith(filters);
            }

            if (ShouldAbort())
            {
                return;
            }
            // The following fixes LT-10293.
            RecordSorter sorter = null;

            if (firstSearchStr != null)
            {
                int  ws     = firstSearchStr.get_WritingSystemAt(0);
                bool isVern = m_cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Contains(ws);
                sorter = m_bvMatches.CreateSorterForFirstColumn(isVern, ws);
            }
            if (sorter != null)
            {
                // Convert each ICmObject in results to a IManyOnePathSortItem, and sort
                // using the sorter.
                var records = new ArrayList(results.Count);
                foreach (ICmObject obj in results)
                {
                    records.Add(new ManyOnePathSortItem(obj));
                }
                sorter.Sort(records);
                var hvos = new int[records.Count];
                for (int i = 0; i < records.Count; ++i)
                {
                    hvos[i] = (((IManyOnePathSortItem)records[i]).KeyObject);
                }
                UpdateResults(hvos);
            }
            else
            {
                UpdateResults(results.Select(obj => obj.Hvo).ToArray());
            }
            // Completed successfully, don't want to do again.
            m_pendingFields = null;
            m_mediator.IdleQueue.Remove(DoPendingSearchWhenIdle);
        }
コード例 #3
0
        private FindResultSorter CreateFindResultSorter(ITsString firstSearchStr, int ws)
        {
            var browseViewSorter = m_bvMatches.CreateSorterForFirstColumn(ws);

            return(browseViewSorter == null ? null: new FindResultSorter(firstSearchStr, browseViewSorter));
        }