Пример #1
0
        private void expandOrCollapseAll(LogItem i, bool expand)
        {
            if (expand)
            {
                i.Expand();
            }
            else
            {
                i.Collapse();
            }

            foreach (LogItem i2 in i.SubEvents)
            {
                expandOrCollapseAll(i2, expand);
            }
        }
Пример #2
0
        /// <summary>
        /// updates the actual GUI with the status information received as parameter
        /// If the StatusUpdate indicates that the job has ended, the Progress window is closed
        /// and the logging messages from the StatusUpdate object are added to the log tab
        /// if the job mentioned in the statusupdate has a next job name defined, the job is looked
        /// up and processing of that job starts - this applies even in queue encoding mode
        /// the linked jobs will always be encoded first, regardless of their position in the queue
        /// If we're in queue encoding mode, the next nob in the queue is also started
        /// </summary>
        /// <param name="su">StatusUpdate object containing the current encoder stats</param>
        private void UpdateGUIStatus(StatusUpdate su)
        {
            if (su.IsComplete)
            {
                // so we don't lock up the GUI, we start a new thread
                Thread t = new Thread(new ThreadStart(delegate
                {
                    TaggedJob job = mainForm.Jobs.ByName(su.JobName);

                    copyInfoIntoJob(job, su);
                    progress = 0;
                    HideProcessWindow();

                    // Postprocessing
                    bool jobFailed = (job.Status != JobStatus.PROCESSING);
                    if (!jobFailed)
                    {
                        postprocessJob(job.Job);
                        job.Status = JobStatus.DONE;
                    }

                    currentProcessor = null;
                    currentJob       = null;

                    // Logging
                    log.LogEvent("Job completed");
                    log.Collapse();

                    if (!jobFailed && mainForm.Settings.DeleteCompletedJobs)
                    {
                        mainForm.Jobs.RemoveCompletedJob(job);
                    }
                    else
                    {
                        mainForm.Jobs.saveJob(job, mainForm.MeGUIPath);     //AAA: save state more often
                    }
                    if (shutdownWorkerIfJobsCompleted())
                    {
                    }
                    else if (job.Status == JobStatus.ABORTED)
                    {
                        log.LogEvent("Current job was aborted");
                        status = JobWorkerStatus.Idle;
                    }
                    else if (status == JobWorkerStatus.Stopping)
                    {
                        log.LogEvent("Queue mode stopped");
                        status = JobWorkerStatus.Idle;
                    }
                    else
                    {
                        switch (startNextJobInQueue())
                        {
                        case JobStartInfo.JOB_STARTED:
                            break;

                        case JobStartInfo.COULDNT_START:
                            status = JobWorkerStatus.Idle;
                            break;

                        case JobStartInfo.NO_JOBS_WAITING:
                            status = JobWorkerStatus.Idle;
                            new Thread(delegate()
                            {
                                WorkerFinishedJobs(this, EventArgs.Empty);
                            }).Start();
                            break;
                        }
                    }

                    refreshAll();
                }));
                t.IsBackground = true;
                t.Start();
            }
            else // job is not complete yet
            {
                try
                {
                    if (pw.IsHandleCreated && pw.Visible) // the window is there, send the update to the window
                    {
                        pw.BeginInvoke(new UpdateStatusCallback(pw.UpdateStatus), su);
                    }
                }
                catch (Exception e)
                {
                    mainForm.Log.LogValue("Error trying to update status while a job is running", e, ImageType.Warning);
                }

                progress = su.PercentageDoneExact ?? 0;
                updateProgress();
            }
        }
Пример #3
0
        private void JobFinished(StatusUpdate su)
        {
            // so we don't lock up the GUI, we start a new thread
            Thread t = new Thread(new ThreadStart(delegate
            {
                TaggedJob job        = mainForm.Jobs.ByName(su.JobName);
                JobStartInfo JobInfo = JobStartInfo.JOB_STARTED;

                copyInfoIntoJob(job, su);
                progress = 0;
                HideProcessWindow();

                // Postprocessing
                bool jobFailed = (job.Status != JobStatus.PROCESSING);
                if (!jobFailed)
                {
                    PostprocessJob(job.Job);
                    job.Status = JobStatus.DONE;
                }

                currentProcessor = null;
                currentJob       = null;

                // Logging
                if (job.Status == JobStatus.ABORTED)
                {
                    log.LogEvent("Job aborted");
                }
                else
                {
                    log.LogEvent("Job completed");
                }
                log.Collapse();

                if (!jobFailed && mainForm.Settings.WorkerRemoveJob)
                {
                    mainForm.Jobs.RemoveCompletedJob(job);
                }
                else
                {
                    mainForm.Jobs.SaveJob(job, mainForm.MeGUIPath);
                }

                if (job.Status == JobStatus.ABORTED)
                {
                    status  = JobWorkerStatus.Stopped;
                    JobInfo = JobStartInfo.COULDNT_START;
                    if (bIsTemporaryWorker)
                    {
                        ShutDown();
                    }
                }
                else if (status == JobWorkerStatus.Stopping)
                {
                    log.LogEvent("Queue mode stopped");
                    status  = JobWorkerStatus.Stopped;
                    JobInfo = JobStartInfo.COULDNT_START;
                }
                else if (mainForm.Jobs.WorkersCount <= MainForm.Instance.Settings.WorkerMaximumCount || bIsTemporaryWorker)
                {
                    JobInfo = StartNextJobInQueue();
                    switch (JobInfo)
                    {
                    case JobStartInfo.COULDNT_START:
                        if (status != JobWorkerStatus.Postponed)
                        {
                            status = JobWorkerStatus.Idle;
                        }
                        break;

                    case JobStartInfo.NO_JOBS_WAITING:
                        if (status != JobWorkerStatus.Postponed)
                        {
                            status = JobWorkerStatus.Idle;
                        }
                        if (mode == JobWorkerMode.CloseOnLocalListCompleted)
                        {
                            ShutDown();
                        }
                        WorkerFinishedJobs(this, EventArgs.Empty);
                        break;
                    }
                }
                else
                {
                    status = JobWorkerStatus.Idle;
                }

                mainForm.Jobs.AdjustWorkerCount(true);

                if (!mainForm.Jobs.IsAnyJobRunning)
                {
                    MeGUI.core.util.WindowUtil.AllowSystemPowerdown();
                }

                RefreshAll();
            }));

            t.IsBackground = true;
            t.Start();
        }
Пример #4
0
        private void expandOrCollapseAll(LogItem i, bool expand)
        {
            if (expand)
                i.Expand();
            else
                i.Collapse();

            foreach (LogItem i2 in i.SubEvents)
                expandOrCollapseAll(i2, expand);
        }