Exemple #1
0
        private void StartMAControllers()
        {
            this.cancellationToken = new CancellationTokenSource();
            List <Task> startTasks = new List <Task>();

            foreach (MAControllerConfiguration c in Program.ActiveConfig.ManagementAgents)
            {
                if (c.IsMissing)
                {
                    logger.Warn($"{c.ManagementAgentName}: Skipping management agent because it is missing from the Sync Engine");
                    continue;
                }


                if (this.controllers.ContainsKey(c.ManagementAgentID))
                {
                    logger.Trace($"Starting {c.ManagementAgentName}");
                    startTasks.Add(Task.Factory.StartNew(() =>
                    {
                        MAController e = this.controllers[c.ManagementAgentID];
                        lock (e)
                        {
                            e.Start(c);
                        }
                    }, this.cancellationToken.Token));
                }
                else
                {
                    logger.Error($"Cannot start management agent controller '{c.ManagementAgentName}' because the management agent was not found");
                }
            }

            Task.WaitAll(startTasks.ToArray(), this.cancellationToken.Token);
        }
Exemple #2
0
        public void Stop(Guid managementAgentID, bool cancelRun)
        {
            MAController e = this.GetContorllerOrThrow(managementAgentID);

            lock (e)
            {
                e.Stop(cancelRun);
            }
        }
Exemple #3
0
        public void CancelRun(Guid managementAgentID)
        {
            MAController e = this.GetContorllerOrThrow(managementAgentID);

            lock (e)
            {
                e.CancelRun();
            }
        }
Exemple #4
0
        public void AddToExecutionQueue(Guid managementAgentID, string runProfileName)
        {
            MAController e = this.GetContorllerOrThrow(managementAgentID);

            if (e.ControlState != ControlState.Running)
            {
                return;
            }

            e.AddPendingActionIfNotQueued(runProfileName, "Manual entry");
        }
Exemple #5
0
        private void InitializeMAControllers()
        {
            this.controllers = new Dictionary <Guid, MAController>();

            foreach (ManagementAgent ma in ManagementAgent.GetManagementAgents())
            {
                MAController x = new MAController(ma);
                x.StateChanged += this.X_StateChanged;
                x.RunProfileExecutionComplete += this.X_RunProfileExecutionComplete;
                x.MessageLogged += this.X_MessageLogged;

                this.controllers.Add(ma.ID, x);
            }
        }
Exemple #6
0
        public void Start(Guid managementAgentID)
        {
            MAControllerConfiguration c = Program.ActiveConfig.ManagementAgents.GetItemOrDefault(managementAgentID);

            if (c == null)
            {
                throw new InvalidOperationException($"There was no active configuration found for the management agent {managementAgentID}");
            }

            MAController e = this.GetContorllerOrThrow(managementAgentID);

            lock (e)
            {
                logger.Trace($"Starting {e.ManagementAgentName}");
                e.Start(c);
            }
        }
Exemple #7
0
        public IList <Guid> GetManagementAgentsPendingRestart()
        {
            List <Guid> restartItems = new List <Guid>();

            foreach (MAControllerConfiguration newItem in Program.ActiveConfig.ManagementAgents)
            {
                if (!this.controllers.ContainsKey(newItem.ManagementAgentID))
                {
                    continue;
                }

                MAController e = this.controllers[newItem.ManagementAgentID];

                if ((e.ControlState == ControlState.Disabled || e.Configuration == null) && newItem.Disabled)
                {
                    continue;
                }

                if (e.ControlState == ControlState.Disabled && !newItem.Disabled)
                {
                    restartItems.Add(newItem.ManagementAgentID);
                    continue;
                }

                if (e.ControlState == ControlState.Stopped)
                {
                    continue;
                }

                if (e.Configuration == null)
                {
                    continue;
                }

                if (e.Configuration.Version != newItem.Version)
                {
                    restartItems.Add(newItem.ManagementAgentID);
                }
            }

            return(restartItems);
        }