public static int GetTaxonomyID(string tModelKey) { int taxonomyID; Debug.Enter(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "UI_getTaxonomies"; sp.Parameters.Add("@tModelKey", SqlDbType.UniqueIdentifier); sp.Parameters.SetGuidFromKey("@tModelKey", tModelKey); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { if (reader.Read()) { taxonomyID = reader.GetInt("taxonomyID"); } else { taxonomyID = -1; } } finally { reader.Close(); } Debug.Leave(); return(taxonomyID); }
public string Get() { string AuthorizedName; SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_publisher_assertions_get"); sp.Parameters.Add("@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID); sp.Parameters.Add("@authorizedName", SqlDbType.NVarChar, UDDI.Constants.Lengths.AuthorizedName, ParameterDirection.Output); sp.Parameters.SetString("@PUID", Context.User.ID); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { while (reader.Read()) { Add( reader.GetGuidString("fromKey"), reader.GetGuidString("toKey"), reader.GetGuidString("keyName"), reader.GetGuidString("keyValue"), reader.GetKeyFromGuid("tModelKey")); } } finally { reader.Close(); } AuthorizedName = sp.Parameters.GetString("@authorizedName"); return(AuthorizedName); }
public static string BusinessName(string businessKey) { string name = null; Debug.Enter(); SqlCommand cmd = new SqlCommand("net_businessEntity_names_get", ConnectionManager.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = ConnectionManager.GetTransaction(); cmd.Parameters.Add(new SqlParameter("@businessKey", SqlDbType.UniqueIdentifier)).Direction = ParameterDirection.Input; SqlParameterAccessor paramacc = new SqlParameterAccessor(cmd.Parameters); paramacc.SetGuidFromString("@businessKey", businessKey); SqlDataReaderAccessor reader = new SqlDataReaderAccessor(cmd.ExecuteReader()); try { if (reader.Read()) { name = reader.GetString("name"); } } finally { reader.Close(); } Debug.Leave(); return(name); }
public void Get() { Debug.Enter(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_operator_get"; sp.Parameters.Add("@operatorKey", SqlDbType.UniqueIdentifier); sp.Parameters.SetGuidFromString("@operatorKey", OperatorNodeID); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { if (reader.Read()) { OperatorStatus = (OperatorStatus)reader.GetShort("operatorStatusID"); Name = reader.GetString("name"); SoapReplicationURL = reader.GetString("soapReplicationURL"); CertIssuerName = reader.GetString("certIssuer"); CertSubjectName = reader.GetString("certSubject"); Certificate = reader.GetBinary("certificate"); } } finally { reader.Close(); } Debug.Leave(); }
public void Get(string fromKey, string toKey) { SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_businessEntity_assertions_get"; sp.Parameters.Add("@fromKey", SqlDbType.UniqueIdentifier); sp.Parameters.Add("@toKey", SqlDbType.UniqueIdentifier); sp.Parameters.Add("@completionStatus", SqlDbType.Int); sp.Parameters.SetGuidFromString("@fromKey", fromKey); sp.Parameters.SetGuidFromString("@toKey", toKey); sp.Parameters.SetInt("@completionStatus", (int)CompletionStatusType.Complete); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { while (reader.Read()) { KeyedReferences.Add( reader.GetString("keyName"), reader.GetString("keyValue"), reader.GetKeyFromGuid("tModelKey")); } } finally { reader.Close(); } }
public void GetForCurrentPublisher() { SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_publisher_businessInfos_get"); sp.Parameters.Add("@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID); sp.Parameters.SetString("@PUID", Context.User.ID); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { while (reader.Read()) { Add(reader.GetGuidString("businessKey")); } } finally { reader.Close(); } foreach (BusinessInfo businessInfo in this) { businessInfo.Get(true); } }
public void Get(long contactID) { // // Create a command object to invoke the stored procedure net_get_contacts // SqlStoredProcedureAccessor cmd = new SqlStoredProcedureAccessor("net_contact_emails_get"); // // Add parameters and set values // cmd.Parameters.Add("@contactID", SqlDbType.BigInt, ParameterDirection.Input); cmd.Parameters.SetLong("@contactID", contactID); // // Run the stored procedure // SqlDataReaderAccessor reader = cmd.ExecuteReader(); try { #if never while (reader.Read()) { // // Construct a new Email from the data in this row // this.Add(dracc.GetString(EmailIndex), dracc.GetString(UseTypeIndex)); } #endif } finally { reader.Close(); } }
static ArrayList GetBusinessEntities() { ArrayList businessKeyList = new ArrayList(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_find_businessKeysWithDiscoveryURLs"; SqlDataReaderAccessor reader = sp.ExecuteReader(); ArrayList businessEntities = new ArrayList(); try { while (reader.Read()) { BusinessEntity businessEntity = new BusinessEntity(reader.GetGuidString(0)); businessEntities.Add(businessEntity); } } finally { reader.Close(); } return(businessEntities); }
public void Get(long addressID) { SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_address_addressLines_get"; sp.Parameters.Add("@addressID", SqlDbType.BigInt); sp.Parameters.SetLong("@addressID", addressID); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { while (reader.Read()) { Add( reader.GetString("addressLine"), reader.GetString("keyName"), reader.GetString("keyValue")); } } finally { reader.Close(); } }
public HighWaterMarkDetail Get() { HighWaterMarkDetail detail = new HighWaterMarkDetail(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_highWaterMarks_get"; SqlDataReaderAccessor reader = sp.ExecuteReader(); try { while (reader.Read()) { detail.HighWaterMarks.Add( reader.GetString("operatorKey"), reader.GetLong("USN")); } } finally { reader.Close(); } return(detail); }
public void Get() { Debug.Enter(); // // Retrieve the taxonomy // SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_taxonomy_get"); sp.Parameters.Add("@tModelKey", SqlDbType.UniqueIdentifier); sp.Parameters.Add("@flag", SqlDbType.Int, ParameterDirection.InputOutput); sp.Parameters.SetGuidFromKey("@tModelKey", tModelKey); sp.Parameters.SetNull("@flag"); sp.ExecuteScalar(); // // Set the flag value // CategorizationSchemeFlag = sp.Parameters.GetInt("@flag"); // // Retrieve the taxonomy values // CategoryValues.Clear(); SqlStoredProcedureAccessor sp2 = new SqlStoredProcedureAccessor("net_taxonomyValues_get"); sp2.Parameters.Add("@tModelKey", SqlDbType.UniqueIdentifier); sp2.Parameters.SetGuidFromKey("@tModelKey", tModelKey); SqlDataReaderAccessor reader = sp2.ExecuteReader(); try { while (reader.Read()) { CategoryValues.Add(reader.GetString("keyName"), reader.GetString("keyValue"), reader.GetString("parentKeyValue"), ((reader.GetInt("valid") == 1) ? true : false)); } } finally { reader.Close(); } Debug.Leave(); }
public void Get() { Debug.Enter(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "UI_getPublisher"; sp.Parameters.Add("@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID); sp.Parameters.SetString("@PUID", Puid); SqlDataReaderAccessor reader = sp.ExecuteReader(); Exists = false; try { if (reader.Read()) { int flag; IsoLangCode = reader.GetString(1); Name = reader.GetString(2); Email = reader.GetString(3); Phone = reader.GetString(4); CompanyName = reader.GetString(5); AltPhone = reader.GetString(6); AddressLine1 = reader.GetString(7); AddressLine2 = reader.GetString(8); City = reader.GetString(9); StateProvince = reader.GetString(10); PostalCode = reader.GetString(11); Country = reader.GetString(12); flag = reader.GetInt(13); SecurityToken = reader.GetGuidString(14); TrackPassport = (0x00 == (flag & 0x02)); Validated = (0x01 == (flag & 0x01)); Exists = true; } } finally { reader.Close(); } Debug.Leave(); }
public void Get(bool activeOperatorsOnly) { SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_operators_get"; SqlDataReaderAccessor reader = sp.ExecuteReader(); try { this.Clear(); while (reader.Read()) { OperatorStatus operatorStatus = (OperatorStatus)reader.GetShort("operatorStatusID"); string name = reader.GetString("name"); if (!activeOperatorsOnly || OperatorStatus.New == operatorStatus || OperatorStatus.Normal == operatorStatus) { this.Add( reader.GetGuidString("operatorKey"), operatorStatus, name, reader.GetString("soapReplicationURL")); } else { Debug.Write( SeverityType.Info, CategoryType.Replication, String.Format( "Removing operator '{0}' with status '{1}' from list of replication operators", name, operatorStatus.ToString())); } } } finally { reader.Close(); } }
/// **************************************************************** /// public Get /// ---------------------------------------------------------------- /// <summary> /// Populates the collection with all binding templates related to /// the specified service. /// </summary> /// ---------------------------------------------------------------- /// <param name="serviceKey"> /// Key of the parent service. A Guid formatted as a string. /// </param> /// ---------------------------------------------------------------- /// <returns> /// /// </returns> /// ---------------------------------------------------------------- /// <remarks> /// /// </remarks> /// **************************************************************** /// public void Get(string serviceKey) { // // Get all the bindings associated with the specified service // SqlStoredProcedureAccessor cmd = new SqlStoredProcedureAccessor("net_businessService_bindingTemplates_get"); cmd.Parameters.Add("@serviceKey", SqlDbType.UniqueIdentifier, ParameterDirection.Input); cmd.Parameters.SetGuidFromString("@serviceKey", serviceKey); SqlDataReaderAccessor reader = cmd.ExecuteReader(); try { Read(reader); #if never // // Get the keys of the services for this business ID // while (rdr.Read()) { Add(rdr.GetGuid(0).ToString()); } #endif } finally { reader.Close(); } Populate(); #if never // // Populate each binding // foreach (BindingTemplate bt in this) { bt.Get(); } #endif }
public void Get(long contactID) { // // Create a command object to invoke the stored procedure net_get_contacts // SqlStoredProcedureAccessor cmd = new SqlStoredProcedureAccessor("net_contact_phones_get"); // // Add parameters and set values // cmd.Parameters.Add("@contactID", SqlDbType.BigInt, ParameterDirection.Input); cmd.Parameters.SetLong("@contactID", contactID); // // Run the stored procedure // SqlDataReaderAccessor reader = cmd.ExecuteReader(); try { Read(reader); #if never // // Phones for this contact will be contained in the resultset // while (rdr.Read()) { // // construct a new contact from the data in this row, fully populate contact and add to collection // this.Add(dracc.GetString(PhoneIndex), dracc.GetString(UseTypeIndex)); } #endif } finally { reader.Close(); } }
public void Get(long addressID) { SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_address_addressLines_get"; sp.Parameters.Add("@addressID", SqlDbType.BigInt); sp.Parameters.SetLong("@addressID", addressID); // // Run the stored procedure // SqlDataReaderAccessor reader = sp.ExecuteReader(); try { if (1 == Context.ApiVersionMajor) { while (reader.Read()) { AddressLines.Add(reader.GetString("addressLine")); } } else { while (reader.Read()) { AddressLines.Add( reader.GetString("addressLine"), reader.GetString("keyName"), reader.GetString("keyValue")); } } } finally { reader.Close(); } }
public void Get(string parentKey, EntityType parentType) { SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); switch (parentType) { case EntityType.BusinessEntity: sp.ProcedureName = "net_businessEntity_names_get"; sp.Parameters.Add("@businessKey", SqlDbType.UniqueIdentifier); sp.Parameters.SetGuidFromString("@businessKey", parentKey); break; case EntityType.BusinessService: sp.ProcedureName = "net_businessService_names_get"; sp.Parameters.Add("@serviceKey", SqlDbType.UniqueIdentifier); sp.Parameters.SetGuidFromString("@serviceKey", parentKey); break; default: // throw new UDDIException( ErrorType.E_fatalError, "Unexpected parent entity type '" + parentType.ToString() + "'" ); throw new UDDIException(ErrorType.E_fatalError, "UDDI_ERROR_UNEXPECTED_PARENT_ENTITY_TYPE", parentType.ToString()); } SqlDataReaderAccessor reader = sp.ExecuteReader(); try { Read(reader); } finally { reader.Close(); } }
protected static OperatorNodeCollection GetOperators(bool filter, int status) { OperatorNodeCollection operators = new OperatorNodeCollection(); SqlStoredProcedureAccessor sp = null; SqlDataReaderAccessor data = null; try { sp = new SqlStoredProcedureAccessor("UI_operatorsList_get"); if (filter && -1 != status) { sp.Parameters.Add("@StatusID", SqlDbType.TinyInt); sp.Parameters.SetInt("@StatusID", status); } data = sp.ExecuteReader(); while (data.Read()) { operators.Add(data.GetString("OperatorKey"), (OperatorStatus)data.GetInt("OperatorStatusID"), data.GetString("Name"), data.GetString("soapReplicationUrl")); } } finally { if (null != data) { data.Close(); } if (null != sp) { sp.Close(); } } return(operators); }
static string GetPUIDForBusinessEntity(string businessKey) { SqlStoredProcedureAccessor puidSP = new SqlStoredProcedureAccessor(); puidSP.ProcedureName = "net_getPUIDForBusinessEntity"; puidSP.Parameters.Add("@businessKey", SqlDbType.UniqueIdentifier); puidSP.Parameters.SetGuidFromString("@businessKey", businessKey); SqlDataReaderAccessor reader = puidSP.ExecuteReader(); string puid = ""; try { reader.Read(); puid = reader.GetString(0); } finally { reader.Close(); } return(puid); }
public void Get(CompletionStatusType completionStatus) { SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_publisher_assertionStatus_get"); sp.Parameters.Add("@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID); sp.Parameters.SetString("@PUID", Context.User.ID); if (CompletionStatusType.Uninitialized != completionStatus) { // // If the completion status was not specified get all // of the assertions by not specifying a completionStatus value // in the stored procedure. // sp.Parameters.Add("@completionStatus", SqlDbType.Int); sp.Parameters.SetInt("@completionStatus", (int)completionStatus); } SqlDataReaderAccessor reader = sp.ExecuteReader(); try { while (reader.Read()) { KeyedReference keyedReference = new KeyedReference( reader.GetString("keyName"), reader.GetString("keyValue"), reader.GetKeyFromGuid("tModelKey")); CompletionStatusType status = (CompletionStatusType)reader.GetInt("flag"); string fromKey = reader.GetGuidString("fromKey"); string toKey = reader.GetGuidString("toKey"); int ownerFlag = reader.GetInt("ownerFlag"); KeysOwned keysOwned = new KeysOwned(); if (0x02 == (ownerFlag & 0x02)) { keysOwned.FromKey = fromKey; } if (0x01 == (ownerFlag & 0x01)) { keysOwned.ToKey = toKey; } this.Add( new AssertionStatusItem( status, fromKey, toKey, keyedReference, keysOwned)); } } finally { reader.Close(); } }
/// <summary> /// Override OnLoad to do our initialization. /// </summary> /// <param name="args">Passed by ASP.NET, we don't use it.</param> protected override void OnLoad(EventArgs args) { // // See if we already have a cached search, if we do, we'll use it. We only cache search params, // result count and the search type, we'll get values from our database all the time. // results = Session[StateParamNames.Results] as ResultsCache; // // If we don't have search results, get them // if (null == results) { // // Instantiate our results cache // results = new ResultsCache(); // // Run our query based on the search type and display the results // string temp = Request[StateParamNames.SearchType]; if (null == temp || temp.Length == 0) { Response.Redirect("error.aspx"); } results.searchType = ( SearchType )Int32.Parse(temp); if (results.searchType == SearchType.SearchByService || results.searchType == SearchType.SearchByProvider) { results.searchParams = GetSearchParams(); } } // // Search type determines what sproc to run. // SqlStoredProcedureAccessor searchCommand = new SqlStoredProcedureAccessor(); switch (results.searchType) { case SearchType.SearchByService: { searchCommand.ProcedureName = "VS_AWR_services_get"; searchCommand.Parameters.Add("@serviceName", SqlDbType.NVarChar, 450); searchCommand.Parameters.SetString("@serviceName", results.searchParams); break; } case SearchType.SearchByProvider: { searchCommand.ProcedureName = "VS_AWR_businesses_get"; searchCommand.Parameters.Add("@businessName", SqlDbType.NVarChar, 450); searchCommand.Parameters.SetString("@businessName", results.searchParams); break; } case SearchType.SearchFromBrowse: { searchCommand.ProcedureName = "VS_AWR_categorization_get"; searchCommand.Parameters.Add("@tModelKey", SqlDbType.UniqueIdentifier); searchCommand.Parameters.Add("@keyValue", SqlDbType.NVarChar, 255); searchCommand.Parameters.SetGuidFromString("@tModelKey", GetTModelKey()); searchCommand.Parameters.SetString("@keyValue", GetKeyValue()); break; } } // // Get the results that we are supposed to display. // SqlDataReaderAccessor resultsReader = searchCommand.ExecuteReader(); results.numResults = uddi_resultsList.ParseResults(resultsReader); resultsReader.Close(); // // Store our results in session state // Session[StateParamNames.Results] = results; DisplaySearchMessages(results.numResults); }
/// **************************************************************** /// public Get /// ---------------------------------------------------------------- /// <summary> /// Retrieves the bindingTemplate details from the database. /// </summary> /// ---------------------------------------------------------------- /// <returns> /// </returns> /// ---------------------------------------------------------------- /// <remarks> /// The bindingKey must be set prior to execution of this call. /// </remarks> /// **************************************************************** /// public override void Get() { Debug.Enter(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_bindingTemplate_get_batch"); sp.Parameters.Add("@bindingKey", SqlDbType.UniqueIdentifier); sp.Parameters.Add("@serviceKey", SqlDbType.UniqueIdentifier, ParameterDirection.Output); sp.Parameters.Add("@URLTypeID", SqlDbType.TinyInt, ParameterDirection.Output); sp.Parameters.Add("@accessPoint", SqlDbType.NVarChar, UDDI.Constants.Lengths.AccessPoint, ParameterDirection.Output); sp.Parameters.Add("@hostingRedirector", SqlDbType.UniqueIdentifier, ParameterDirection.Output); sp.Parameters.SetGuidFromString("@bindingKey", BindingKey); SqlDataReaderAccessor reader = null; ArrayList instanceIds = new ArrayList(); try { // // net_bindingTemplate_get will return the objects contained in a business in the following order: // // - descriptions // - tmodel instance infos reader = sp.ExecuteReader(); // // Read the descriptions // Descriptions.Read(reader); // // Read the tmodel instance infos // if (true == reader.NextResult()) { instanceIds = TModelInstanceInfos.Read(reader); } } finally { if (null != reader) { reader.Close(); } } // // These calls will make separate sproc calls, so we have to close our reader first. // TModelInstanceInfos.Populate(instanceIds); // // Get output parameters // ServiceKey = sp.Parameters.GetGuidString("@serviceKey"); AccessPoint.URLType = (URLType)sp.Parameters.GetInt("@URLTypeID"); AccessPoint.Value = sp.Parameters.GetString("@accessPoint"); HostingRedirector.BindingKey = sp.Parameters.GetGuidString("@hostingRedirector"); #if never SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_bindingTemplate_get"); sp.Parameters.Add("@bindingKey", SqlDbType.UniqueIdentifier); sp.Parameters.Add("@serviceKey", SqlDbType.UniqueIdentifier, ParameterDirection.Output); sp.Parameters.Add("@URLTypeID", SqlDbType.TinyInt, ParameterDirection.Output); sp.Parameters.Add("@accessPoint", SqlDbType.NVarChar, UDDI.Constants.Lengths.AccessPoint, ParameterDirection.Output); sp.Parameters.Add("@hostingRedirector", SqlDbType.UniqueIdentifier, ParameterDirection.Output); sp.Parameters.SetGuidFromString("@bindingKey", BindingKey); sp.ExecuteNonQuery(); ServiceKey = sp.Parameters.GetGuidString("@serviceKey"); AccessPoint.URLType = (URLType)sp.Parameters.GetInt("@URLTypeID"); AccessPoint.Value = sp.Parameters.GetString("@accessPoint"); HostingRedirector.BindingKey = sp.Parameters.GetGuidString("@hostingRedirector"); // // Get all contained objects. // Descriptions.Get(BindingKey, EntityType.BindingTemplate); TModelInstanceInfos.Get(BindingKey); #endif QueryLog.Write(QueryType.Get, EntityType.BindingTemplate); }
public void Get(string parentKey, EntityType parentType, KeyedReferenceType keyedReferenceType) { Debug.Enter(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); switch (parentType) { case EntityType.BusinessEntity: if (KeyedReferenceType.CategoryBag == keyedReferenceType) { sp.ProcedureName = "net_businessEntity_categoryBag_get"; } else { sp.ProcedureName = "net_businessEntity_identifierBag_get"; } sp.Parameters.Add("@businessKey", SqlDbType.UniqueIdentifier); sp.Parameters.SetGuidFromString("@businessKey", parentKey); break; case EntityType.BusinessService: Debug.Assert( KeyedReferenceType.CategoryBag == keyedReferenceType, "Unexpected keyed reference type '" + keyedReferenceType.ToString() + "' for parent entity type '" + parentType.ToString() + "'"); sp.ProcedureName = "net_businessService_categoryBag_get"; sp.Parameters.Add("@serviceKey", SqlDbType.UniqueIdentifier); sp.Parameters.SetGuidFromString("@serviceKey", parentKey); break; case EntityType.TModel: if (KeyedReferenceType.CategoryBag == keyedReferenceType) { sp.ProcedureName = "net_tModel_categoryBag_get"; } else { sp.ProcedureName = "net_tModel_identifierBag_get"; } sp.Parameters.Add("@tModelKey", SqlDbType.UniqueIdentifier); sp.Parameters.SetGuidFromKey("@tModelKey", parentKey); break; default: throw new UDDIException(ErrorType.E_fatalError, "UDDI_ERROR_UNEXPECTED_PARENT_ENTITY_TYPE", parentType.ToString()); } SqlDataReaderAccessor reader = sp.ExecuteReader(); try { Read(reader); #if never while (reader.Read()) { Add( reader.GetString("keyName"), reader.GetString("keyValue"), reader.GetKeyFromGuid("tModelKey")); } #endif } finally { reader.Close(); } Debug.Leave(); }
private void CheckCertificate(SoapMessage message) { HttpClientCertificate httpCert = HttpContext.Current.Request.ClientCertificate; X509Certificate requestCert = new X509Certificate(httpCert.Certificate); Debug.Verify(!Utility.StringEmpty(httpCert.Issuer), "UDDI_ERROR_FATALERROR_CLIENTCERTREQUIRED"); Debug.Verify(!Utility.StringEmpty(httpCert.Subject), "UDDI_ERROR_FATALERROR_CLIENTCERTREQUIRED"); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_operatorCert_get"); sp.Parameters.Add("@certSerialNo", SqlDbType.NVarChar, UDDI.Constants.Lengths.CertSerialNo); sp.Parameters.SetString("@certSerialNo", requestCert.GetSerialNumberString()); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { if (reader.Read()) { Context.RemoteOperator = reader.GetGuidString("operatorKey"); byte[] operatorCertRaw = reader.GetBinary("certificate"); byte[] requestCertRaw = httpCert.Certificate; Debug.Verify( null != operatorCertRaw, "UDDI_ERROR_FATALERROR_CLIENTCERTNOTSTORED", ErrorType.E_fatalError, Context.RemoteOperator); if (operatorCertRaw.Length != requestCertRaw.Length) { throw new UDDIException( ErrorType.E_unknownUser, "UDDI_ERROR_UNKNOWNUSER_UNKOWNCERT"); } for (int i = 0; i < operatorCertRaw.Length; i++) { if (operatorCertRaw[i] != requestCertRaw[i]) { throw new UDDIException( ErrorType.E_unknownUser, "UDDI_ERROR_UNKNOWNUSER_UNKOWNCERT"); } } /* * TODO: Check to see if this works instead * * * X509Certificate operatorCert = new X509Certificate( operatorCertRaw ); * X509Certificate requestCert = new X509Certificate( requestCertRaw ); * * if( !requestCert.Equals( operatorCert ) ) * { * throw new UDDIException( * ErrorType.E_unknownUser, * "Unknown certificate" ); * } */ } else { throw new UDDIException( ErrorType.E_unknownUser, "UDDI_ERROR_UNKNOWNUSER_UNKOWNCERT"); } } finally { reader.Close(); } }
public void Get(string businessKey) { // // This procedure add the discoveryURLs that were persisted to the database // this does not include the default discoveryURL, it is added by the the businessEntity.Get() // method since it has the visibility of the operator name who owns the entity. // // // Create a command object to invoke the stored procedure // SqlStoredProcedureAccessor cmd = new SqlStoredProcedureAccessor("net_businessEntity_discoveryURLs_get"); // // Add parameters // cmd.Parameters.Add("@businessKey", SqlDbType.UniqueIdentifier); cmd.Parameters.SetGuidFromString("@businessKey", businessKey); // // Execute query // SqlDataReaderAccessor reader = cmd.ExecuteReader(); try { Read(reader); } finally { reader.Close(); } #if never // // This procedure add the discoveryURLs that were persisted to the database // this does not include the default discoveryURL, it is added by the the businessEntity.Get() // method since it has the visibility of the operator name who owns the entity. // const int UseTypeIndex = 0; const int UrlIndex = 1; // // Create a command object to invoke the stored procedure // SqlCommand cmd = new SqlCommand("net_businessEntity_discoveryURLs_get", ConnectionManager.GetConnection()); cmd.Transaction = ConnectionManager.GetTransaction(); cmd.CommandType = CommandType.StoredProcedure; // // Add parameters // cmd.Parameters.Add(new SqlParameter("@businessKey", SqlDbType.UniqueIdentifier)); SqlParameterAccessor paramacc = new SqlParameterAccessor(cmd.Parameters); paramacc.SetGuidFromString("@businessKey", businessKey); // // Execute query // SqlDataReader rdr = cmd.ExecuteReader(); try { SqlDataReaderAccessor rdracc = new SqlDataReaderAccessor(rdr); // // The discoveryUrls will be contained in the result set // while (rdr.Read()) { string useType = rdracc.GetString(UseTypeIndex); if (null == useType) { useType = ""; } Add(rdracc.GetString(UrlIndex), useType); } } finally { rdr.Close(); } #endif }
public void Get(long contactID) { ArrayList addressIDs = new ArrayList(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_contact_addresses_get"); sp.Parameters.Add("@contactID", SqlDbType.BigInt); sp.Parameters.SetLong("@contactID", contactID); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { addressIDs = Read(reader); } finally { reader.Close(); } Populate(addressIDs); #if never ArrayList addressIDs = new ArrayList(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_contact_addresses_get"; sp.Parameters.Add("@contactID", SqlDbType.BigInt); sp.Parameters.SetLong("@contactID", contactID); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { if (1 == Context.ApiVersionMajor) { while (reader.Read()) { addressIDs.Add(reader.GetLong("addressID")); Add(reader.GetString("sortCode"), reader.GetString("useType")); } } else { while (reader.Read()) { addressIDs.Add(reader.GetLong("addressID")); Add(reader.GetString("sortCode"), reader.GetString("useType"), reader.GetKeyFromGuid("tModelKey")); } } } finally { reader.Close(); } // // Retrieve the addressLines for this address // int index = 0; foreach (Address address in this) { address.Get((long)addressIDs[index]); index++; } #endif }
public static void ExportOperatorCertificate() { if (null == operatorKey) { operatorKey = Config.GetString("OperatorKey"); } if (File.Exists(filename) && !overwrite) { Console.Write("Overwrite '{0}' [y/n]? ", filename); int choice = Console.Read(); if ('y' != (char)choice && 'Y' != (char)choice) { Console.WriteLine(); Console.WriteLine("Operation aborted."); return; } } byte[] data = null; // // Retrieve the certificate. // SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_operator_get"; sp.Parameters.Add("@operatorKey", SqlDbType.UniqueIdentifier); sp.Parameters.SetGuidFromString("@operatorKey", operatorKey); SqlDataReaderAccessor reader = sp.ExecuteReader(); try { if (reader.Read()) { data = reader.GetBinary("certificate"); } } finally { reader.Close(); } FileStream file = File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.None); try { int filesize = (int)data.Length; file.Write(data, 0, filesize); Console.WriteLine("Wrote {0} byte(s) to certificate file '{1}'.\r\nSource: {{{2}}}", filesize, filename, operatorKey); } finally { file.Close(); } }
/// **************************************************************** /// public Get /// ---------------------------------------------------------------- /// <summary> /// </summary> /// **************************************************************** /// public ChangeRecordDetail Get() { Debug.VerifySetting("OperatorKey"); ChangeRecordDetail detail = new ChangeRecordDetail(); try { // // Get the list of known operators. // StringCollection operators = new StringCollection(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_operators_get"; SqlDataReaderAccessor reader = sp.ExecuteReader(); try { while (reader.Read()) { operators.Add(reader.GetGuidString("operatorKey")); } } finally { reader.Close(); } // // Set the search criteria for change records. // foreach (string operatorKey in operators) { long startUSN; long stopUSN; startUSN = 0; foreach (ChangeRecordVector mark in ChangesAlreadySeen) { if (0 == String.Compare(operatorKey, mark.NodeID, true)) { startUSN = mark.OriginatingUSN + 1; break; } } stopUSN = System.Int64.MaxValue; foreach (ChangeRecordVector mark in ResponseLimitVector) { if (0 == String.Compare(operatorKey, mark.NodeID, true)) { stopUSN = mark.OriginatingUSN; break; } } FindChangeRecords.SetRange(operatorKey, startUSN, stopUSN); } // // Retrieve the change records. // int limit = Config.GetInt("Replication.ResponseLimitCountDefault"); if (ResponseLimitCount >= 0 && ResponseLimitCount <= limit) { limit = ResponseLimitCount; } reader = FindChangeRecords.RetrieveResults(limit); try { while (reader.Read()) { XmlSerializer serializer = null; switch ((ChangeRecordPayloadType)reader.GetShort("changeTypeID")) { case ChangeRecordPayloadType.ChangeRecordNull: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordNull)); break; case ChangeRecordPayloadType.ChangeRecordNewData: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordNewData)); break; case ChangeRecordPayloadType.ChangeRecordDelete: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordDelete)); break; case ChangeRecordPayloadType.ChangeRecordPublisherAssertion: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordPublisherAssertion)); break; case ChangeRecordPayloadType.ChangeRecordHide: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordHide)); break; case ChangeRecordPayloadType.ChangeRecordDeleteAssertion: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordDeleteAssertion)); break; case ChangeRecordPayloadType.ChangeRecordAcknowledgement: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordAcknowledgement)); break; case ChangeRecordPayloadType.ChangeRecordCorrection: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordCorrection)); break; } StringReader stringReader = new StringReader(reader.GetString("changeData")); try { ChangeRecord changeRecord = new ChangeRecord(); changeRecord.AcknowledgementRequested = (reader.GetInt("flag") & (int)ChangeRecordFlags.AcknowledgementRequested) > 0; changeRecord.ChangeID.NodeID = reader.GetString("OperatorKey"); changeRecord.ChangeID.OriginatingUSN = reader.GetLong("USN"); ChangeRecordBase changeRecordBase = ( ChangeRecordBase )serializer.Deserialize(stringReader); if (changeRecordBase is ChangeRecordCorrection) { // // The query to find change records will do correction 'fixups'. That is, the changeData of this // change record will be replaced with the changeData from the correction. The problem with this is // that the original change data will now look like a correction. To distinguish these types of // change records, we look to see if the OriginatingUSN's match. If the OriginatingUSN's match, // we want they payload of the change record in this correction. This payload will contain the // corrected data that we want. // ChangeRecordCorrection changeRecordCorrection = ( ChangeRecordCorrection )changeRecordBase; if (changeRecordCorrection.ChangeRecord.ChangeID.OriginatingUSN == changeRecord.ChangeID.OriginatingUSN) { changeRecordBase = changeRecordCorrection.ChangeRecord.Payload; } } changeRecord.Payload = changeRecordBase; detail.ChangeRecords.Add(changeRecord); } finally { stringReader.Close(); } } } finally { reader.Close(); } } catch (Exception e) { Debug.OperatorMessage( SeverityType.Error, CategoryType.Replication, OperatorMessageType.None, "Could not retrieve change records:\r\n" + e.ToString()); FindChangeRecords.CleanUp(); throw; } return(detail); }
static ArrayList GetChangeRecordsForEntity(BusinessEntity businessEntity) { string contextID = Guid.NewGuid().ToString(); string operatorKey = Config.GetString("OperatorKey"); ArrayList changeRecords = new ArrayList(); SqlDataReaderAccessor resultsReader = null; try { // // Get all the ChangeRecordNewData change records associated with this entity. // SqlStoredProcedureAccessor findSP = new SqlStoredProcedureAccessor(); findSP.ProcedureName = "net_find_changeRecordsByChangeType"; findSP.Parameters.Add("@contextID", SqlDbType.UniqueIdentifier); findSP.Parameters.Add("@operatorKey", SqlDbType.UniqueIdentifier); findSP.Parameters.Add("@entityKey", SqlDbType.UniqueIdentifier); findSP.Parameters.Add("@changeTypeID", SqlDbType.TinyInt); findSP.Parameters.Add("@rows", SqlDbType.Int, ParameterDirection.Output); findSP.Parameters.SetGuidFromString("@contextID", contextID); findSP.Parameters.SetGuidFromString("@operatorKey", operatorKey); findSP.Parameters.SetGuidFromString("@entityKey", businessEntity.BusinessKey); findSP.Parameters.SetShort("@changeTypeID", ( short )ChangeRecordPayloadType.ChangeRecordNewData); findSP.ExecuteNonQuery(); // // Retrieve results // SqlStoredProcedureAccessor resultsSP = new SqlStoredProcedureAccessor(); resultsSP.ProcedureName = "net_find_changeRecords_commit"; resultsSP.Parameters.Add("@contextID", SqlDbType.UniqueIdentifier); resultsSP.Parameters.Add("@responseLimitCount", SqlDbType.Int); resultsSP.Parameters.SetGuidFromString("@contextID", contextID); resultsSP.Parameters.SetInt("@responseLimitCount", 0); // // Read our results and create change records from them. // resultsReader = resultsSP.ExecuteReader(); while (resultsReader.Read()) { ChangeRecord changeRecord = CreateChangeRecord(resultsReader); if (null != changeRecord) { changeRecords.Add(changeRecord); } else { throw new Exception("Could not create change record!"); } } } catch { // // Cleanup on failure. // SqlStoredProcedureAccessor cleanupSP = new SqlStoredProcedureAccessor(); cleanupSP.ProcedureName = "net_find_changeRecords_cleanup"; cleanupSP.Parameters.Add("@contextID", SqlDbType.UniqueIdentifier); cleanupSP.Parameters.SetGuidFromString("@contextID", contextID); cleanupSP.ExecuteNonQuery(); } finally { if (null != resultsReader) { resultsReader.Close(); } } return(changeRecords); }
ChangeRecord CreateChangeRecord(SqlDataReaderAccessor reader) { ChangeRecord changeRecord = null; try { while (reader.Read()) { XmlSerializer serializer = null; switch ((ChangeRecordPayloadType)reader.GetShort("changeTypeID")) { case ChangeRecordPayloadType.ChangeRecordNull: serializer = new XmlSerializer(typeof(ChangeRecordNull)); break; case ChangeRecordPayloadType.ChangeRecordNewData: serializer = new XmlSerializer(typeof(ChangeRecordNewData)); break; case ChangeRecordPayloadType.ChangeRecordDelete: serializer = new XmlSerializer(typeof(ChangeRecordDelete)); break; case ChangeRecordPayloadType.ChangeRecordPublisherAssertion: serializer = new XmlSerializer(typeof(ChangeRecordPublisherAssertion)); break; case ChangeRecordPayloadType.ChangeRecordHide: serializer = new XmlSerializer(typeof(ChangeRecordHide)); break; case ChangeRecordPayloadType.ChangeRecordDeleteAssertion: serializer = new XmlSerializer(typeof(ChangeRecordDeleteAssertion)); break; case ChangeRecordPayloadType.ChangeRecordAcknowledgement: serializer = new XmlSerializer(typeof(ChangeRecordAcknowledgement)); break; case ChangeRecordPayloadType.ChangeRecordCorrection: serializer = new XmlSerializer(typeof(ChangeRecordCorrection)); break; } StringReader stringReader = new StringReader(reader.GetString("changeData")); try { changeRecord = new ChangeRecord(); changeRecord.AcknowledgementRequested = (reader.GetInt("flag") & (int)ChangeRecordFlags.AcknowledgementRequested) > 0; changeRecord.ChangeID.NodeID = reader.GetString("OperatorKey"); changeRecord.ChangeID.OriginatingUSN = reader.GetLong("USN"); ChangeRecordBase changeRecordBase = ( ChangeRecordBase )serializer.Deserialize(stringReader); if (changeRecordBase is ChangeRecordCorrection) { // // The query to find change records will do correction 'fixups'. That is, the changeData of this // change record will be replaced with the changeData from the correction. The problem with this is // that the original change data will now look like a correction. To distinguish these types of // change records, we look to see if the OriginatingUSN's match. If the OriginatingUSN's match, // we want they payload of the change record in this correction. This payload will contain the // corrected data that we want. // ChangeRecordCorrection changeRecordCorrection = ( ChangeRecordCorrection )changeRecordBase; if (changeRecordCorrection.ChangeRecord.ChangeID.OriginatingUSN == changeRecord.ChangeID.OriginatingUSN) { changeRecordBase = changeRecordCorrection.ChangeRecord.Payload; } } changeRecord.Payload = changeRecordBase; } finally { stringReader.Close(); } } } finally { reader.Close(); } return(changeRecord); }