Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.3 KiB

  1. /********************************************************************
  2. * Project : C:\DEPOT\multimedia\eHomeTest\UserXp\guidesearch\guidesearch.sln
  3. * File : GuideSearch.cs
  4. * Summary :
  5. * Classes :
  6. * Notes :
  7. * *****************************************************************/
  8. using System;
  9. using System.IO;
  10. namespace GuideMgr
  11. {
  12. class GuideMgrApp
  13. {
  14. /// <summary>
  15. /// The main entry point for the application.
  16. /// </summary>
  17. [STAThread]
  18. static void Main(string[] args)
  19. {
  20. ProgramArgs opts = new ProgramArgs();
  21. LenCheck lc;
  22. GuideSearch gc;
  23. string[,] results;
  24. string[] sortedResults;
  25. StreamWriter OutputStream = null;
  26. // Get command line args
  27. if ( !opts.CommandLine(args) ) return;
  28. // Run LENGTH test
  29. if ( opts.test == "len" )
  30. {
  31. // Scan guidestore and return all titles/descriptions.
  32. lc = new LenCheck();
  33. results = lc.ReturnResults(opts.MaxTitleLen,opts.MaxDescLen);
  34. }
  35. // run SEARCH test
  36. else if (opts.test == "search" )
  37. {
  38. gc = new GuideSearch(opts.QueryType, opts.QueryMode, opts.SearchString);
  39. results = gc.ReturnResults();
  40. }
  41. else
  42. {
  43. Console.WriteLine("Test {0} not supported or not implemented.", opts.test);
  44. return;
  45. }
  46. // Setup output file
  47. if ( opts.OutputFile != "" )
  48. {
  49. if ( opts.Append == true )
  50. {
  51. OutputStream = File.AppendText(opts.OutputFile);
  52. }
  53. else
  54. {
  55. OutputStream = File.CreateText(opts.OutputFile);
  56. }
  57. }
  58. // display results
  59. int count = results.GetLength(0);
  60. sortedResults = new string[count];
  61. for ( int x = 0; x < count; x++ )
  62. {
  63. sortedResults[x] = results[x,0] + "\r\n" + results[x,2] + results[x,1] + "\r\n\r\n";
  64. }
  65. Array.Sort(sortedResults);
  66. if (OutputStream != null)
  67. {
  68. OutputStream.WriteLine("Test Parameters");
  69. OutputStream.WriteLine("Test Mode = {0}", opts.test);
  70. OutputStream.WriteLine("Max Title Len = {0}, Max Desc Len = {1}", opts.MaxTitleLen, opts.MaxDescLen);
  71. OutputStream.WriteLine("Search Term = {0}", opts.SearchString);
  72. OutputStream.WriteLine("Search Mode = {0}:{1}", opts.QueryType, opts.QueryMode);
  73. OutputStream.WriteLine("===========================================================");
  74. }
  75. for ( int x = 0; x < count; x++ )
  76. {
  77. Console.WriteLine("{0}", sortedResults[x]);
  78. if (OutputStream != null)
  79. {
  80. OutputStream.WriteLine("{0}", sortedResults[x]);
  81. }
  82. }
  83. if ( OutputStream != null )
  84. {
  85. OutputStream.Flush();
  86. OutputStream.Close();
  87. }
  88. }
  89. }
  90. }