Ejemplo n.º 1
0
    private void RemoteCompileMC(SfbClient _net)
    {
        string[] sources = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.f90", SearchOption.TopDirectoryOnly);
        if (sources.Length > 0 && _net.ServerVersionIsAtLeast("0.8") && _net.SupportedFileType(FileType.mccompile))
        {
            string errortext = null;

            foreach (string source in sources)
            {
                WriteToLog(string.Format("uploaded {0}", _net.SendFile(new FileInfo(source))));
            }
            SetStartTime(DateTime.Now);
            SetStatus(Status.compiling);

            // Compileer op de gui thread (hoort eigenlijk niet)
            _net.Run(FileType.mccompile, "mc.f90", this, ref errortext);

            if (errortext != null)
            {
                MessageBox.Show(errortext, "Server error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        else if (sources.Length > 0)
        {
            MessageBox.Show("There are source files found with your input file. \r\nHowever, " + SubItems[(int)Display.where].Text + " does not support remote compiling.", "Server error", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
Ejemplo n.º 2
0
    static void RunAndDownload(SfbClient _net, string shortName, string directoryName, JobEntry je)
    {
        je.RunAndDownloadIsActive = true;
        string errortext = null;

        _net.Run(je.filetype, shortName, je, ref errortext);

        if (errortext == "Maximum number of concurrent jobs exceeded.")
        {
            _net.Disconnect();
            je.WriteToLog(errortext.ToLower());
            je.SetStatus(Status.schedulerequest);
        }
        else if (errortext != null)
        {
            _net.Disconnect();
            MessageBoxShow(je._houston, errortext, "Run error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        else
        {
            _net.GetFinalStatus();
            je.SetCpuAndMem();

            _net.Download(je.DirectoryName);
            //je.WriteToLog("downloading finished");
            _net.Disconnect();
            if (je.stat == Status.aborted)
            {
                je.WriteToLog("abort completed");
            }
        }
    }
Ejemplo n.º 3
0
    public void StartRemoteJob()
    {
        string error;

        _checkInputFile      = false;
        _theTabs.SelectedTab = _tabLog;
        _log.Text            = "";

        Interlocked.Increment(ref Scheduler.numNetJobsRunning);
        //_houston.SetStatusBarText(Scheduler.numJobsRunning.ToString());

        _job = null;
        _net = new SfbClient(this);
        SetSubItem(Display.cpu, "0.0s");
        SetSubItem(Display.mem, "0kb");
        if ((error = _net.Connect(remotehost, remoteport, filetype)) == null)
        {
            string requiredversion = "";

            if (filetype == FileType.sfbox && _net.ServerVersionIsAtLeast(requiredversion = "0.5") || (filetype == FileType.mcrenko || filetype == FileType.ctb) && _net.ServerVersionIsAtLeast(requiredversion = "0.7"))
            {
                this._houston.AddtoRegistry(remotehost, remoteport);

                ArrayList news = _net.GetNews();

                string shortName = _net.SendInputFile(FullName);

                if (filetype == FileType.mcrenko)
                {
                    RemoteCompileMC(_net);
                }

                SetStartTime(DateTime.Now);
                SetStatus(Status.running);

                RunDelegate   run             = new RunDelegate(RunAndDownload);
                AsyncCallback myAsyncCallback = new AsyncCallback(NetHasExited);
                run.BeginInvoke(_net, shortName, DirectoryName, this, myAsyncCallback, null);

                PopupMessages(news);
            }
            else
            {
                SetStatus(Status.aborted);
                MessageBox.Show("You need at least server version " + requiredversion + " for what you are trying to do.", "Server error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Interlocked.Decrement(ref Scheduler.numNetJobsRunning);
            }
        }
        else
        {
            SetStatus(Status.aborted);
            MessageBox.Show("Server connection error:\n\n" + error, "Server error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            _log.AppendText("\r\nCould not connect: " + error);
            Interlocked.Decrement(ref Scheduler.numNetJobsRunning);
            //_houston.SetStatusBarText(Scheduler.numJobsRunning.ToString());
        }
    }
Ejemplo n.º 4
0
    private void NetHasExited(IAsyncResult res)
    {
        //Draait niet op de gui thread
        SetStopTime(DateTime.Now);

        if (_net != null)
        {
            _net = null;
        }

        Interlocked.Decrement(ref Scheduler.numNetJobsRunning);
        RunAndDownloadIsActive = false;

        if (stat == Status.schedulerequest)
        {
            Schedule(DateTime.Now.AddMinutes(1), true);
        }
        else if (stat != Status.aborted)
        {
            SetStatus(Status.completed);
        }
    }
Ejemplo n.º 5
0
    public void StartJob(bool checkInputFile)
    {
        _checkInputFile      = checkInputFile;
        _theTabs.SelectedTab = _tabLog;
        _log.Text            = "";

        Interlocked.Increment(ref Scheduler.numJobsRunning);
        _houston.SetStatusBarText(Scheduler.numJobsRunning.ToString());

        _net = null;
        _job = new Process();
        _job.EnableRaisingEvents = true;
        if (filetype == FileType.sfbox)
        {
            _job.StartInfo.FileName  = Application.StartupPath + "\\Plugins\\sfbox";
            _job.StartInfo.Arguments = "\"" + FullName + "\"";
        }
        else if (filetype == FileType.mcrenko)
        {
            string fname = Path.GetFileNameWithoutExtension(FullName);
            string fext  = Path.GetExtension(FullName);
            _job.StartInfo.FileName  = Application.StartupPath + "\\Plugins\\MCRenko";
            _job.StartInfo.Arguments = string.Format("\"{0}\" {1}a{2} {1}b{2}", FullName, fname, fext);
        }
        else if (filetype == FileType.ctb)
        {
            string fname = Path.GetFileNameWithoutExtension(FullName);
            string fext  = Path.GetExtension(FullName);
            _job.StartInfo.FileName  = Application.StartupPath + "\\Plugins\\ctb";
            _job.StartInfo.Arguments = "\"" + FullName + "\"";
        }

        _job.StartInfo.RedirectStandardOutput = true;
        _job.StartInfo.UseShellExecute        = false;
        _job.StartInfo.CreateNoWindow         = true;
        if (checkInputFile)
        {
            _job.StartInfo.Arguments = "-c " + _job.StartInfo.Arguments;
        }
        _job.StartInfo.WorkingDirectory = DirectoryName;

        try
        {
            _job.Exited += new System.EventHandler(JobHasExited);
            _job.Start();
        }
        catch (Exception e)
        {
            SetStatus(Status.aborted);
            MessageBox.Show("Starting the job failed:\n\n" + e.Message + "\n\n" + _job.StartInfo.FileName, "Start Failed");
            _log.AppendText("\r\nCould not start.");
            Interlocked.Decrement(ref Scheduler.numJobsRunning);
            _houston.SetStatusBarText(Scheduler.numJobsRunning.ToString());
            return;
        }
        try
        {
            if (System.Environment.OSVersion.ToString().StartsWith("Microsoft Windows NT"))
            {
                _job.PriorityClass = ProcessPriorityClass.Idle;
            }
            //else MessageBox.Show("Priority not set\n\n"+System.Environment.OSVersion.ToString());
            _jobStream = _job.StandardOutput;
            _jobStream.BaseStream.BeginRead(_buf, 0, 512, asyncCallback, null);
        }
        catch (Exception e)
        {
            WriteToLog(e.Message);
        }

        if (!checkInputFile)
        {
            SetStartTime(_job.StartTime);
            SetSubItem(Display.cpu, "0.0s");
            SetStatus(Status.running);
        }
        else
        {
            WriteToLog("input checking started");
        }

        _houston.jobslistview.Select();
        Focused = true;
    }