Exemplo n.º 1
0
        public RunSourceForm_copy(IRunSource runSource, ITrace trace, XmlConfig config, RunSourceRestartParameters runSourceParameters)
        {
            _trace = trace;

            try
            {
                Initialize();

                _tabResultMessage = tab_message;
                _tabResultGrid = tab_result2;
                _tabResultTree = tab_result4;

                //this.Icon = Properties.Resources.app;
                //string title = config.Get("RunsourceTitle");
                //if (title != null)
                //    __title = title;

                //tc_result.SelectedTab = _tabResultMessage;

                //cGrid.Culture = CultureInfo.CurrentUICulture;

                //_gridMaxWidth = _config.Get("GridMaxWidth").zParseAs<int>();
                //_gridMaxHeight = _config.Get("GridMaxHeight").zParseAs<int>();
                //_dataTableMaxImageWidth = _config.Get("DataTableMaxImageWidth").zParseAs<int>();
                //_dataTableMaxImageHeight = _config.Get("DataTableMaxImageHeight").zParseAs<int>();

                //initRunSource();
                //SetFileSaved();
            }
            catch (Exception ex)
            {
                _trace.WriteError(ex);
                zerrf.ErrorMessageBox(ex);
            }
        }
Exemplo n.º 2
0
        public RunSourceForm_copy(IRunSource runSource, ITrace trace, XmlConfig config, RunSourceRestartParameters runSourceParameters)
        {
            _trace = trace;

            try
            {
                Initialize();

                _tabResultMessage = tab_message;
                _tabResultGrid    = tab_result2;
                _tabResultTree    = tab_result4;

                //this.Icon = Properties.Resources.app;
                //string title = config.Get("RunsourceTitle");
                //if (title != null)
                //    __title = title;

                //tc_result.SelectedTab = _tabResultMessage;

                //cGrid.Culture = CultureInfo.CurrentUICulture;

                //_gridMaxWidth = _config.Get("GridMaxWidth").zParseAs<int>();
                //_gridMaxHeight = _config.Get("GridMaxHeight").zParseAs<int>();
                //_dataTableMaxImageWidth = _config.Get("DataTableMaxImageWidth").zParseAs<int>();
                //_dataTableMaxImageHeight = _config.Get("DataTableMaxImageHeight").zParseAs<int>();

                //initRunSource();
                //SetFileSaved();
            }
            catch (Exception ex)
            {
                _trace.WriteError(ex);
                zerrf.ErrorMessageBox(ex);
            }
        }
Exemplo n.º 3
0
        private void Test_RunSource3(IRunSource runSource)
        {
            string   s   = GetSource();
            DateTime dt1 = DateTime.Now;

            WriteMessage("{0:HH:mm:ss} RunSource\r\n", dt1);
            //Exe(new fExe(RunSource));
            Test_RunSource(runSource, s);

            DateTime dt2;

            for (int i = 0; i < 6; i++)
            {
                WriteMessage("wait 1 min\r\n");
                Thread.Sleep(60000);
                dt2 = DateTime.Now;
                WriteMessage("{0:HH:mm:ss}-{1} KeepAlive\r\n", dt2, TimeSpanToString(dt2.Subtract(dt1)));
                //runSource.KeepAlive();
            }

            dt2 = DateTime.Now;
            WriteMessage("{0:HH:mm:ss}-{1} RunSource\r\n", dt2, TimeSpanToString(dt2.Subtract(dt1)));
            //Exe(new fExe(RunSource));
            Test_RunSource(runSource, s);
        }
Exemplo n.º 4
0
        //static int Main(string[] args)
        static void Main()
        {
            try
            {
                XmlConfig config = new XmlConfig();
                FormatInfo.SetInvariantCulture();
                Application.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                RemoteRunSource remoteRunSource = new RemoteRunSource();
                remoteRunSource.RunsourceDllFilename = config.GetExplicit("RunsourceDllFilename");
                remoteRunSource.RunsourceClassName   = config.GetExplicit("RunsourceClassName");
                remoteRunSource.TraceClassName       = config.GetExplicit("TraceClassName");
                // ATTENTION si CreateRunSourceDomain = true runsource.launch.exe ne peut pas mettre à jour runsource.runsource.exe
                remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs <bool>(false);
                IRunSource runSource = remoteRunSource.GetRunSource();
                runSource.AllowMultipleExecution = config.Get("AllowMultipleExecution").zTryParseAs(false);
                // ATTENTION Trace exists in both 'runsource.runsource.exe' and 'runsource.dll'
                // donc il faut utiliser RemoteRunSource.GetTrace()
                ITrace trace = remoteRunSource.GetTrace();
                trace.SetWriter(config.Get("Log"), config.Get("Log/@option").zTextDeserialize(FileOption.None));

                // ATTENTION appeler DeleteGeneratedAssemblies() après SetRunSourceConfig()
                //RunSourceForm form = new RunSourceForm(runSource, trace, config, GetRunSourceRestartParameters());
                RunSourceForm_v3 form = new RunSourceForm_v3(runSource, trace, config, GetRunSourceRestartParameters());

                form.SetRestartRunsource += FormSetRestartRunsource;
                Application.Run(form);
                SetRunSourceRestartParameters();
            }
            catch (Exception ex)
            {
                zerrf.ErrorMessageBox(ex);
            }
        }
