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.

136 lines
3.3 KiB

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Web;
  5. using UDDI;
  6. using UDDI.Diagnostics;
  7. namespace UDDI.Web
  8. {
  9. public enum ReportType
  10. {
  11. GetEntityCounts = 0,
  12. GetPublisherStats = 1,
  13. GetTopPublishers = 2,
  14. GetTaxonomyStats = 3
  15. }
  16. public enum ReportStatus
  17. {
  18. Available = 0,
  19. Processing = 1
  20. }
  21. public class Statistics
  22. {
  23. public static DataView GetStatistics( ReportType reporttype, ref DateTime lastchange )
  24. {
  25. string reportid = GetReportID( reporttype );
  26. Debug.Enter();
  27. //
  28. // Get Report Header
  29. //
  30. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  31. sp.ProcedureName = "net_report_get";
  32. sp.Parameters.Add( "@reportID", SqlDbType.NVarChar, 128 );
  33. sp.Parameters.Add( "@lastChange", SqlDbType.DateTime, ParameterDirection.Output );
  34. sp.Parameters.SetString( "@reportID", reportid );
  35. sp.ExecuteNonQuery();
  36. lastchange = (DateTime)sp.Parameters.GetDateTime( "@lastChange" );
  37. //
  38. // Get Report Detail
  39. //
  40. DataSet statistics = new DataSet();
  41. SqlStoredProcedureAccessor sp2 = new SqlStoredProcedureAccessor();
  42. sp2.ProcedureName = "net_reportLines_get";
  43. sp2.Parameters.Add( "@reportID", SqlDbType.NVarChar, 128 );
  44. sp2.Parameters.SetString( "@reportID", reportid );
  45. sp2.Fill( statistics, "Statistics" );
  46. Debug.Leave();
  47. return statistics.Tables[ "Statistics" ].DefaultView;
  48. }
  49. public static void RecalculateStatistics( )
  50. {
  51. Debug.Enter();
  52. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  53. sp.ProcedureName = "net_statistics_recalculate";
  54. try
  55. {
  56. sp.ExecuteNonQuery();
  57. }
  58. catch( Exception e )
  59. {
  60. Debug.Write( UDDI.Diagnostics.SeverityType.Info, CategoryType.Website, "Exception during statistic recalculation:\r\n\r\n" + e.ToString() );
  61. #if never
  62. throw new UDDIException( ErrorType.E_fatalError, "Unable to recalculate statistics:" + e.Message );
  63. #endif
  64. throw new UDDIException( ErrorType.E_fatalError, "UDDI_ERROR_UNABLE_TO_RECALC_STATS", e.Message );
  65. }
  66. Debug.Leave();
  67. }
  68. public static ReportStatus GetReportStatus( ReportType reporttype )
  69. {
  70. string reportid = GetReportID( reporttype );
  71. ReportStatus reportstatus;
  72. Debug.Enter();
  73. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  74. sp.ProcedureName = "net_report_get";
  75. sp.Parameters.Add( "@reportID", SqlDbType.NVarChar, 128 );
  76. sp.Parameters.Add( "@reportStatusID", SqlDbType.TinyInt, ParameterDirection.Output );
  77. sp.Parameters.SetString( "@reportID", reportid );
  78. sp.ExecuteNonQuery();
  79. reportstatus = (ReportStatus)sp.Parameters.GetInt( "@reportStatusID" );
  80. Debug.Leave();
  81. return reportstatus;
  82. }
  83. private static string GetReportID ( ReportType reporttype )
  84. {
  85. string reportid = "";
  86. switch( reporttype )
  87. {
  88. case ReportType.GetEntityCounts :
  89. reportid = "UI_getEntityCounts";
  90. break;
  91. case ReportType.GetPublisherStats :
  92. reportid = "UI_getPublisherStats";
  93. break;
  94. case ReportType.GetTopPublishers :
  95. reportid = "UI_getTopPublishers";
  96. break;
  97. case ReportType.GetTaxonomyStats :
  98. reportid = "UI_getTaxonomyStats";
  99. break;
  100. }
  101. return reportid;
  102. }
  103. }
  104. }