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.

109 lines
4.0 KiB

  1. /********************************************************************
  2. * Project : C:\DEPOT\multimedia\eHomeTest\UserXp\guidesearch\guidesearch.sln
  3. * File : LenCheck.cs
  4. * Summary : This class is used to check the title and content lengths. Used for demos at CES while string wrapping bug exists.
  5. * Classes :
  6. * Notes :
  7. * *****************************************************************/
  8. using System;
  9. using MediaCenter.Video;
  10. using System.Runtime.InteropServices;
  11. using ServiceBus.Interop.RecordingGSCustomObject;
  12. using System.Threading;
  13. namespace GuideMgr
  14. {
  15. /// <summary>
  16. /// Summary description for LenCheck.
  17. /// </summary>
  18. public class LenCheck
  19. {
  20. MediaCenter.Video.ShowQueryOp query;
  21. GSMediaLibrary gs;
  22. IPrograms programs;
  23. public LenCheck()
  24. {
  25. gs = new GSMediaLibrary();
  26. query = ShowQueryOp.Contains;
  27. programs = gs.ShowsKeywordQuery(query, " " );
  28. }
  29. public string[,] ReturnResults(int titleLen, int descLen)
  30. {
  31. string[,] fullResults;
  32. string[,] filteredResults;
  33. int index = 0;
  34. int entryCount = 0;
  35. int totalProgramCount = 0;
  36. int tooLargeCount = 0;
  37. IProgram prg = null;
  38. IScheduleEntry se = null;
  39. Console.WriteLine("This is slow. Please be patient.");
  40. // Get results of search on "ALL"
  41. Console.WriteLine("Finding Results");
  42. totalProgramCount = programs.Count;
  43. fullResults = new string[totalProgramCount, 3];
  44. for(uint i=0; i < totalProgramCount; i++)
  45. {
  46. prg = programs.get_Item(i);
  47. fullResults[i,0] = prg.Title;
  48. fullResults[i,1] = prg.Description;
  49. /* // Here is some code that gives access to showings for this program
  50. entryCount = prg.ScheduleEntries.Count;
  51. fullResults[i,2] = "";
  52. for (int k = 0; k < entryCount; k++)
  53. {
  54. prg = programs.get_Item(i);
  55. se = prg.ScheduleEntries.get_Item(k);
  56. {
  57. fullResults[i,2] = fullResults[i,2] + se.StartTime + " " +
  58. se.Service.ProviderDescription + " " + "\r\n";
  59. Console.WriteLine("TITLE:{0}\r\nSHOWINGS:\r\n{1}DESCRIPTION:{2}", fullResults[i,0], fullResults[i,2], fullResults[i,1]);
  60. }
  61. Marshal.ReleaseComObject(se);
  62. Marshal.ReleaseComObject(prg);
  63. } // for entries
  64. */
  65. if (fullResults[i,0].Length > titleLen ||
  66. fullResults[i,1].Length > descLen)
  67. {
  68. prg.Title = "**************************";
  69. tooLargeCount++;
  70. }
  71. Marshal.ReleaseComObject(prg);
  72. } // for programs
  73. // create results array and fill it.
  74. filteredResults = new string[tooLargeCount,3];
  75. Console.WriteLine("Filling Array");
  76. for(uint i=0; i < totalProgramCount; i++)
  77. {
  78. if (fullResults[i,0].Length > titleLen ||
  79. fullResults[i,1].Length > descLen)
  80. {
  81. filteredResults[index,0] = fullResults[i,0];
  82. filteredResults[index,1] = fullResults[i,1];
  83. filteredResults[index,2] = fullResults[i,2];
  84. index++;
  85. }
  86. }
  87. return filteredResults;
  88. }
  89. ~LenCheck()
  90. {
  91. // release the programs com obj
  92. Marshal.ReleaseComObject(programs);
  93. programs = null;
  94. }
  95. } // public class LenCheck
  96. }