Exemplo n.º 1
0
        private void ExecutorMainForm_Load(object sender, EventArgs e)
        {
            //this should normally not create any problems, but then during design time it doesnt work, so we need to catch any exceptions
            //that may occur during design time.
            try
            {
                // avoid multiple instances
                bool  isOnlyInstance = false;
                Mutex mtx            = new Mutex(true, "AlchemiExecutorServiceController_Mutex", out isOnlyInstance);
                if (!isOnlyInstance)
                {
                    MessageBox.Show(this, "An instance of this application is already running. The program will now exit.", "Alchemi Executor Service Controller", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Application.Exit();
                }

                Logger.LogHandler += new LogEventHandler(this.LogHandler);

                //this is a service. just read the config.
                ExecutorContainer ec = new ExecutorContainer();
                ec.ReadConfig(false);
                Config = ec.Config;
                ec     = null;

                this.btConnect.Text    = "Start";
                this.btDisconnect.Text = "Stop";

                RefreshUIControls();
                btConnect.Focus();
            }
            catch {}
        }
Exemplo n.º 2
0
        public ExecutorService()
        {
            InitializeComponent();
            execContainer = new ExecutorContainer();
            // subscribe to events
            execContainer.GotDisconnected += new GotDisconnectedEventHandler(this.Executor_GotDisconnected);

            Logger.LogHandler += new LogEventHandler(this.Log);
        }
Exemplo n.º 3
0
        protected override void ResetExecutor()
        {
            ExecutorContainer ec = new ExecutorContainer();

            ec.ReadConfig(true);
            Config = ec.Config;
            ec     = null;
            RefreshUIControls();
        }
Exemplo n.º 4
0
        public ExecutorContainerWrapper()
        {
            _container = new ExecutorContainer();
            _container.ReadConfig(false);
            Config = _container.Config;

            //_container.NonDedicatedExecutingStatusChanged += new NonDedicatedExecutingStatusChangedEventHandler(this.RefreshUIControls);
            _container.GotDisconnected  += new GotDisconnectedEventHandler(this.Executor_GotDisconnected);
            _container.ExecConnectEvent += new ExecutorConnectStatusEventHandler(this.ExecutorConnect_Status);


            //now application should refresh ui with config values
        }
Exemplo n.º 5
0
        private void ExecutorMainForm_Load(object sender, EventArgs e)
        {
            Logger.LogHandler += new LogEventHandler(this.LogHandler);

            //not a service. normal exec startup mode.
            _container = new ExecutorContainer();
            _container.ReadConfig(false);
            Config = _container.Config;

            this.btConnect.Text    = "Connect";
            this.btDisconnect.Text = "Disconnect";

            _container.NonDedicatedExecutingStatusChanged += new NonDedicatedExecutingStatusChangedEventHandler(this.RefreshUIControls);
            _container.GotDisconnected += new GotDisconnectedEventHandler(this.Executor_GotDisconnected);
            //_container.ExecConnectEvent += new ExecutorConnectStatusEventHandler(this.ExecutorConnect_Status);

            ConnectOnStartup();

            RefreshUIControls();
            btConnect.Focus();
        }
Exemplo n.º 6
0
        protected static int Execute(ExecuteOptions options)
        {
            System.Console.WriteLine($"Execute permissions' checks based on {options.Source}.");
            //Parse the model
            var container = new ParserContainer();

            container.Initialize(Path.GetExtension(options.Source));

            var modelFactory = new ModelFactory();
            var collection   = modelFactory.Instantiate(options.Source, container);

            var types = collection.Select(o => o.GetType()).Distinct();

            //Execute the checks
            foreach (var type in types)
            {
                var executorContainer = new ExecutorContainer();
                executorContainer.Initialize();
                var executorFactory = executorContainer.Retrieve(type);

                var textWriters = new List <TextWriter>()
                {
                    System.Console.Out,
                };
                if (!string.IsNullOrEmpty(options.Output))
                {
                    textWriters.Add(new StreamWriter(options.Output));
                }

                var engine = executorFactory.Instantiate(textWriters);

                var objects = collection.Where(o => o.GetType() == type);
                engine.Execute(objects);
            }

            return(0);
        }