Ejemplo n.º 1
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.InternalProcessRecord();
            this.cleanIdentity = base.ValidateAndNormalizeAgentIdentity(this.Identity.ToString());
            if (!base.AgentExists(this.cleanIdentity))
            {
                base.WriteError(new ArgumentException(AgentStrings.AgentNotFound(this.Identity.ToString()), "Identity"), ErrorCategory.InvalidArgument, null);
            }
            IList <AgentInfo> publicAgentList = base.MExConfiguration.GetPublicAgentList();

            if (this.Priority != null)
            {
                if (this.Priority < 1 || this.Priority > publicAgentList.Count)
                {
                    base.WriteError(new ArgumentOutOfRangeException(AgentStrings.PriorityOutOfRange(publicAgentList.Count.ToString())), ErrorCategory.InvalidArgument, null);
                }
                foreach (AgentInfo agentInfo in publicAgentList)
                {
                    if (string.Compare(agentInfo.AgentName, this.cleanIdentity, StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        base.MExConfiguration.AgentList.Remove(agentInfo);
                        int index = this.Priority.Value - 1 + base.MExConfiguration.GetPreExecutionInternalAgents().Count;
                        base.MExConfiguration.AgentList.Insert(index, agentInfo);
                        base.Save();
                        this.WriteWarning(AgentStrings.RestartServiceForChanges(base.GetTransportServiceName()));
                        TaskLogger.LogExit();
                        return;
                    }
                }
                base.WriteError(new ArgumentException(AgentStrings.AgentNotFound(this.Identity.ToString()), "Identity"), ErrorCategory.InvalidArgument, null);
                return;
            }
        }
Ejemplo n.º 2
0
        internal void SetAgentEnabled(string identity, bool enabled)
        {
            string strB = this.ValidateAndNormalizeAgentIdentity(identity);

            if (this.mexConfig != null)
            {
                foreach (AgentInfo agentInfo in this.mexConfig.GetPublicAgentList())
                {
                    if (string.Compare(agentInfo.AgentName, strB, StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        agentInfo.Enabled = enabled;
                        return;
                    }
                }
            }
            base.WriteError(new ArgumentException(AgentStrings.AgentNotFound(identity), "Identity"), ErrorCategory.InvalidArgument, null);
        }
Ejemplo n.º 3
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.InternalProcessRecord();
            string strB = base.ValidateAndNormalizeAgentIdentity(this.Identity.ToString());

            foreach (AgentInfo agentInfo in base.MExConfiguration.GetPublicAgentList())
            {
                if (string.Compare(agentInfo.AgentName, strB, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    base.MExConfiguration.AgentList.Remove(agentInfo);
                    base.Save();
                    this.WriteWarning(AgentStrings.RestartServiceForChanges(base.GetTransportServiceName()));
                    TaskLogger.LogExit();
                    return;
                }
            }
            base.WriteError(new ArgumentException(AgentStrings.AgentNotFound(this.Identity.ToString()), "Identity"), ErrorCategory.InvalidArgument, null);
        }