private List <AgentInfo> GetAgentsFromReader(IDataReader reader) { List <AgentInfo> agentInfoList = new List <AgentInfo>(); AgentInfo agentInfo1 = (AgentInfo)null; while (reader.Read()) { OsType result1; if (!Enum.TryParse <OsType>(DatabaseFunctions.GetString(reader, "OSType"), true, out result1)) { result1 = (OsType)0; } AgentInfo agentInfo2 = new AgentInfo(); agentInfo2.set_AgentId(DatabaseFunctions.GetInt32(reader, "AgentId")); agentInfo2.set_AgentGuid(DatabaseFunctions.GetGuid(reader, "AgentGuid")); agentInfo2.set_NodeID(DatabaseFunctions.GetNullableInt32(reader, "NodeId")); agentInfo2.set_NodeSubType(DatabaseFunctions.GetString(reader, "ObjectSubType", (string)null)); agentInfo2.set_Uri(DatabaseFunctions.GetString(reader, "Uri")); agentInfo2.set_PollingEngineId(DatabaseFunctions.GetInt32(reader, "PollingEngineId")); agentInfo2.set_AgentStatus(DatabaseFunctions.GetInt32(reader, "AgentStatus")); agentInfo2.set_AgentStatusMessage(DatabaseFunctions.GetString(reader, "AgentStatusMessage")); agentInfo2.set_ConnectionStatus(DatabaseFunctions.GetInt32(reader, "ConnectionStatus")); agentInfo2.set_ConnectionStatusMessage(DatabaseFunctions.GetString(reader, "ConnectionStatusMessage")); agentInfo2.set_OsType(result1); agentInfo2.set_OsDistro(DatabaseFunctions.GetString(reader, "OSDistro")); AgentInfo agentInfo3 = agentInfo2; agentInfo3.set_Name(DatabaseFunctions.GetString(reader, "Name")); agentInfo3.set_HostName(DatabaseFunctions.GetString(reader, "HostName")); agentInfo3.set_IPAddress(DatabaseFunctions.GetString(reader, "IP")); Version result2; if (Version.TryParse(DatabaseFunctions.GetString(reader, "OSVersion"), out result2)) { agentInfo3.set_OsVersion(result2); } if (agentInfo1 == null || agentInfo1.get_AgentId() != agentInfo3.get_AgentId()) { agentInfoList.Add(agentInfo3); agentInfo1 = agentInfo3; } AgentPluginInfo agentPluginInfo1 = new AgentPluginInfo(); agentPluginInfo1.set_PluginId(DatabaseFunctions.GetString(reader, "PluginId", (string)null)); AgentPluginInfo agentPluginInfo2 = agentPluginInfo1; if (agentPluginInfo2.get_PluginId() != null) { agentPluginInfo2.set_Status(DatabaseFunctions.GetInt32(reader, "Status")); agentPluginInfo2.set_StatusMessage(DatabaseFunctions.GetString(reader, "StatusMessage")); agentInfo1.AddPlugin(agentPluginInfo2); } } return(agentInfoList); }
private AgentDeploymentInfo LoadAgentDeploymentInfo(int agentId) { AgentInfo agentInfo1 = new AgentManager(this.AgentInfoDal).GetAgentInfo(agentId); if (agentInfo1 != null) { string[] discoveryPluginIds = DiscoveryHelper.GetAgentDiscoveryPluginIds(); return(AgentDeploymentInfo.Calculate(agentInfo1, (IEnumerable <string>)discoveryPluginIds, (string)null)); } AgentDeploymentInfo agentDeploymentInfo = new AgentDeploymentInfo(); AgentInfo agentInfo2 = new AgentInfo(); agentInfo2.set_AgentId(agentId); agentDeploymentInfo.set_Agent(agentInfo2); agentDeploymentInfo.set_StatusInfo(new AgentDeploymentStatusInfo(agentId, (AgentDeploymentStatus)2, "Agent not found.")); return(agentDeploymentInfo); }