/// <summary> /// Retrieve all the process agents of a given type from the database /// </summary> /// <returns>Array of objects that represent the retrieved static process agents</returns> public ProcessAgent[] GetProcessAgentsByType(string agentType) { ArrayList list = new ArrayList(); ProcessAgent agent = null; // create sql connection DbConnection connection = FactoryDB.GetConnection(); // create sql command // command executes the "RetrieveProcessAgentDescriptors" stored procedure DbCommand cmd = connection.CreateCommand(); cmd.CommandText = "GetProcessAgentsByType"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(FactoryDB.CreateParameter(cmd,"@agentType",agentType, DbType.AnsiString, 100)); // execute the command DbDataReader dataReader = null; try { connection.Open(); dataReader = cmd.ExecuteReader(); // add the agent to the list while (dataReader.Read()) { agent = readProcessAgent(dataReader); list.Add(agent); } } catch (DbException e) { writeEx(e); throw; } finally { connection.Close(); } ProcessAgent dummy = new ProcessAgent(); ProcessAgent[] agents = (ProcessAgent[])list.ToArray(dummy.GetType()); return agents; }
/// <summary> /// Retrieve all process agent records from the database /// </summary> /// <param name="guid">The Guid id of the static process agent</param> /// <returns>Object that represents the retrieved static process agent</returns> public ProcessAgent[] GetProcessAgents() { // create sql connection DbConnection connection = FactoryDB.GetConnection(); // create sql command // command executes the "RetrieveProcessAgentDescriptor" stored procedure DbCommand cmd = connection.CreateCommand(); cmd.CommandText= "GetProcessAgents"; cmd.CommandType = CommandType.StoredProcedure; // execute the command DbDataReader dataReader = null; try { connection.Open(); dataReader = cmd.ExecuteReader(); } catch (DbException e) { writeEx(e); throw; } ArrayList list = new ArrayList(); ProcessAgent agent = null; while (dataReader.Read()) { agent = readProcessAgent(dataReader); list.Add(agent); } connection.Close(); ProcessAgent dummy = new ProcessAgent(); ProcessAgent[] agents = (ProcessAgent[])list.ToArray(dummy.GetType()); return agents; }