Exemplo n.º 5
0
        public RunSourceForm(IRunSource runSource, XmlConfig config, RunSourceRestartParameters runSourceParameters)
        {
            _runSource = runSource;
            _config = config;
            _runSourceParameters = runSourceParameters;

            // http://stackoverflow.com/questions/9056418/resources-getobjectthis-icon-crashes-application-on-windows-xp
            // pour ne pas avoir une exection avec :
            // this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            // Thread.Sleep(100);
            // dont work

            InitializeComponent();
            this.Icon = Properties.Resources.app;
            initGrid();
            //initTestMenu();
            tb_source.ConfigurationManager.CustomLocation = @"ScintillaNET.xml";
            tb_source.ConfigurationManager.Language = "cs";
            tc_result.SelectedTab = tab_message;
            //ActiveControl = me_source;
            ActiveControl = tb_source;

            cGrid.Culture = CultureInfo.CurrentUICulture;

            //_gridMaxWidth = _config.Get<int>("GridMaxWidth");
            _gridMaxWidth = _config.Get("GridMaxWidth").zParseAs<int>();
            _gridMaxHeight = _config.Get("GridMaxHeight").zParseAs<int>();
            _dataTableMaxImageWidth = _config.Get("DataTableMaxImageWidth").zParseAs<int>();
            _dataTableMaxImageHeight = _config.Get("DataTableMaxImageHeight").zParseAs<int>();

            initRunSource();
            InitLog();
            SetFileSaved();
        }
Exemplo n.º 6
0
        //public RunSourceFormExe(IRunSource runSource, ITrace trace, XmlConfig config, RunSourceRestartParameters runSourceParameters)
        public RunSourceFormExe(IRunSource runSource, XmlConfig config, RemoteRunSource remoteRunSource, RunSourceRestartParameters runSourceParameters)
        {
            _runSource       = runSource;
            _remoteRunSource = remoteRunSource;

            TraceManager.Current.SetViewer(TraceWrited);
            remoteRunSource.GetTraceManager().SetViewer(TraceWrited);

            _config = config;
            _runSourceParameters = runSourceParameters;

            _source.TextChanged += source_TextChanged;

            CreateMenu();
            CreateTopTools();
            this.InitializeForm();
            InitExe();
            InitMenu();
            UpdateRunSourceStatus();
            Try(SetKeyboardShortcuts);
            this.KeyPreview   = true;
            this.Load        += RunSourceForm_Load;
            this.FormClosing += RunSourceForm_FormClosing;
            this.FormClosed  += RunSourceForm_FormClosed;
            //this.KeyDown += RunSourceForm_KeyDown;
        }
Exemplo n.º 7
0
 public IRunSource GetRunSource()
 {
     if (_runSource == null)
     {
         _runSource = (IRunSource)GetAppDomain().CreateInstanceFromAndUnwrap(_runsourceDllFilename, _runsourceClassName);
         _runSource.SetAsCurrentRunSource();
     }
     return(_runSource);
 }
Exemplo n.º 8
0
        static void Main()
        {
            try
            {
                // load runsource.runsource.config.xml (config of runsource.runsource.exe)
                XmlConfig config = new XmlConfig();
                FormatInfo.SetInvariantCulture();
                Application.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                RemoteRunSource remoteRunSource = new RemoteRunSource();
                remoteRunSource.RunsourceDllFilename  = config.GetExplicit("RunsourceDllFilename");
                remoteRunSource.RunsourceClassName    = config.GetExplicit("RunsourceClassName");
                remoteRunSource.TraceManagerClassName = config.GetExplicit("TraceManagerClassName");
                remoteRunSource.TraceClassName        = config.GetExplicit("TraceClassName");
                // ATTENTION si CreateRunSourceDomain = true runsource.launch.exe ne peut pas mettre à jour runsource.runsource.exe
                remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs <bool>(false);
                IRunSource runSource = remoteRunSource.GetRunSource();
                //remoteRunSource.LoadRunsourceCommand();
                //runSource.AllowMultipleExecution = config.Get("AllowMultipleExecution").zTryParseAs(false);
                ///////////////////////// donc il faut utiliser RemoteRunSource.GetTrace()
                //ITrace trace = remoteRunSource.GetTrace();
                //trace.SetWriter(config.Get("Log"), config.Get("Log/@option").zTextDeserialize(FileOption.None));

                // ATTENTION Trace exists in both 'runsource.runsource.exe' and 'runsource.dll'
                // both Trace are connected to TraceManager and can be used
                string     logFile       = config.Get("Log");
                FileOption logFileOption = config.Get("Log/@option").zTextDeserialize(FileOption.None);
                TraceManager.Current.AddTrace(Trace.Current);
                //TraceManager.Current.SetWriter(logFile, logFileOption);
                TraceManager.Current.SetWriter(WriteToFile.Create(logFile, logFileOption));

                ITraceManager remoteTraceManager = remoteRunSource.GetTraceManager();
                remoteTraceManager.AddTrace(remoteRunSource.GetTrace());
                //remoteTraceManager.SetWriter(logFile, logFileOption);
                remoteTraceManager.SetWriter(WriteToFile.Create(logFile, logFileOption));

                // ATTENTION appeler DeleteGeneratedAssemblies() après SetRunSourceConfig()
                //RunSourceForm form = new RunSourceForm(runSource, trace, config, GetRunSourceRestartParameters());
                //RunSourceForm_v3 form = new RunSourceForm_v3(runSource, trace, config, GetRunSourceRestartParameters());
                //RunSourceFormExe form = new RunSourceFormExe(runSource, trace, config, GetRunSourceRestartParameters());
                RunSourceFormExe form = new RunSourceFormExe(runSource, config, remoteRunSource, GetRunSourceRestartParameters());
                RunSourceFormExe.Current = form;

                form.SetRestartRunsource += FormSetRestartRunsource;
                Application.Run(form);

                TraceManager.Current.RemoveTrace(Trace.Current);
                TraceManager.Current.RemoveTrace(remoteRunSource.GetTrace());
                SetRunSourceRestartParameters();
            }
            catch (Exception ex)
            {
                zerrf.ErrorMessageBox(ex);
            }
        }
