예제 #1
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);
            }
        }
예제 #2
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;
        }
예제 #3
0
파일: Program.cs 프로젝트: labeuze/source
        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;
            }
        }
예제 #4
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);
        }