public SqlStoredProcedureAccessor() { cmd = new SqlCommand(); cmd.Connection = ConnectionManager.GetConnection(); cmd.Transaction = ConnectionManager.GetTransaction(); cmd.CommandType = CommandType.StoredProcedure; paramAcc = new SqlParameterAccessor(cmd.Parameters); }
/// **************************************************************** /// public IsValidKey [static] /// ---------------------------------------------------------------- /// <summary> /// Checks to see if the entity associated with a key actually /// exists in the database. /// </summary> /// **************************************************************** /// // // TODO: This function need to be re-written // public static void IsValidKey(EntityType entityType, string key) { SqlCommand cmd = new SqlCommand("net_key_validate", ConnectionManager.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@entityTypeID", SqlDbType.TinyInt)).Direction = ParameterDirection.Input; cmd.Parameters.Add(new SqlParameter("@entityKey", SqlDbType.UniqueIdentifier)).Direction = ParameterDirection.Input; SqlParameterAccessor parmacc = new SqlParameterAccessor(cmd.Parameters); parmacc.SetShort("@entityTypeID", (short)entityType); // // Check for a tModel key vs other // if (key.ToLower().StartsWith("uuid:")) { if (entityType != EntityType.TModel) { //throw new UDDIException( ErrorType.E_invalidKeyPassed, "Only TModel Keys can start with uuid:" ); throw new UDDIException(ErrorType.E_invalidKeyPassed, "UDDI_ERROR_INVALID_TMODEL_KEY"); } parmacc.SetGuidFromKey("@entityKey", key); } else { if (EntityType.TModel == entityType) { //throw new UDDIException( ErrorType.E_invalidKeyPassed, "Only TModel Keys can start with uuid:" ); throw new UDDIException(ErrorType.E_invalidKeyPassed, "UDDI_ERROR_INVALID_TMODEL_KEY"); } try { parmacc.SetGuidFromString("@entityKey", key); } catch (Exception) { //throw new UDDIException( ErrorType.E_invalidKeyPassed, "Key has invalid format" ); throw new UDDIException(ErrorType.E_invalidKeyPassed, "UDDI_ERROR_INVALID_KEY_FORMAT"); } } cmd.ExecuteScalar(); }