Exemplo n.º 9
0
 private void Test_RunSource(IRunSource runSource, string s)
 {
     try
     {
         runSource.RunCode(s);
     }
     catch (Exception ex)
     {
         WriteMessage(ex.ToString() + "\r\n");
     }
 }
Exemplo n.º 10
0
 private void EndRunSource()
 {
     if (_runSource != null)
     {
         _runSource.DisableMessageChanged -= EventDisableMessageChanged;
         _runSource.GridResultSetDataTable -= EventGridResultSetDataTable;
         _runSource.GridResultSetDataSet -= EventGridResultSetDataSet;
         _runSource.ProgressChange -= EventProgressChange;
         _runSource.EndRunCode -= EventEndRunCode;
         _runSource = null;
     }
 }
Exemplo n.º 11
0
 private void EndRunSource()
 {
     if (_runSource != null)
     {
         _runSource.DisableMessageChanged  -= EventDisableMessageChanged;
         _runSource.GridResultSetDataTable -= EventGridResultSetDataTable;
         _runSource.GridResultSetDataSet   -= EventGridResultSetDataSet;
         _runSource.ProgressChange         -= EventProgressChange;
         _runSource.EndRunCode             -= EventEndRunCode;
         _runSource = null;
     }
 }
Exemplo n.º 12
0
        //public RemoteRunSource(string runsourceDllFilename, bool createRunSourceDomain = true)
        //{
        //    _createRunSourceDomain = createRunSourceDomain;
        //    //string runsourceDllFilename = Path.Combine(zapp.GetAppDirectory(), "runsource.dll");
        //    runsourceDllFilename = Path.Combine(zapp.GetAppDirectory(), runsourceDllFilename);
        //    if (createRunSourceDomain)
        //    {
        //        _domain = AppDomain.CreateDomain(_runSourceDomainName);
        //        //System.Diagnostics.Debug.WriteLine(string.Format("FriendlyName {0}", _domain.FriendlyName));
        //        //System.Diagnostics.Debug.WriteLine(string.Format("BaseDirectory {0}", _domain.BaseDirectory));
        //        //System.Diagnostics.Debug.WriteLine(string.Format("RelativeSearchPath {0}", _domain.RelativeSearchPath));
        //        _runSource = (IRunSource)_domain.CreateInstanceFromAndUnwrap(runsourceDllFilename, "pb.old.RunSource");
        //        _runSource.SetAsCurrentRunSource();
        //        //_domain.SetData("RunSource", _runSource);
        //    }
        //    else
        //    {
        //        _domain = AppDomain.CurrentDomain;
        //        //_domain.CreateInstance();
        //        _runSource = (IRunSource)_domain.CreateInstanceFromAndUnwrap(runsourceDllFilename, "pb.old.RunSource");
        //        _runSource.SetAsCurrentRunSource();
        //    }
        //}

        public void Dispose()
        {
            if (_runSource != null)
            {
                _runSource.Dispose();
                _runSource = null;
            }
            if (_domain != null && _createRunSourceDomain)
            {
                AppDomain.Unload(_domain);
                _domain = null;
            }
        }
