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.

297 lines
8.9 KiB

  1. using System;
  2. using System.Collections;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.IO;
  6. using System.Web;
  7. using UDDI;
  8. using UDDI.API;
  9. using UDDI.API.ServiceType;
  10. using UDDI.Diagnostics;
  11. namespace UDDI.Web
  12. {
  13. public class Taxonomy
  14. {
  15. public static DataView GetTaxonomies()
  16. {
  17. Debug.Enter();
  18. DataTable taxonomies = GetTaxonomiesDataSet();
  19. Debug.Leave();
  20. return taxonomies.DefaultView;
  21. }
  22. public static DataView GetTaxonomies( string filter, string sort)
  23. {
  24. Debug.Enter();
  25. DataTable taxonomies = GetTaxonomiesDataSet();
  26. DataView view = new DataView( taxonomies, filter, sort,DataViewRowState.OriginalRows );
  27. Debug.Leave();
  28. return view;
  29. }
  30. protected static DataTable GetTaxonomiesDataSet( )
  31. {
  32. Debug.Enter();
  33. DataSet taxonomies = new DataSet();
  34. SqlCommand cmd = new SqlCommand( "UI_getTaxonomies", ConnectionManager.GetConnection() );
  35. cmd.CommandType = CommandType.StoredProcedure;
  36. cmd.Transaction = ConnectionManager.GetTransaction();
  37. SqlDataAdapter adapter = new SqlDataAdapter( cmd );
  38. adapter.Fill( taxonomies, "Taxonomies" );
  39. Debug.Leave();
  40. return taxonomies.Tables[ "Taxonomies" ];
  41. }
  42. public static int GetTaxonomyID( string tModelKey )
  43. {
  44. int taxonomyID;
  45. Debug.Enter();
  46. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  47. sp.ProcedureName = "UI_getTaxonomies";
  48. sp.Parameters.Add( "@tModelKey", SqlDbType.UniqueIdentifier );
  49. sp.Parameters.SetGuidFromKey( "@tModelKey", tModelKey );
  50. SqlDataReaderAccessor reader = sp.ExecuteReader();
  51. try
  52. {
  53. if( reader.Read() )
  54. taxonomyID = reader.GetInt( "taxonomyID" );
  55. else
  56. taxonomyID = -1;
  57. }
  58. finally
  59. {
  60. reader.Close();
  61. }
  62. Debug.Leave();
  63. return taxonomyID;
  64. }
  65. public static string GetTaxonomyParent( int taxonomyID, string ID )
  66. {
  67. Debug.Enter();
  68. SqlCommand cmd = new SqlCommand( "UI_getTaxonomyParent", ConnectionManager.GetConnection() );
  69. cmd.CommandType = CommandType.StoredProcedure;
  70. cmd.Transaction = ConnectionManager.GetTransaction();
  71. cmd.Parameters.Add( new SqlParameter( "@TaxonomyID", SqlDbType.Int ) ).Direction = ParameterDirection.Input;
  72. cmd.Parameters.Add( new SqlParameter( "@ID", SqlDbType.NVarChar, 450 ) ).Direction = ParameterDirection.Input;
  73. SqlParameterAccessor paramacc = new SqlParameterAccessor( cmd.Parameters );
  74. paramacc.SetInt( "@TaxonomyID", taxonomyID );
  75. paramacc.SetString( "@ID", ID );
  76. string parent = (string)cmd.ExecuteScalar();
  77. Debug.Leave();
  78. return parent;
  79. }
  80. public static string GetTaxonomyKeyName( int taxonomyID, string keyValue )
  81. {
  82. Debug.Enter();
  83. SqlCommand cmd = new SqlCommand( "UI_getTaxonomyName", ConnectionManager.GetConnection() );
  84. cmd.CommandType = CommandType.StoredProcedure;
  85. cmd.Transaction = ConnectionManager.GetTransaction();
  86. cmd.Parameters.Add( new SqlParameter( "@TaxonomyID", SqlDbType.Int ) ).Direction = ParameterDirection.Input;
  87. cmd.Parameters.Add( new SqlParameter( "@ID", SqlDbType.NVarChar, 450 ) ).Direction = ParameterDirection.Input;
  88. SqlParameterAccessor paramacc = new SqlParameterAccessor( cmd.Parameters );
  89. paramacc.SetInt( "@TaxonomyID", taxonomyID );
  90. paramacc.SetString( "@ID", keyValue );
  91. string keyName = (string)cmd.ExecuteScalar();
  92. Debug.Leave();
  93. return keyName;
  94. }
  95. public static DataView GetTaxonomyChildrenNode( int taxonomyID, string node )
  96. {
  97. Debug.Enter();
  98. DataSet categories = new DataSet();
  99. SqlCommand cmd = new SqlCommand( "UI_getTaxonomyChildrenNode", ConnectionManager.GetConnection() );
  100. cmd.CommandType = CommandType.StoredProcedure;
  101. cmd.Transaction = ConnectionManager.GetTransaction();
  102. cmd.Parameters.Add( new SqlParameter( "@rowCount", SqlDbType.Int ) ).Direction = ParameterDirection.ReturnValue;
  103. cmd.Parameters.Add( new SqlParameter( "@taxonomyID", SqlDbType.Int ) ).Direction = ParameterDirection.Input;
  104. cmd.Parameters.Add( new SqlParameter( "@node", SqlDbType.NVarChar, 450 ) ).Direction = ParameterDirection.Input;
  105. SqlParameterAccessor paramacc = new SqlParameterAccessor( cmd.Parameters );
  106. paramacc.SetInt( "@taxonomyID", taxonomyID );
  107. paramacc.SetString( "@node", node );
  108. SqlDataAdapter adapter = new SqlDataAdapter( cmd );
  109. adapter.Fill( categories, "categories" );
  110. Debug.Leave();
  111. return categories.Tables[ "categories" ].DefaultView;
  112. }
  113. public static DataView GetTaxonomyChildrenRoot( int taxonomyID )
  114. {
  115. Debug.Enter();
  116. DataSet categories = new DataSet();
  117. SqlCommand cmd = new SqlCommand( "UI_getTaxonomyChildrenRoot", ConnectionManager.GetConnection() );
  118. cmd.CommandType = CommandType.StoredProcedure;
  119. cmd.Transaction = ConnectionManager.GetTransaction();
  120. cmd.Parameters.Add( new SqlParameter( "@rowCount", SqlDbType.Int ) ).Direction = ParameterDirection.ReturnValue;
  121. cmd.Parameters.Add( new SqlParameter( "@taxonomyID", SqlDbType.Int ) ).Direction = ParameterDirection.Input;
  122. SqlParameterAccessor paramacc = new SqlParameterAccessor( cmd.Parameters );
  123. paramacc.SetInt( "@taxonomyID", taxonomyID );
  124. SqlDataAdapter adapter = new SqlDataAdapter( cmd );
  125. adapter.Fill( categories, "Categories" );
  126. Debug.Leave();
  127. return categories.Tables[ "Categories" ].DefaultView;
  128. }
  129. public static bool IsValidForClassification( int taxonomyID, string node )
  130. {
  131. Debug.Enter();
  132. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  133. sp.ProcedureName = "UI_isNodeValidForClassification";
  134. sp.Parameters.Add( "@taxonomyID", SqlDbType.Int );
  135. sp.Parameters.Add( "@node", SqlDbType.NVarChar, 450 );
  136. sp.Parameters.SetInt( "@taxonomyID", taxonomyID );
  137. sp.Parameters.SetString( "@node", node );
  138. bool valid = (bool)sp.ExecuteScalar();
  139. Debug.Leave();
  140. return valid;
  141. }
  142. public static void SetTaxonomyBrowsable( string tModelKey, bool enabled )
  143. {
  144. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  145. sp.ProcedureName = "UI_setTaxonomyBrowsable";
  146. sp.Parameters.Add( "@tModelKey", SqlDbType.UniqueIdentifier );
  147. sp.Parameters.Add( "@enabled", SqlDbType.TinyInt );
  148. sp.Parameters.SetGuidFromKey( "@tModelKey", tModelKey );
  149. sp.Parameters.SetInt( "@enabled", Convert.ToInt32( enabled ) );
  150. sp.ExecuteNonQuery();
  151. }
  152. public static DataTable GetTaxonomiesForBrowsingDataTable()
  153. {
  154. Debug.Enter( );
  155. DataSet taxonomies = new DataSet( );
  156. SqlCommand cmd = new SqlCommand( "UI_getBrowsableTaxonomies", ConnectionManager.GetConnection() );
  157. cmd.CommandType = CommandType.StoredProcedure;
  158. cmd.Transaction = ConnectionManager.GetTransaction();
  159. SqlDataAdapter adapter = new SqlDataAdapter( cmd );
  160. adapter.Fill( taxonomies, "Taxonomies" );
  161. Debug.Leave();
  162. return taxonomies.Tables[ "Taxonomies" ];
  163. }
  164. public static DataView GetTaxonomiesForBrowsing( )
  165. {
  166. Debug.Enter( );
  167. DataTable taxonomies = GetTaxonomiesForBrowsingDataTable();
  168. Debug.Leave();
  169. return taxonomies.DefaultView;
  170. }
  171. public static DataView GetTaxonomiesForBrowsing( string filter, string sort )
  172. {
  173. Debug.Enter( );
  174. DataTable taxonomies = GetTaxonomiesForBrowsingDataTable();
  175. DataView view = new DataView( taxonomies, filter, sort, DataViewRowState.OriginalRows );
  176. Debug.Leave();
  177. return view;
  178. }
  179. ///********************************************************************************************************
  180. /// <summary>
  181. /// Used to determine if the current taxonomy object is valid for use in the User Interface for
  182. /// browsing purposes.
  183. ///
  184. /// Checks a flag in the database to see if the taxonomy is browsable.
  185. ///
  186. /// If flag 0x02 is set, then it is browsable.
  187. /// </summary>
  188. ///********************************************************************************************************
  189. /// <param name="tModelKey">tModelKey to get</param>
  190. ///********************************************************************************************************
  191. /// <returns>
  192. /// boolean indicating that the taxonomy is valid for browsing in the search via the User Interface
  193. /// </returns>
  194. ///********************************************************************************************************
  195. public static bool IsValidForBrowsing( string tModelKey )
  196. {
  197. bool r = false;
  198. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  199. sp.ProcedureName = "UI_isTaxonomyBrowsable";
  200. sp.Parameters.Add( "@tModelKey", SqlDbType.UniqueIdentifier );
  201. sp.Parameters.Add( "@isBrowsable", SqlDbType.TinyInt, ParameterDirection.Output );
  202. sp.Parameters.SetGuidFromKey( "@tModelKey", tModelKey );
  203. sp.ExecuteNonQuery();
  204. r = sp.Parameters.GetBool( "@isBrowsable" );
  205. sp.Close();
  206. return r;
  207. }
  208. }
  209. }