public List <AgentDataModel> GetAgentsFromDatabase()
        {
            List <AgentDataModel> agentList = new List <AgentDataModel>();

            try
            {
                _myConnection.Open();

                SqlCommand getAgents = new SqlCommand("getAgents", _myConnection);
                getAgents.CommandType = System.Data.CommandType.StoredProcedure;

                SqlDataReader myAgentsSet = getAgents.ExecuteReader();

                List <TypeDataModel> typeSet = new DatabaseConnectionMonitor(Properties.Settings.Default.ProdDatabase).GetTypesFromDatabase();

                while (myAgentsSet.Read())
                {
                    TypeDataModel type       = null;
                    int           tempTypeNr = (int)myAgentsSet["TypeNr"];
                    foreach (TypeDataModel temp in typeSet)
                    {
                        if (temp.TypeNr == tempTypeNr)
                        {
                            type = temp;
                        }
                    }
                    agentList.Add(new AgentDataModel((int)myAgentsSet["AgentNr"], myAgentsSet["Name"].ToString(), myAgentsSet["IPAddress"].ToString(), type, (int)myAgentsSet["Port"], (int)myAgentsSet["Status"], myAgentsSet["sysDesc"].ToString(), myAgentsSet["sysName"].ToString(), myAgentsSet["sysUptime"].ToString()));
                }
            }
            finally
            {
                _myConnection.Close();
            }
            return(agentList);
        }
Ejemplo n.º 2
0
 public AgentDataModel(int agentNr, String name, String iPAddress, TypeDataModel type, int port, int status, string sysDesc, string sysName, string sysUptime)
 {
     _agentNr   = agentNr;
     _name      = name;
     _iPAddress = iPAddress;
     _type      = type;
     _port      = port;
     _status    = status;
     _sysDesc   = sysDesc;
     _sysName   = sysName;
     _sysUptime = sysUptime;
 }
Ejemplo n.º 3
0
 public AgentDataModel(String name, String iPAddress, TypeDataModel type, int port)
 {
     _agentNr   = 0;
     _name      = name;
     _iPAddress = iPAddress;
     _type      = type;
     _port      = port;
     _status    = 1;
     _sysDesc   = "";
     _sysName   = "";
     _sysUptime = "";
 }