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;
            }
        }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.InternalProcessRecord();
            string text = base.ValidateAndNormalizeAgentIdentity(this.Name);

            if (base.AgentExists(text))
            {
                base.WriteError(new ArgumentException(AgentStrings.AgentAlreadyExist(this.Name), "Name"), ErrorCategory.InvalidArgument, null);
            }
            Type      type      = this.ReflectAgentType(this.absoluteAssemblyPath, this.TransportAgentFactory);
            AgentInfo agentInfo = new AgentInfo(text, type.ToString(), this.TransportAgentFactory, this.absoluteAssemblyPath, false, false);

            if (base.TransportService == TransportService.FrontEnd && type != typeof(SmtpReceiveAgent))
            {
                base.WriteError(new InvalidOperationException(AgentStrings.AgentTypeNotSupportedOnFrontEnd(type.ToString())), ErrorCategory.InvalidOperation, null);
            }
            if (type == typeof(DeliveryAgent))
            {
                this.ValidateDeliveryAgent(agentInfo);
            }
            TransportAgent sendToPipeline = new TransportAgent(text, false, base.MExConfiguration.GetPublicAgentList().Count + 1, this.TransportAgentFactory, this.absoluteAssemblyPath);
            int            index          = base.MExConfiguration.GetPublicAgentList().Count + base.MExConfiguration.GetPreExecutionInternalAgents().Count;

            base.MExConfiguration.AgentList.Insert(index, agentInfo);
            base.Save();
            base.WriteObject(sendToPipeline);
            if (base.MissingConfigFile)
            {
                this.WriteWarning(AgentStrings.MissingConfigurationFileCreate(base.MExConfigPath));
            }
            this.WriteWarning(AgentStrings.ReleaseAgentBinaryReference);
            this.WriteWarning(AgentStrings.RestartServiceForChanges(base.GetTransportServiceName()));
            TaskLogger.LogExit();
        }
Beispiel #3
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     base.InternalProcessRecord();
     base.SetAgentEnabled(this.Identity.ToString(), true);
     base.Save();
     this.WriteWarning(AgentStrings.RestartServiceForChanges(base.GetTransportServiceName()));
     TaskLogger.LogExit();
 }
Beispiel #4
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);
        }