Exemplo n.º 13
0
        //public RemoteRunSource(string runsourceDllFilename, bool createRunSourceDomain = true)
        //{
        //    _createRunSourceDomain = createRunSourceDomain;
        //    //string runsourceDllFilename = Path.Combine(zapp.GetAppDirectory(), "runsource.dll");
        //    runsourceDllFilename = Path.Combine(zapp.GetAppDirectory(), runsourceDllFilename);
        //    if (createRunSourceDomain)
        //    {
        //        _domain = AppDomain.CreateDomain(_runSourceDomainName);
        //        //System.Diagnostics.Debug.WriteLine(string.Format("FriendlyName {0}", _domain.FriendlyName));
        //        //System.Diagnostics.Debug.WriteLine(string.Format("BaseDirectory {0}", _domain.BaseDirectory));
        //        //System.Diagnostics.Debug.WriteLine(string.Format("RelativeSearchPath {0}", _domain.RelativeSearchPath));
        //        _runSource = (IRunSource)_domain.CreateInstanceFromAndUnwrap(runsourceDllFilename, "pb.old.RunSource");
        //        _runSource.SetAsCurrentRunSource();
        //        //_domain.SetData("RunSource", _runSource);
        //    }
        //    else
        //    {
        //        _domain = AppDomain.CurrentDomain;
        //        //_domain.CreateInstance();
        //        _runSource = (IRunSource)_domain.CreateInstanceFromAndUnwrap(runsourceDllFilename, "pb.old.RunSource");
        //        _runSource.SetAsCurrentRunSource();
        //    }
        //}

        public void Dispose()
        {
            if (_runSource != null)
            {
                _runSource.Dispose();
                _runSource = null;
            }
            if (_domain != null && _createRunSourceDomain)
            {
                AppDomain.Unload(_domain);
                _domain = null;
            }
        }
Exemplo n.º 14
0
        public RunSourceForm(IRunSource runSource, ITrace trace, XmlConfig config, RunSourceRestartParameters runSourceParameters)
        {
            _runSource = runSource;
            _trace = trace;
            _config = config;
            _runSourceParameters = runSourceParameters;

            try
            {
                // http://stackoverflow.com/questions/9056418/resources-getobjectthis-icon-crashes-application-on-windows-xp
                // pour ne pas avoir une exection avec :
                // this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
                // Thread.Sleep(100);
                // dont work

                Initialize();

                _tabResultMessage = tab_message;
                _tabResultGrid = tab_result2;
                _tabResultTree = tab_result4;

                this.Icon = Properties.Resources.app;
                string title = config.Get("RunsourceTitle");
                if (title != null)
                    __title = title;
                //tb_source.ConfigurationManager.CustomLocation = "ScintillaNET.xml";
                //tb_source.ConfigurationManager.Language = "cs";
                //InitScintilla();
                Try(InitScintilla);

                tc_result.SelectedTab = _tabResultMessage;
                //ActiveControl = tb_source;

                cGrid.Culture = CultureInfo.CurrentUICulture;

                _gridMaxWidth = _config.Get("GridMaxWidth").zParseAs<int>();
                _gridMaxHeight = _config.Get("GridMaxHeight").zParseAs<int>();
                _dataTableMaxImageWidth = _config.Get("DataTableMaxImageWidth").zParseAs<int>();
                _dataTableMaxImageHeight = _config.Get("DataTableMaxImageHeight").zParseAs<int>();

                initRunSource();
                SetFileSaved();
            }
            catch (Exception ex)
            {
                _trace.WriteError(ex);
                zerrf.ErrorMessageBox(ex);
            }
        }
Exemplo n.º 15
0
        private void Test_RunSource1(IRunSource runSource)
        {
            string   s   = GetSource();
            DateTime dt1 = DateTime.Now;

            WriteMessage("{0:HH:mm:ss} RunSource\r\n", dt1);
            //Exe(new fExe(RunSource));
            Test_RunSource(runSource, s);

            WriteMessage("wait 6 min\r\n");
            Thread.Sleep(360000);

            DateTime dt2 = DateTime.Now;

            WriteMessage("{0:HH:mm:ss}-{1} RunSource\r\n", dt2, TimeSpanToString(dt2.Subtract(dt1)));
            //Exe(new fExe(RunSource));
            Test_RunSource(runSource, s);
        }
