예제 #1
0
        ////Search By Number
        public void FilterResults(DocumentList list, bool truncate, bool answers, bool proofs, bool allDocs, int searchTerm)
        {
            DocumentList resultList = new DocumentList();

            foreach (Document document in list)
            {
                if (document.ChNumber == searchTerm)
                {
                    resultList.Add(document);
                }
            }

            list = resultList;
            list.Sort();
            this.documentList = list;
        }
예제 #2
0
        //Modify existing methods in original app
        public void FilterResults(DocumentList list, bool truncate, bool answers, bool proofs, bool allDocs, string searchTerm)
        {
            DocumentList resultList = new DocumentList();

            Log.Info("Filter", "Filtering Confession Results");
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Reset();
            stopwatch.Start();
            Log.Debug("Timer", "Timer Started");
            Regex regex = new Regex(searchTerm, RegexOptions.IgnoreCase);

            Log.Info("Filter Results", "Filtering has begun");
            foreach (Document document in list)
            {
                string[] searchEntries = new string[4];
                searchEntries[0] = document.ChName;
                searchEntries[1] = document.DocumentText;
                searchEntries[2] = document.ChProofs;
                searchEntries[3] = document.Tags;

                foreach (string word in searchEntries) //this[i].Split(' '))
                {
                    string[] pieces = word.Split(' ');
                    foreach (string chunks in pieces)
                    {
                        if (regex.IsMatch(chunks))
                        {
                            document.Matches++;
                        }
                    }
                }
                if (document.Matches >= 1)
                {
                    resultList.Add(document);
                }
                stopwatch.Stop();
                Log.Debug("Timer", String.Format("{0}ms Passed", stopwatch.ElapsedMilliseconds.ToString()));
                stopwatch.Reset();
            }

            list = resultList;
            list.Sort(Document.CompareMatches);
            //   list.Reverse();
            this.documentList = (DocumentList)list;
        }