//This method returns collection of Agent's objects with SQL Server only public static List <SqlServer> GetSqlServersToListFromCore(CoreConnectionCredentials coreCredentials) { var sqlServersList = new List <SqlServer>(); var coreClient = CoreConnector.GetFullCoreClient(coreCredentials); var protectedAgents = coreClient.AgentsManagement.GetProtectedAgents(); foreach (var agent in protectedAgents) { if ((agent.AgentType != AgentType.EsxServer) && (agent.AgentType != AgentType.EsxVirtualMachine) && agent.HasSqlInstance) { sqlServersList.Add(new SqlServer(agent.Descriptor.HostUri.Host, agent.DisplayName, agent.RepositoryName, agent.Descriptor.MetadataCredentials.DefaultCredentials.UserName, agent.Descriptor.MetadataCredentials.DefaultCredentials.PasswordDecrypted)); } } return(sqlServersList); }
//This method returns collection of Agent's objects with Exchange Server only public static List <ExchangeServer> GetExchangeServersToListFromCore(CoreConnectionCredentials coreCredentials) { var exchangeServersList = new List <ExchangeServer>(); var coreClient = CoreConnector.GetFullCoreClient(coreCredentials); var protectedAgents = coreClient.AgentsManagement.GetProtectedAgents(); foreach (var agent in protectedAgents) { if ((agent.AgentType != AgentType.EsxServer) && (agent.AgentType != AgentType.EsxVirtualMachine) && agent.HasExchangeInstance) { exchangeServersList.Add(new ExchangeServer(agent.Descriptor.HostUri.Host, agent.DisplayName, agent.RepositoryName, agent.Descriptor.MetadataCredentials.DefaultCredentials.UserName, coreClient.AgentsManagement.GetCachedAgentMetadataById(agent.Id.ToString()).FullyQualifiedDomainName.Remove(0, coreClient.AgentsManagement.GetCachedAgentMetadataById(agent.Id.ToString()).HostName.Length + 1), agent.Descriptor.MetadataCredentials.DefaultCredentials.PasswordDecrypted)); } } return(exchangeServersList); }
public static List <SqlServer> SqlServersList; //store list of sql servers // This method displays servers received from Core API to ListView public static void ServersToListView(CoreConnectionCredentials coreCredentials) { ServersList = CoreConnector.GetServersToListFromCore(coreCredentials); ExchangeServersList = CoreConnector.GetExchangeServersToListFromCore(coreCredentials); SqlServersList = CoreConnector.GetSqlServersToListFromCore(coreCredentials); }