Exemplo n.º 16
0
        private void Test_RunSource()
        {
            //private RemoteRunSource _remoteRunSource = null;
            //private IRunSource _runSource = null;
            RemoteRunSource remoteRunSource = new RemoteRunSource();
            IRunSource      runSource       = remoteRunSource.GetRunSource();

            //runSource.SetRunSourceConfig(Program.Config.ConfigPath);
            //Trace.CurrentTrace.Writed += new WritedEvent(EventWrited2);
            Trace.CurrentTrace.SetViewer(EventWrited2);
            //_runSource.DisableMessageChanged += new DisableMessageChangedEvent(EventDisableMessageChanged);
            //_runSource.GridResultSetDataTable += new SetDataTableEvent(EventGridResultSetDataTable);
            //_runSource.GridResultSetDataSet += new SetDataSetEvent(EventGridResultSetDataSet);
            //_runSource.TreeViewResultAdd += new TreeViewResultAddEvent(EventTreeViewResultAdd);
            //_runSource.TreeViewResultSelect += new TreeViewResultSelectEvent(EventTreeViewResultSelect);
            //_runSource.ErrorResultSet += new SetDataTableEvent(EventErrorResultSet);
            //_runSource.ProgressChange += new ProgressChangeEvent(EventProgressChange);
            runSource.EndRunCode += new EndRunEvent(EventEndRun);

            //runSource.SourceDir = Program.Config.GetRootSubDir("SourceDir", "WRun", true);
            //runSource.SourceDir = Program.Config.Get("SourceDir", "WRun").zRootPath(zapp.GetAppDirectory());
            runSource.ProjectDirectory = Program.Config.Get("SourceDir", "WRun").zRootPath(zapp.GetAppDirectory());
            //runSource.LoadParameters();

            Test_RunSource1(runSource);
            //Test_RunSource2(runSource);
            //Test_RunSource3(runSource);

            //runSource.SaveParameters();
            //Trace.CurrentTrace.Writed -= new WritedEvent(EventWrited2);
            Trace.CurrentTrace.SetViewer(null);
            //_runSource.DisableMessageChanged -= new DisableMessageChangedEvent(EventDisableMessageChanged);
            //_runSource.GridResultSetDataTable -= new SetDataTableEvent(EventGridResultSetDataTable);
            //_runSource.GridResultSetDataSet -= new SetDataSetEvent(EventGridResultSetDataSet);
            //_runSource.TreeViewResultAdd -= new TreeViewResultAddEvent(EventTreeViewResultAdd);
            //_runSource.TreeViewResultSelect -= new TreeViewResultSelectEvent(EventTreeViewResultSelect);
            //_runSource.ErrorResultSet -= new SetDataTableEvent(EventErrorResultSet);
            //_runSource.ProgressChange -= new ProgressChangeEvent(EventProgressChange);
            runSource.EndRunCode -= new EndRunEvent(EventEndRun);

            remoteRunSource.Dispose();
            remoteRunSource = null;
            runSource       = null;
        }
Exemplo n.º 17
0
        public RunSourceFormExe(IRunSource runSource, ITrace trace, XmlConfig config, RunSourceRestartParameters runSourceParameters)
        {
            _runSource = runSource;
            _trace = trace;
            _trace.SetViewer(TraceWrited);
            _config = config;
            _runSourceParameters = runSourceParameters;

            _source.TextChanged += source_TextChanged;

            CreateMenu();
            CreateTopTools();
            this.InitializeForm();
            InitExe();
            InitMenu();
            UpdateRunSourceStatus();
            Try(SetKeyboardShortcuts);
            this.KeyPreview = true;
            this.Load += RunSourceForm_Load;
            this.FormClosing += RunSourceForm_FormClosing;
            this.FormClosed += RunSourceForm_FormClosed;
            //this.KeyDown += RunSourceForm_KeyDown;
        }
Exemplo n.º 18
0
        public RunSourceForm_v3(IRunSource runSource, ITrace trace, XmlConfig config, RunSourceRestartParameters runSourceParameters)
        {
            _runSource = runSource;
            _trace = trace;
            _trace.SetViewer(TraceWrited);
            _config = config;
            _runSourceParameters = runSourceParameters;

            this.ClientSize = new Size(1060, 650);
            CreateMenu();
            CreateTopTools();
            CreateScintillaControl();
            _editPanel.Controls.Add(_source);
            CreateResultControls();
            CreateStatusBar();
            this.InitializeForm();
            InitExe();
            InitMenu();
            this.KeyPreview = true;
            this.Load += RunSourceForm_Load;
            this.FormClosing += RunSourceForm_FormClosing;
            this.FormClosed += RunSourceForm_FormClosed;
            this.KeyDown += RunSourceForm_KeyDown;
        }
Exemplo n.º 19
0
        public RunSourceForm_v3(IRunSource runSource, ITrace trace, XmlConfig config, RunSourceRestartParameters runSourceParameters)
        {
            _runSource = runSource;
            _trace     = trace;
            _trace.SetViewer(TraceWrited);
            _config = config;
            _runSourceParameters = runSourceParameters;

            this.ClientSize = new Size(1060, 650);
            CreateMenu();
            CreateTopTools();
            CreateScintillaControl();
            _editPanel.Controls.Add(_source);
            CreateResultControls();
            CreateStatusBar();
            this.InitializeForm();
            InitExe();
            InitMenu();
            this.KeyPreview   = true;
            this.Load        += RunSourceForm_Load;
            this.FormClosing += RunSourceForm_FormClosing;
            this.FormClosed  += RunSourceForm_FormClosed;
            this.KeyDown     += RunSourceForm_KeyDown;
        }
Exemplo n.º 20
0
 private void Test_RunSource(IRunSource runSource, string s)
 {
     try
     {
         runSource.RunCode(s);
     }
     catch (Exception ex)
     {
         WriteMessage(ex.ToString() + "\r\n");
     }
 }
Exemplo n.º 21
0
 public IRunSource GetRunSource()
 {
     if (_runSource == null)
     {
         _runSource = (IRunSource)GetAppDomain().CreateInstanceFromAndUnwrap(_runsourceDllFilename, _runsourceClassName);
         _runSource.SetAsCurrentRunSource();
     }
     return _runSource;
 }
