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.

233 lines
6.5 KiB

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Globalization;
  5. using UDDI.API;
  6. using UDDI;
  7. using UDDI.Diagnostics;
  8. namespace UDDI.Web
  9. {
  10. public class Lookup
  11. {
  12. public static string TModelName( string tModelKey )
  13. {
  14. Debug.Enter();
  15. SqlCommand cmd = new SqlCommand( "net_tModel_get", ConnectionManager.GetConnection() );
  16. cmd.CommandType = CommandType.StoredProcedure;
  17. cmd.Transaction = ConnectionManager.GetTransaction();
  18. cmd.Parameters.Add( new SqlParameter( "@tModelKey", SqlDbType.UniqueIdentifier ) ).Direction = ParameterDirection.Input;
  19. cmd.Parameters.Add( new SqlParameter( "@operatorName", SqlDbType.NVarChar, UDDI.Constants.Lengths.OperatorName ) ).Direction = ParameterDirection.Output;
  20. cmd.Parameters.Add( new SqlParameter( "@authorizedName", SqlDbType.NVarChar, UDDI.Constants.Lengths.AuthorizedName ) ).Direction = ParameterDirection.Output;
  21. cmd.Parameters.Add( new SqlParameter( "@name", SqlDbType.NVarChar, UDDI.Constants.Lengths.Name ) ).Direction = ParameterDirection.Output;
  22. cmd.Parameters.Add( new SqlParameter( "@overviewURL", SqlDbType.NVarChar, UDDI.Constants.Lengths.OverviewURL ) ).Direction = ParameterDirection.Output;
  23. SqlParameterAccessor paramacc = new SqlParameterAccessor( cmd.Parameters );
  24. paramacc.SetGuidFromKey( "@tModelKey", tModelKey );
  25. cmd.ExecuteNonQuery();
  26. Debug.Leave();
  27. return paramacc.GetString( "@name" );
  28. }
  29. public static string BusinessName( string businessKey )
  30. {
  31. string name = null;
  32. Debug.Enter();
  33. SqlCommand cmd = new SqlCommand( "net_businessEntity_names_get", ConnectionManager.GetConnection() );
  34. cmd.CommandType = CommandType.StoredProcedure;
  35. cmd.Transaction = ConnectionManager.GetTransaction();
  36. cmd.Parameters.Add( new SqlParameter( "@businessKey", SqlDbType.UniqueIdentifier ) ).Direction = ParameterDirection.Input;
  37. SqlParameterAccessor paramacc = new SqlParameterAccessor( cmd.Parameters );
  38. paramacc.SetGuidFromString( "@businessKey", businessKey );
  39. SqlDataReaderAccessor reader = new SqlDataReaderAccessor( cmd.ExecuteReader() );
  40. try
  41. {
  42. if( reader.Read() )
  43. name = reader.GetString( "name" );
  44. }
  45. finally
  46. {
  47. reader.Close();
  48. }
  49. Debug.Leave();
  50. return name;
  51. }
  52. public static DataView IdentifierTModels( string filter, string sort )
  53. {
  54. DataView view = new DataView( GetIdentifierTModelsTable(), filter, sort, DataViewRowState.OriginalRows );
  55. return view;
  56. }
  57. public static DataView IdentifierTModels()
  58. {
  59. return GetIdentifierTModelsTable().DefaultView;
  60. }
  61. //
  62. // This method is a work around to remove the Owning-Business
  63. //
  64. public static DataView IdentifierTModelsFiltered()
  65. {
  66. DataTable tModels = GetIdentifierTModelsTable();
  67. for( int i = 0; i < tModels.Rows.Count; i ++ )
  68. {
  69. DataRow row = tModels.Rows[ i ];
  70. if( (new Guid( "4064C064-6D14-4F35-8953-9652106476A9" ).Equals( (Guid)row[ "tModelKey" ] ) ))
  71. {
  72. tModels.Rows.Remove( row );
  73. break;
  74. }
  75. }
  76. return tModels.DefaultView;
  77. }
  78. protected static DataTable GetIdentifierTModelsTable()
  79. {
  80. Debug.Enter();
  81. DataSet tModels = new DataSet();
  82. SqlCommand cmd = new SqlCommand( "UI_getIdentifierTModels", ConnectionManager.GetConnection() );
  83. cmd.CommandType = CommandType.StoredProcedure;
  84. cmd.Transaction = ConnectionManager.GetTransaction();
  85. SqlDataAdapter adapter = new SqlDataAdapter( cmd );
  86. adapter.Fill( tModels, "tModels" );
  87. //
  88. // Add the general keywords taxonomy
  89. //
  90. //string tModelKey = Config.GetString( "TModelKey.GeneralKeywords" );
  91. //
  92. //if( null != tModelKey )
  93. //{
  94. // Guid guidGeneralKeywords = new Guid( Conversions.GuidStringFromKey( tModelKey ) );
  95. //
  96. // tModels.Tables[ "tModels" ].Rows.Add(
  97. // new object[] {
  98. // guidGeneralKeywords,
  99. // Localization.GetString( "TAXONOMY_MISC" )
  100. // } );
  101. //}
  102. //
  103. // Remove the operators taxonomy.
  104. //
  105. Guid guidOperators = new Guid( Conversions.GuidStringFromKey( Config.GetString( "TModelKey.Operators" ) ) );
  106. for( int i = 0; i < tModels.Tables[ "tModels" ].Rows.Count; i ++ )
  107. {
  108. DataRow row = tModels.Tables[ "tModels" ].Rows[ i ];
  109. if( guidOperators == (Guid)row[ "tModelKey" ] )
  110. {
  111. tModels.Tables[ "tModels" ].Rows.Remove( row );
  112. break;
  113. }
  114. }
  115. Debug.Leave();
  116. return tModels.Tables[ "tModels" ];
  117. }
  118. public static DataView GetLanguages()
  119. {
  120. Debug.Enter();
  121. DataSet languages = new DataSet();
  122. /*
  123. * BUG: 722086
  124. *
  125. * Removed logic to read from the database. We now use the CultureInfo.GetCultures() method
  126. * to get all available languages.
  127. *
  128. SqlCommand cmd = new SqlCommand( "UI_getLanguages", ConnectionManager.GetConnection() );
  129. cmd.CommandType = CommandType.StoredProcedure;
  130. cmd.Transaction = ConnectionManager.GetTransaction();
  131. SqlDataAdapter adapter = new SqlDataAdapter( cmd );
  132. adapter.Fill( languages, "languages" );
  133. */
  134. languages.Tables.Add( "languages" );
  135. languages.Tables[ "languages" ].Columns.Add( "isoLangCode" );
  136. languages.Tables[ "languages" ].Columns.Add( "language" );
  137. CultureInfo[] cultures = CultureInfo.GetCultures( CultureTypes.AllCultures );
  138. foreach( CultureInfo ci in cultures )
  139. {
  140. //
  141. // Check for invariat culture, and add all others.
  142. //
  143. if( !Utility.StringEmpty( ci.Name ) )
  144. languages.Tables[ "languages" ].LoadDataRow(
  145. new object[]{ ci.Name.ToLower(),ci.Name },true );
  146. }
  147. Debug.Leave();
  148. return languages.Tables[ "languages" ].DefaultView;
  149. }
  150. public static string GetLanguageName( string isoLangCode )
  151. {
  152. Debug.Enter();
  153. /*
  154. * BUG: 722086
  155. *
  156. SqlCommand cmd = new SqlCommand( "UI_getLanguages", ConnectionManager.GetConnection() );
  157. cmd.CommandType = CommandType.StoredProcedure;
  158. cmd.Transaction = ConnectionManager.GetTransaction();
  159. cmd.Parameters.Add( new SqlParameter( "@isoLangCode", SqlDbType.VarChar, UDDI.Constants.Lengths.IsoLangCode ) ).Direction = ParameterDirection.Input;
  160. cmd.Parameters[ "@isoLangCode" ].Value = isoLangCode;
  161. Debug.Leave();
  162. */
  163. try
  164. {
  165. CultureInfo ci = new CultureInfo( isoLangCode );
  166. return ci.Name;
  167. }
  168. catch
  169. {
  170. return isoLangCode;
  171. }
  172. //return (string)cmd.ExecuteScalar();
  173. }
  174. }
  175. }