コード例 #1
0
        private string CreateAgentName()
        {
            int    agentCount    = _environment.GetAgentCount(_agentTypeArtifactId);
            string agentTypeName = _environment.GetTextIdByArtifactId(_agentTypeArtifactId);

            return(string.Format("{0} ({1})", agentTypeName, agentCount + 1));
        }
        public List <AgentsDesired> Compare()
        {
            List <AgentsDesired> outputList = new List <AgentsDesired>();
            string logString = "";

            int counter = _agentsDesiredList.Count - 1;

            while (counter >= 0)
            {
                //Declaring all of these to variables to make logging easier
                int    currentCount;
                string agentGuid    = _agentsDesiredList[counter].Guid;
                int    agentTypeId  = _environment.GetArtifactIdFromGuid(agentGuid);
                int    desiredCount = _agentsDesiredList[counter].Count;

                //Account for agents Resource Pool policy
                if (_agentsDesiredList[counter].RespectsResourcePool)
                {
                    currentCount = _environment.GetAgentCountByPool(agentTypeId, _poolId);
                }
                else
                {
                    currentCount = _environment.GetAgentCount(agentTypeId);
                }

                int difference = desiredCount - currentCount;

                logString += string.Format("AgentGuid: {0}, AgentTypeID {1}, Current Count: {2}, Desired Count: {3} Difference: {4}\r\n", agentGuid, agentTypeId, currentCount, desiredCount, difference);

                outputList.Add(new AgentsDesired
                {
                    Guid = _agentsDesiredList[counter].Guid,
                    RespectsResourcePool = _agentsDesiredList[counter].RespectsResourcePool,
                    Count = difference
                });

                counter -= 1;
            }
            _logger.LogDebug("Compare output--\r\n" + logString);
            return(outputList);
        }