private void DeployMissingPlugins(int agentId, IEnumerable <string> requiredPlugins) { AgentDeployer.log.DebugFormat("DeployMissingPlugins started, AgentId:{0}, RequiredPlugins:{1}", (object)agentId, (object)string.Join(",", requiredPlugins)); AgentManager agentManager = new AgentManager(this.agentInfoDal); AgentInfo agentInfo = agentManager.GetAgentInfo(agentId); if (agentInfo == null) { throw new ArgumentException(string.Format("Agent with Id:{0} not found", (object)agentId)); } foreach (string pluginId in agentInfo.get_Plugins().Where <AgentPluginInfo>((Func <AgentPluginInfo, bool>)(p => p.get_Status() == 5 || p.get_Status() == 12)).Select <AgentPluginInfo, string>((Func <AgentPluginInfo, string>)(p => p.get_PluginId())).ToArray <string>()) { AgentDeployer.log.DebugFormat("DeployMissingPlugins - Redeploying plugin {0}", (object)pluginId); agentManager.StartRedeployingPlugin(agentId, pluginId); } foreach (string pluginId in requiredPlugins.Where <string>((Func <string, bool>)(requiredPluginId => agentInfo.get_Plugins().All <AgentPluginInfo>((Func <AgentPluginInfo, bool>)(installedPlugin => installedPlugin.get_PluginId() != requiredPluginId))))) { AgentDeployer.log.DebugFormat("DeployMissingPlugins - Deploying plugin {0}", (object)pluginId); agentManager.StartDeployingPlugin(agentId, pluginId); } agentInfo = agentManager.GetAgentInfo(agentId); if (agentInfo == null || agentInfo.get_AgentStatus() != 8 && !agentInfo.get_Plugins().Any <AgentPluginInfo>((Func <AgentPluginInfo, bool>)(p => p.get_Status() == 3)) && !agentInfo.get_Plugins().Any <AgentPluginInfo>((Func <AgentPluginInfo, bool>)(p => p.get_Status() == 13))) { return; } AgentDeployer.log.Debug((object)"DeployMissingPlugins - Approve update"); agentManager.ApproveUpdate(agentId); }