コード例 #1
0
ファイル: SampleBehavior.cs プロジェクト: silexcorp/wpf-demos
 private void ContinueLoadingAsynchonolously(IndexEngine engine, DateTime index)
 {
     AssociatedObject.Dispatcher.BeginInvoke(new Action(() =>
     {
         if (engine != null && engine.HighRowLevel < engine.RowCount - 1)
         {
             if (scrollViewer != null && scrollViewer.Content is TextBlock)
             {
                 (scrollViewer.Content as TextBlock).Text +=
                     string.Format("\n{0}/{1}", (highRowIndex + engine.HighRowLevel), engine.RowCount - 1);
                 highRowIndex += engine.HighRowLevel;
                 ContinueLoadingAsynchonolously(engine, index);     //do it again...
             }
         }
         else
         {
             CheckTime(index, "Load Completed");
         }
     }), DispatcherPriority.SystemIdle);
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: patrickgehrke/IndexEngine
        static void Main(string[] args)
        {
            try
            {
                string      filename = InputString("Filename", false);
                IndexEngine ie       = new IndexEngine(filename);
                ie.Logger = Logger;

                bool runForever = true;
                while (runForever)
                {
                    // Console.WriteLine("1234567890123456789012345678901234567890123456789012345678901234567890123456789");
                    string userInput = InputString("Command [? for help]", false);

                    Document        doc        = new Document();
                    List <Document> results    = new List <Document>();
                    List <string>   terms      = new List <string>();
                    List <string>   activeDocs = new List <string>();
                    string          guid       = "";

                    switch (userInput.ToLower())
                    {
                    case "?":
                        Menu();
                        break;

                    case "q":
                    case "quit":
                        runForever = false;
                        break;

                    case "c":
                    case "cls":
                        Console.Clear();
                        break;

                    case "addfile":
                        doc = BuildFileDocument();
                        ie.Add(doc);
                        break;

                    case "addfile async":
                        doc = BuildFileDocument();
                        ie.AddAsync(doc).Wait();
                        break;

                    case "addtext":
                        doc = BuildStringDocument();
                        ie.Add(doc);
                        break;

                    case "del":
                        guid = InputString("GUID", false);
                        ie.DeleteDocumentByGuid(guid);
                        break;

                    case "threads":
                        Console.WriteLine("Active document processing jobs: " + ie.CurrentIndexingThreads + "/" + ie.MaxIndexingThreads);
                        Console.WriteLine("Documents being processed:");
                        activeDocs = ie.DocumentsIndexing.ToList();
                        if (activeDocs != null && activeDocs.Count > 0)
                        {
                            foreach (string curr in activeDocs)
                            {
                                Console.WriteLine("  " + curr);
                            }
                        }
                        else
                        {
                            Console.WriteLine("(null)");
                        }
                        break;

                    case "search":
                        terms = GatherTerms();
                        if (terms == null || terms.Count < 1)
                        {
                            break;
                        }
                        results = ie.Search(terms);
                        if (results == null || results.Count < 1)
                        {
                            Console.WriteLine("No results");
                        }
                        else
                        {
                            foreach (Document curr in results)
                            {
                                Console.WriteLine(curr.ToString());
                            }
                        }
                        break;

                    case "exists":
                        Console.Write("Handle: ");
                        string handle = Console.ReadLine();
                        if (!String.IsNullOrEmpty(handle))
                        {
                            Console.WriteLine("Exists: " + ie.IsHandleIndexed(handle));
                        }
                        break;

                    case "backup":
                        ie.Backup(InputString("Destination filename", false));
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                LogException(e);
            }
            finally
            {
                Console.WriteLine("");
                Console.WriteLine("Press ENTER to exit");
                Console.ReadLine();
            }
        }
コード例 #3
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="filename">The db filename</param>
 /// <param name="apiKey">The admin api key</param>
 public IndexEngineSearchService(string filename = "idx.db")
 {
     Engine = new IndexEngine(filename);
 }