예제 #1
0
    protected override void OnStdOut(object sender, CSGeneral.DataReceivedEventArgs e)
    {
        lock (this)
        {
            // A handler for an APSIM process writting to stdout.
            if (!_SumFile.BaseStream.CanWrite)
            {
                // This is bad. It means that the associated apsim.exe has been closed but
                // we're still being passed stdout stuff.

                _SumFile = new StreamWriter(_SumFileName, true);
                _SumFile.Write(e.Text);
                _SumFile.Close();
            }
            else if (e.Text != "")
            {
                _SumFile.Write(e.Text);
            }
            if (e.Text.Contains("APSIM  Fatal  Error"))
            {
                _HasErrors = true;
            }
            else if (e.Text.Contains("APSIM Warning Error"))
            {
                _HasWarnings = true;
            }
        }
    }
예제 #2
0
 protected override void OnStdError(object sender, CSGeneral.DataReceivedEventArgs e)
 {
     lock (this)
     {
         // A handler for an APSIM process writting to stderr.
         // Look for a percent complete
         if (e.Text.Length > 0)
         {
             if (e.Text[0] == '%')
             {
                 _PercentComplete = Convert.ToInt32(e.Text.Substring(1));
                 int posEol = e.Text.IndexOf('\n');
                 if (posEol > 0)
                 {
                     _StdErr += e.Text.Substring(posEol);                 // Append trailing message, if any
                 }
             }
             else
             {
                 _StdErr += e.Text;
             }
         }
     }
 }