Esempio n. 1
0
    public override void Run()
    {
        _IsRunning = true;

        // We need to run ConToSim first. When it has finished then we can
        // let the base class run APSIM.

        SimFileName = Path.Combine(Directory.GetCurrentDirectory(),
                                   Path.GetDirectoryName(_ConFileName),
                                   Path.GetFileNameWithoutExtension(_ConFileName) + "."
                                   + _SimulationName + ".sim");

        _ConFileName     = Path.Combine(Directory.GetCurrentDirectory(), _ConFileName);
        _ConToSimProcess = new ProcessCaller(Application.OpenForms[0]);
        if (Configuration.getArchitecture() == Configuration.architecture.unix)
        {
            _ConToSimProcess.FileName  = "mono";
            _ConToSimProcess.Arguments = StringManip.DQuote(Configuration.RemoveMacros(Path.Combine("%apsim%", "Model", "ConToSim.exe")))
                                         + " " + StringManip.DQuote(_ConFileName) + " " + StringManip.DQuote(_SimulationName);
        }
        else
        {
            _ConToSimProcess.FileName  = Configuration.RemoveMacros(Path.Combine("%apsim%", "Model", "ConToSim.exe"));
            _ConToSimProcess.Arguments = StringManip.DQuote(_ConFileName) + " " + StringManip.DQuote(_SimulationName);
        }
        _ConToSimProcess.AllFinished    += OnConToSimExited;
        _ConToSimProcess.StdOutReceived += OnStdOut;
        _ConToSimProcess.StdErrReceived += OnStdError;
        _ConToSimProcess.Start();
    }
Esempio n. 2
0
        private void EpmAnalyze()
        {
            this.Cursor        = Cursors.AppStarting;
            this.cmdOK.Enabled = this.cmdParse.Enabled = false;

            processCaller                 = new ProcessCaller(this);
            processCaller.FileName        = _newProject.ProjectAnalysisFile.FullName;
            processCaller.Arguments       = "";
            processCaller.StdErrReceived += new DataReceivedHandler(writeStreamInfo);
            processCaller.StdOutReceived += new DataReceivedHandler(writeStreamInfo);
            processCaller.Completed      += new EventHandler(processCompletedOrCanceled);
            processCaller.Cancelled      += new EventHandler(processCompletedOrCanceled);

            this.rtbResults.Text = "EPM Started, please wait..." + Environment.NewLine;

            // The following function starts a process and returns immediately,
            // allowing the form to stay responsive
            processCaller.Start();
        }
Esempio n. 3
0
        /*
         * --window-with-profile=Default --title=Job1 --cmd=dir --tab-with-profile=Default --title=Job2 --cmd=dir --tab-with-profile=Default --title=Job3 --cmd=dir
         * */
        static void RunCmd(Tab tab, RichTextBox rtb)
        {
            ProcessCaller processCaller = new ProcessCaller(rtb);

            //processCaller.FileName = @"..\..\hello.bat";
            processCaller.FileName         = tab.Exe();
            processCaller.WorkingDirectory = ".";
            processCaller.Arguments        = tab.Args();
            processCaller.StdErrReceived  += new DataReceivedHandler(new RichTextBoxUpdater(rtb).writeStreamInfo);
            processCaller.StdOutReceived  += new DataReceivedHandler(new RichTextBoxUpdater(rtb).writeStreamInfo);
            //processCaller.Completed += new EventHandler(processCompletedOrCanceled);
            //processCaller.Cancelled += new EventHandler(processCompletedOrCanceled);
            // processCaller.Failed += no event handler for this one, yet.

            rtb.Text = "Started function.  Please stand by.." + Environment.NewLine;

            // the following function starts a process and returns immediately,
            // thus allowing the form to stay responsive.
            processCaller.Start();
        }
Esempio n. 4
0
        public static void ExecuteCommand(string Command, ISynchronizeInvoke isi, bool wait)
        {
            string cmdText = Command;

            if (DisplayFilter != null)
            {
                cmdText = DisplayFilter(cmdText);
            }
            Trace.WriteLine("executing command: " + cmdText);
            ProcessCaller processCaller;

            processCaller                 = new ProcessCaller(isi);
            processCaller.FileName        = @"cmd.exe";
            processCaller.Arguments       = "/C " + Command;
            processCaller.StdOutReceived += processCaller_StdOutReceived;
            processCaller.StdErrReceived += processCaller_StdOutReceived;
            processCaller.Start();
            if (wait)
            {
                processCaller.WaitUntilDone();
            }
        }
Esempio n. 5
0
        private void OpenExcel_CsvFile()
        {
            var proc = new ProcessCaller(this) { FileName = GetExcelFileName() };

            if (proc.FileName.Length == 0)
                return;

            var param = new StringBuilder();
            param.Append(" \"");
            param.Append(textBox_CSV_FilePath.Text);
            param.Append("\"");
            proc.Arguments = param.ToString();
            proc.Start();
        }