Ejemplo n.º 1
0
        public void Run()
        {
            // var code = new StreamReader(Resources.ResourceManager.GetStream("TextFile1.py")).ReadToEnd();
            _controller            = new ScriptController(false);
            _controller.OnMessage += (sender, message) =>
            {
                //Console.WriteLine(message);
                // Console.WriteLine(String.Format("[{0:HH:MM:ss:fff}][SCRIPT]:{1}", DateTime.Now, message.Trim()));
                Console.WriteLine(String.Format("{0}", message.Trim()));
            };
            var            code    = Resources.ResourceManager.GetString("ScriptHeader1");
            dynamic        handler = null;
            IScriptContext ctx;

            try
            {
                if (string.IsNullOrEmpty(script))
                {
                    script = code;
                    ctx    = _controller.CreateScriptContextFromString(script);
                    ctx.Execute();
                }
                else
                {
                    ctx = _controller.CreateScriptContextFromFile(script);
                    ctx.ExecuteString(code);
                    ctx.Execute();
                }



                handler = ctx.Scope.CreateHandler();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }


            _mainProcess = new PyProcessContext(ctx, handler,
                                                _processFactory,
                                                command,
                                                CommandArguments,
                                                workingDirectory,
                                                _commandParameters);


            _mainProcess.Start();

            ctx.FlushBuffer();
            // Console.ReadKey();
        }
Ejemplo n.º 2
0
        public void Run()
        {
            // var code = new StreamReader(Resources.ResourceManager.GetStream("TextFile1.py")).ReadToEnd();
            _controller = new ScriptController(false);
            _controller.OnMessage += (sender, message) =>
                {
                    //Console.WriteLine(message);
                   // Console.WriteLine(String.Format("[{0:HH:MM:ss:fff}][SCRIPT]:{1}", DateTime.Now, message.Trim()));
                    Console.WriteLine(String.Format("{0}", message.Trim()));

                };
            var code = Resources.ResourceManager.GetString("ScriptHeader1");
            dynamic handler = null;
            IScriptContext ctx;
            try
            {

                if (string.IsNullOrEmpty(script))
                {
                    script = code;
                    ctx = _controller.CreateScriptContextFromString(script);
                    ctx.Execute();
                }
                else
                {
                    ctx = _controller.CreateScriptContextFromFile(script);
                    ctx.ExecuteString(code);
                    ctx.Execute();
                }

                handler = ctx.Scope.CreateHandler();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            _mainProcess = new PyProcessContext(ctx, handler,
                _processFactory,
                command,
                CommandArguments,
                workingDirectory,
                _commandParameters);

            _mainProcess.Start();

            ctx.FlushBuffer();
               // Console.ReadKey();
        }