Exemplo n.º 1
0
 public static string StopAndPrintProcess(string inProcessName)
 {
     return(Pad(_watches.Count - 1) + string.Format("END PROCESS {0} ({1})", inProcessName, TimeHelper.FromSeconds(StopProcess())));
 }
Exemplo n.º 2
0
        /*
         * private void AddJobCtrl(Job job)
         * {
         *  JobUCtrl ctrl = new JobUCtrl(job);
         *  _jobsPanel.Controls.Add(ctrl);
         *  ctrl.Dock = DockStyle.Top;
         *  ctrl.BringToFront();
         *
         *  _jobs.Add(job.Id, ctrl);
         *  DropFinished();
         * }
         *
         * private void DropFinished()
         * {
         *  _jobsPanel.SuspendLayout();
         *  foreach (JobUCtrl job in _jobs.Values)
         *  {
         *      if (job.Job._IsFinished)
         *      {
         *          job.BringToFront();
         *      }
         *  }
         *  _jobsPanel.ResumeLayout(true);
         * }
         */

        public void RefreshValues()
        {
            if (InvokeRequired)
            {
                VoidCallback p = new VoidCallback(RefreshValues);
                this.Invoke(p);
            }
            else
            {
                dataGridView1.DataSource = null;

                //int nbJobs = _jobs.Count;
                int nbJobs         = _activeJobs.Count;
                int nbFinishedJobs = 0;

                long totalComplexity = 0;
                long doneComplexity  = 0;

                foreach (Job job in _activeJobs)
                {
                    totalComplexity += job.Complexity;

                    if (job.Status == QueueStatuses.Finished || job.Status == QueueStatuses.Error)
                    {
                        nbFinishedJobs++;
                        doneComplexity += job.Complexity;
                    }
                }

                /*
                 * foreach (JobUCtrl job in _jobs.Values)
                 * {
                 *  totalComplexity += job.Job.Complexity;
                 *
                 *  if (job.IsFinished)
                 *  {
                 *      nbFinishedJobs++;
                 *      doneComplexity += job.Job.Complexity;
                 *  }
                 * }
                 */
                if (nbFinishedJobs == nbJobs)
                {
                    Clear();
                    nbJobs = nbFinishedJobs = 0;

                    SetButtons(false);
                }
                else
                {
                    SetButtons(true);
                    _activeJobs.Sort();
                    dataGridView1.DataSource = _activeJobs;

                    int counter = 0;
                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        if (_activeJobs[counter].Status == QueueStatuses.Finished)
                        {
                            row.DefaultCellStyle.BackColor = Color.Gray;
                        }
                        else if (_activeJobs[counter].Status == QueueStatuses.Error)
                        {
                            row.DefaultCellStyle.BackColor = Color.Red;
                        }
                        else if (_activeJobs[counter].Status == QueueStatuses.Running)
                        {
                            row.DefaultCellStyle.BackColor = Color.PaleGreen;
                        }

                        counter++;
                    }
                }

                //Caption
                string StatusText = _queue.Status.ToString();

                float remainingSeconds = (float)(totalComplexity - doneComplexity) / _queue.ComplexityPerSecond;
                if (remainingSeconds > 0 && !float.IsInfinity(remainingSeconds))
                {
                    StatusText += " " + TimeHelper.FromSeconds(remainingSeconds);
                }

                //DropFinished();

                _queueStatusLabel.Text  = StatusText;
                _queueCountLabel.Text   = string.Format("{0}/{1} jobs finished ({2}%)", nbFinishedJobs, nbJobs, nbJobs == 0 ? 0 : (nbFinishedJobs * 100) / nbJobs);
                _queueProgressBar.Value = (int)(100 * ((float)doneComplexity / (totalComplexity != 0 ? totalComplexity : 100)));
            }
        }