Exemplo n.º 22
0
        //private static bool _selectTreeViewResult = false;  // true si il faut sélectionner le résultat du TreeView

        static void Main()
        {
            Console.WriteLine("Test_AppDomain_08 : test runsource.dll");
            AppDomain domain = AppDomain.CreateDomain("New Domain");

            //Console.WriteLine("set initial lease time to 10 sec");
            //LifetimeServices.LeaseTime = TimeSpan.FromSeconds(10);  // This is the InitialLeaseTime property
            //Console.WriteLine();

            DateTime dt1 = DateTime.Now;

            //IRunSource rs = (IRunSource)domain.CreateInstanceFromAndUnwrap("runsource.dll", "pb.RunSource");
            //Console.WriteLine("{0:HH:mm:ss} create object pb.RunSource", dt1);

            Console.WriteLine("{0:HH:mm:ss} create object RemoteRunSource", dt1);
            Console.WriteLine();
            RemoteRunSource remoteRunSource = new RemoteRunSource();

            _runSource = remoteRunSource.GetRunSource();
            _runSource.SetRunSourceConfig(@"c:\pib\prog\tools\runsource\runsource32_config.xml");
            //_runSource.Trace.Writed += new WritedEvent(EventWrited);
            Trace.CurrentTrace.SetViewer(EventWrited);
            _runSource.DisableMessageChanged  += new DisableMessageChangedEvent(EventDisableMessageChanged);
            _runSource.GridResultSetDataTable += new SetDataTableEvent(EventGridResultSetDataTable);
            _runSource.GridResultSetDataSet   += new SetDataSetEvent(EventGridResultSetDataSet);
            //_runSource.TreeViewResultAdd += new TreeViewResultAddEvent(EventTreeViewResultAdd);
            //_runSource.TreeViewResultSelect += new TreeViewResultSelectEvent(EventTreeViewResultSelect);
            _runSource.ErrorResultSet += new SetDataTableEvent(EventErrorResultSet);
            _runSource.ProgressChange += new ProgressChangeEvent(EventProgressChange);
            _runSource.EndRunCode     += new EndRunEvent(EventEndRun);


            DateTime dt2;
            string   s = "RunSource.CurrentDomainRunSource.Trace.WriteLine(DateTime.Now.ToString());";

            dt2 = DateTime.Now;
            Console.WriteLine("{0:HH:mm:ss}-{1} execute : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), s);
            _runSource.RunCode(s);
            while (_runSource.IsRunning())
            {
                Thread.Sleep(100);
            }

            //Console.WriteLine("wait 15 sec");
            //Thread.Sleep(15000);
            //dt2 = DateTime.Now;
            //Console.WriteLine("{0:HH:mm:ss}-{1} test_03.GetMessage() : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());

            //Console.WriteLine("wait 2 min");
            //Thread.Sleep(120000);
            //dt2 = DateTime.Now;
            //Console.WriteLine("{0:HH:mm:ss}-{1} test_03.GetMessage() : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());

            Console.WriteLine("wait 6 min");
            Thread.Sleep(360000);
            //Console.WriteLine("wait 10 min");
            //Thread.Sleep(600000);
            //Console.WriteLine("wait 15 min");
            //Thread.Sleep(900000);
            //Console.WriteLine("wait 30 min");
            //Thread.Sleep(1800000);
            //Console.WriteLine("wait 2h");
            //Thread.Sleep(7200000);
            dt2 = DateTime.Now;
            Console.WriteLine("{0:HH:mm:ss}-{1} execute : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), s);
            _runSource.RunCode(s);
            while (_runSource.IsRunning())
            {
                Thread.Sleep(100);
            }


            //for (int i = 0; i < 500; i++)
            //{
            //    Thread.Sleep(1000);
            //    DateTime dt2 = DateTime.Now;
            //    Console.WriteLine("{0,6} {1:HH:mm:ss}-{2} test_03.GetMessage() : {3}", i + 1, dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());
            //}

            AppDomain.Unload(domain);
        }
Exemplo n.º 23
0
        //private static bool _selectTreeViewResult = false;  // true si il faut sélectionner le résultat du TreeView

        static void Main()
        {
            Console.WriteLine("Test_AppDomain_08 : test runsource.dll");
            AppDomain domain = AppDomain.CreateDomain("New Domain");

            //Console.WriteLine("set initial lease time to 10 sec");
            //LifetimeServices.LeaseTime = TimeSpan.FromSeconds(10);  // This is the InitialLeaseTime property
            //Console.WriteLine();

            DateTime dt1 = DateTime.Now;
            //IRunSource rs = (IRunSource)domain.CreateInstanceFromAndUnwrap("runsource.dll", "pb.RunSource");
            //Console.WriteLine("{0:HH:mm:ss} create object pb.RunSource", dt1);

            Console.WriteLine("{0:HH:mm:ss} create object RemoteRunSource", dt1);
            Console.WriteLine();
            RemoteRunSource remoteRunSource = new RemoteRunSource();
            _runSource = remoteRunSource.GetRunSource();
            _runSource.SetRunSourceConfig(@"c:\pib\prog\tools\runsource\runsource32_config.xml");
            //_runSource.Trace.Writed += new WritedEvent(EventWrited);
            Trace.CurrentTrace.SetViewer(EventWrited);
            _runSource.DisableMessageChanged += new DisableMessageChangedEvent(EventDisableMessageChanged);
            _runSource.GridResultSetDataTable += new SetDataTableEvent(EventGridResultSetDataTable);
            _runSource.GridResultSetDataSet += new SetDataSetEvent(EventGridResultSetDataSet);
            //_runSource.TreeViewResultAdd += new TreeViewResultAddEvent(EventTreeViewResultAdd);
            //_runSource.TreeViewResultSelect += new TreeViewResultSelectEvent(EventTreeViewResultSelect);
            _runSource.ErrorResultSet += new SetDataTableEvent(EventErrorResultSet);
            _runSource.ProgressChange += new ProgressChangeEvent(EventProgressChange);
            _runSource.EndRunCode += new EndRunEvent(EventEndRun);


            DateTime dt2;
            string s = "RunSource.CurrentDomainRunSource.Trace.WriteLine(DateTime.Now.ToString());";

            dt2 = DateTime.Now;
            Console.WriteLine("{0:HH:mm:ss}-{1} execute : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), s);
            _runSource.RunCode(s);
            while (_runSource.IsRunning())
                Thread.Sleep(100);

            //Console.WriteLine("wait 15 sec");
            //Thread.Sleep(15000);
            //dt2 = DateTime.Now;
            //Console.WriteLine("{0:HH:mm:ss}-{1} test_03.GetMessage() : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());

            //Console.WriteLine("wait 2 min");
            //Thread.Sleep(120000);
            //dt2 = DateTime.Now;
            //Console.WriteLine("{0:HH:mm:ss}-{1} test_03.GetMessage() : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());

            Console.WriteLine("wait 6 min");
            Thread.Sleep(360000);
            //Console.WriteLine("wait 10 min");
            //Thread.Sleep(600000);
            //Console.WriteLine("wait 15 min");
            //Thread.Sleep(900000);
            //Console.WriteLine("wait 30 min");
            //Thread.Sleep(1800000);
            //Console.WriteLine("wait 2h");
            //Thread.Sleep(7200000);
            dt2 = DateTime.Now;
            Console.WriteLine("{0:HH:mm:ss}-{1} execute : {2}", dt2, TimeSpanToString(dt2.Subtract(dt1)), s);
            _runSource.RunCode(s);
            while (_runSource.IsRunning())
                Thread.Sleep(100);


            //for (int i = 0; i < 500; i++)
            //{
            //    Thread.Sleep(1000);
            //    DateTime dt2 = DateTime.Now;
            //    Console.WriteLine("{0,6} {1:HH:mm:ss}-{2} test_03.GetMessage() : {3}", i + 1, dt2, TimeSpanToString(dt2.Subtract(dt1)), test03.GetMessage());
            //}

            AppDomain.Unload(domain);
        }
Exemplo n.º 24
0
        private void Test_RunSource3(IRunSource runSource)
        {
            string s = GetSource();
            DateTime dt1 = DateTime.Now;
            WriteMessage("{0:HH:mm:ss} RunSource\r\n", dt1);
            //Exe(new fExe(RunSource));
            Test_RunSource(runSource, s);

            DateTime dt2;

            for (int i = 0; i < 6; i++)
            {
                WriteMessage("wait 1 min\r\n");
                Thread.Sleep(60000);
                dt2 = DateTime.Now;
                WriteMessage("{0:HH:mm:ss}-{1} KeepAlive\r\n", dt2, TimeSpanToString(dt2.Subtract(dt1)));
                //runSource.KeepAlive();
            }

            dt2 = DateTime.Now;
            WriteMessage("{0:HH:mm:ss}-{1} RunSource\r\n", dt2, TimeSpanToString(dt2.Subtract(dt1)));
            //Exe(new fExe(RunSource));
            Test_RunSource(runSource, s);
        }
Exemplo n.º 25
0
 private void EndRunSource()
 {
     if (_runSource != null)
     {
         _trace.SetViewer(null);
         _runSource.DisableMessageChanged -= new DisableMessageChangedEvent(EventDisableMessageChanged);
         _runSource.GridResultSetDataTable -= new SetDataTableEvent(EventGridResultSetDataTable);
         _runSource.GridResultSetDataSet -= new SetDataSetEvent(EventGridResultSetDataSet);
         _runSource.ProgressChange -= new ProgressChangeEvent(EventProgressChange);
         _runSource.EndRunCode -= EventEndRunCode;
         _runSource = null;
     }
 }
Exemplo n.º 26
0
        static void Main()
        {
            try
            {
                XmlConfig config = new XmlConfig();

                //Trace.CurrentTrace.SetLogFile("log.txt", LogOptions.None);
                //string path = config.Get("Log").zSetRootDirectory();
                //if (path != null)
                //    _runSource.Trace.SetLogFile(path, LogOptions.IndexedFile);
                //Trace.WriteLine(config.Get("Log").zSetRootDirectory());
                //LogOptions logOptions = config.Get("Log/@LogOptions").zTextDeserialize(LogOptions.None);
                //Trace.WriteLine(logOptions.ToString());
                //Trace.CurrentTrace.SetLogFile(config.Get("Log").zSetRootDirectory(), config.Get("Log/@LogOptions").zTextDeserialize(LogOptions.None));
                //Trace.WriteLine(Trace.CurrentTrace.GetLogFile());

                FormatInfo.SetInvariantCulture();
                Application.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                RemoteRunSource remoteRunSource = new RemoteRunSource();
                remoteRunSource.RunsourceDllFilename = config.GetExplicit("RunsourceDllFilename");
                remoteRunSource.RunsourceClassName   = config.GetExplicit("RunsourceClassName");
                remoteRunSource.TraceClassName       = config.GetExplicit("TraceClassName");
                //remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs<bool>(true);
                // ATTENTION si CreateRunSourceDomain = true runsource.launch.exe ne peut pas mettre à jour runsource.runsource.exe
                remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs <bool>(false);
                IRunSource runSource = remoteRunSource.GetRunSource();
                runSource.AllowMultipleExecution = config.Get("AllowMultipleExecution").zTryParseAs(false);
                // ATTENTION Trace exists in both 'runsource.runsource.exe' and 'runsource.dll'
                // donc il faut utiliser RemoteRunSource.GetTrace()
                ITrace trace = remoteRunSource.GetTrace();
                //trace.SetLogFile(config.Get("Log").zRootPath(zapp.GetAppDirectory()), config.Get("Log/@LogOptions").zTextDeserialize(LogOptions.None));
                // .zRootPath(zapp.GetAppDirectory())
                trace.SetWriter(config.Get("Log"), config.Get("Log/@option").zTextDeserialize(FileOption.None));

                //runSource.GenerateAndExecuteManager.GenerateAssemblyDirectory = config.Get("GenerateAssemblyDirectory", "run").zRootPath(zapp.GetAppDirectory());
                // ATTENTION appeler DeleteGeneratedAssemblies() après SetRunSourceConfig()
                //runSource.DeleteGeneratedAssemblies();
                //RunSourceForm_v1 form = new RunSourceForm_v1(runSource, trace, config, GetRunSourceRestartParameters());
                RunSourceForm form = new RunSourceForm(runSource, trace, config, GetRunSourceRestartParameters());

                //form.UpdateRunsourceFiles += FormUpdateRunsourceFiles;
                form.SetRestartRunsource += FormSetRestartRunsource;
                Application.Run(form);
                //if (_projectFiles != null)
                SetRunSourceRestartParameters();
                //SetRunSourceUpdateParameters();

                //if (_updateProgram)
                //{
                //    _updateProgram = false;
                //    return 1;
                //}
                //else
                //    return 0;
                //Application.Exit();
            }
            catch (Exception ex)
            {
                zerrf.ErrorMessageBox(ex);
                //return 0;
            }
        }
Exemplo n.º 27
0
 private void endRunSource()
 {
     if (_runSource != null)
     {
         SaveParameters();
         //_runSource.SaveParameters();
         _runSource.Trace.Writed -= new WritedEvent(EventWrited);
         _runSource.DisableMessageChanged -= new DisableMessageChangedEvent(EventDisableMessageChanged);
         _runSource.GridResultSetDataTable -= new SetDataTableEvent(EventGridResultSetDataTable);
         _runSource.GridResultSetDataSet -= new SetDataSetEvent(EventGridResultSetDataSet);
         //_runSource.TreeViewResultAdd -= new TreeViewResultAddEvent(EventTreeViewResultAdd);
         //_runSource.TreeViewResultSelect -= new TreeViewResultSelectEvent(EventTreeViewResultSelect);
         _runSource.ErrorResultSet -= new SetDataTableEvent(EventErrorResultSet);
         _runSource.ProgressChange -= new ProgressChangeEvent(EventProgressChange);
         _runSource.EndRun -= new EndRunEvent(EventEndRun);
         _runSource = null;
     }
 }
Exemplo n.º 28
0
        private void Test_RunSource1(IRunSource runSource)
        {
            string s = GetSource();
            DateTime dt1 = DateTime.Now;
            WriteMessage("{0:HH:mm:ss} RunSource\r\n", dt1);
            //Exe(new fExe(RunSource));
            Test_RunSource(runSource, s);

            WriteMessage("wait 6 min\r\n");
            Thread.Sleep(360000);

            DateTime dt2 = DateTime.Now;
            WriteMessage("{0:HH:mm:ss}-{1} RunSource\r\n", dt2, TimeSpanToString(dt2.Subtract(dt1)));
            //Exe(new fExe(RunSource));
            Test_RunSource(runSource, s);
        }