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.

246 lines
5.5 KiB

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Specialized;
  4. using System.Data;
  5. using System.Xml.Serialization;
  6. using UDDI;
  7. using UDDI.API.Business;
  8. using UDDI.Diagnostics;
  9. namespace UDDI.Replication
  10. {
  11. public class OperatorNodeCollection : CollectionBase
  12. {
  13. public void Get()
  14. {
  15. Get( true );
  16. }
  17. public void Get( bool activeOperatorsOnly )
  18. {
  19. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  20. sp.ProcedureName = "net_operators_get";
  21. SqlDataReaderAccessor reader = sp.ExecuteReader();
  22. try
  23. {
  24. this.Clear();
  25. while( reader.Read() )
  26. {
  27. OperatorStatus operatorStatus = (OperatorStatus)reader.GetShort( "operatorStatusID" );
  28. string name = reader.GetString( "name" );
  29. if( !activeOperatorsOnly ||
  30. OperatorStatus.New == operatorStatus ||
  31. OperatorStatus.Normal == operatorStatus )
  32. {
  33. this.Add(
  34. reader.GetGuidString( "operatorKey" ),
  35. operatorStatus,
  36. name,
  37. reader.GetString( "soapReplicationURL" ) );
  38. }
  39. else
  40. {
  41. Debug.Write(
  42. SeverityType.Info,
  43. CategoryType.Replication,
  44. String.Format(
  45. "Removing operator '{0}' with status '{1}' from list of replication operators",
  46. name,
  47. operatorStatus.ToString() ) );
  48. }
  49. }
  50. }
  51. finally
  52. {
  53. reader.Close();
  54. }
  55. }
  56. public OperatorNode this[ int index ]
  57. {
  58. get { return (OperatorNode)List[ index ]; }
  59. set { List[index] = value; }
  60. }
  61. public int Add( OperatorNode value )
  62. {
  63. return List.Add( value );
  64. }
  65. public int Add( string operatorNodeID, OperatorStatus operatorStatus, string name, string soapReplicationURL )
  66. {
  67. return List.Add( new OperatorNode( operatorNodeID, operatorStatus, name, soapReplicationURL ) );
  68. }
  69. public void Insert( int index, OperatorNode value )
  70. {
  71. List.Insert( index, value );
  72. }
  73. public int IndexOf( string operatorNodeID )
  74. {
  75. for( int i = 0; i < this.Count; i ++ )
  76. {
  77. if( 0 == String.Compare( operatorNodeID, ((OperatorNode)List[ i ]).OperatorNodeID, true ) )
  78. return i;
  79. }
  80. return -1;
  81. }
  82. public bool Contains( string operatorNodeID )
  83. {
  84. foreach( OperatorNode node in this )
  85. {
  86. if( 0 == String.Compare( operatorNodeID, node.OperatorNodeID, true ) )
  87. return true;
  88. }
  89. return false;
  90. }
  91. public void Remove( string operatorNodeID )
  92. {
  93. foreach( OperatorNode node in this )
  94. {
  95. if( 0 == String.Compare( operatorNodeID, node.OperatorNodeID, true ) )
  96. {
  97. List.Remove( node );
  98. return;
  99. }
  100. }
  101. }
  102. public void CopyTo( OperatorNode[] array, int index )
  103. {
  104. List.CopyTo( array, index );
  105. }
  106. }
  107. /// ********************************************************************
  108. /// public class OperatorNode
  109. /// --------------------------------------------------------------------
  110. /// <summary>
  111. /// </summary>
  112. /// ********************************************************************
  113. ///
  114. [XmlRoot( "operator", Namespace=UDDI.Replication.Constants.Namespace )]
  115. public class OperatorNode
  116. {
  117. //
  118. // Element: operatorNodeID
  119. //
  120. [XmlElement( "operatorNodeID" )]
  121. public string OperatorNodeID;
  122. //
  123. // Element: operatorStatus
  124. //
  125. [XmlElement( "operatorStatus" )]
  126. public UDDI.Replication.OperatorStatus OperatorStatus;
  127. //
  128. // Element: contact
  129. //
  130. private ContactCollection contacts;
  131. [XmlElement( "contact" )]
  132. public ContactCollection Contacts
  133. {
  134. get
  135. {
  136. if( null == contacts )
  137. contacts = new ContactCollection();
  138. return contacts;
  139. }
  140. set { contacts = value; }
  141. }
  142. //
  143. // Element: operatorCustodyName
  144. //
  145. [XmlElement( "operatorCustodyName" )]
  146. public string Name;
  147. //
  148. // Element: soapReplicationRootURL
  149. //
  150. [XmlElement( "soapReplicationRootURL" )]
  151. public string SoapReplicationURL;
  152. //
  153. // Element: certIssuerName
  154. //
  155. [XmlElement( "certIssuerName" )]
  156. public string CertIssuerName;
  157. //
  158. // Element: certSubjectName
  159. //
  160. [XmlElement( "certSubjectName" )]
  161. public string CertSubjectName;
  162. //
  163. // Element: certificate
  164. //
  165. [XmlElement( "certificate" )]
  166. public byte[] Certificate;
  167. public OperatorNode()
  168. {
  169. }
  170. public OperatorNode( string operatorNodeID )
  171. {
  172. this.OperatorNodeID = operatorNodeID;
  173. }
  174. public OperatorNode( string operatorNodeID, OperatorStatus operatorStatus, string name, string soapReplicationURL )
  175. {
  176. this.OperatorNodeID = operatorNodeID;
  177. this.OperatorStatus = operatorStatus;
  178. this.Name = name;
  179. this.SoapReplicationURL = soapReplicationURL;
  180. }
  181. public void Get()
  182. {
  183. Debug.Enter();
  184. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  185. sp.ProcedureName = "net_operator_get";
  186. sp.Parameters.Add( "@operatorKey", SqlDbType.UniqueIdentifier );
  187. sp.Parameters.SetGuidFromString( "@operatorKey", OperatorNodeID );
  188. SqlDataReaderAccessor reader = sp.ExecuteReader();
  189. try
  190. {
  191. if( reader.Read() )
  192. {
  193. OperatorStatus = (OperatorStatus)reader.GetShort( "operatorStatusID" );
  194. Name = reader.GetString( "name" );
  195. SoapReplicationURL = reader.GetString( "soapReplicationURL" );
  196. CertIssuerName = reader.GetString( "certIssuer" );
  197. CertSubjectName = reader.GetString( "certSubject" );
  198. Certificate = reader.GetBinary( "certificate" );
  199. }
  200. }
  201. finally
  202. {
  203. reader.Close();
  204. }
  205. Debug.Leave();
  206. }
  207. }
  208. }