Пример #1
0
        public static void HandleJobStatus(IgorCore.JobReturnStatus Status)
        {
            if (Status.bDone)
            {
                if (IgorAssert.HasJobFailed())
                {
                    IgorDebug.CoreLogError("Job failed!");
                }
                else
                {
                    IgorDebug.CoreLog("Job's done!");
                }
            }

            if (!Status.bWasStartedManually && (Status.bFailed || Status.bDone))
            {
                if (Status.bFailed)
                {
                    Application.Quit();
                }
                else
                {
                    Application.Quit();
                }
            }
        }
Пример #2
0
        public static bool ExecuteSteps()
        {
            if (IgorAssert.HasJobFailed())
            {
                IgorDebug.CoreLogError("Job failed so we are bailing out early and not finishing the remaining steps!");

                return(false);
            }

            List <StepID> SortedSteps = new List <StepID>(JobSteps.Keys);

            SortedSteps.Sort();

            IgorJobConfig.SetIsRunning(true);

            int StartingPriority        = IgorJobConfig.GetLastPriority();
            int StartingIndexInPriority = IgorJobConfig.GetLastIndexInPriority();

            foreach (StepID CurrentStep in SortedSteps)
            {
                if (CurrentStep.StepPriority > StartingPriority)
                {
                    IgorJobConfig.SetLastPriority(CurrentStep.StepPriority - 1);

                    int LastIndex = 0;

                    List <JobStep> CurrentStepFuncs = JobSteps[CurrentStep];

                    foreach (JobStep CurrentFunction in CurrentStepFuncs)
                    {
                        if (LastIndex > StartingIndexInPriority)
                        {
                            if (CurrentFunction.StepFunction())
                            {
                                IgorJobConfig.SetLastIndexInPriority(LastIndex);
                            }

                            return(false);
                        }

                        ++LastIndex;
                    }

                    StartingIndexInPriority = -1;
                    IgorJobConfig.SetLastIndexInPriority(-1);
                }
            }

            return(true);
        }
Пример #3
0
        public static void EditorHandleJobStatus(IgorCore.JobReturnStatus Status)
        {
            if (Status.bDone)
            {
                if (IgorAssert.HasJobFailed())
                {
                    IgorDebug.CoreLogError("Job failed!");
                }
                else
                {
                    IgorDebug.CoreLog("Job's done!");
                }

                float time = IgorUtils.PlayJobsDoneSound();
                System.Threading.Thread t = new System.Threading.Thread(() => WaitToExit(time));
                t.Start();

                while (t.IsAlive)
                {
                }
            }

            if (Status.bFailed)
            {
                IgorJobConfig.SetIsRunning(false);

                if (!Status.bWasStartedManually)
                {
                    EditorApplication.Exit(-1);
                }
            }

            if (!Status.bWasStartedManually && Status.bDone)
            {
                EditorApplication.Exit(0);
            }
        }
Пример #4
0
        public static JobReturnStatus RunJob(bool bFromMenu = false)
        {
            bool bWasStartedManually = false;
            bool bThrewException     = false;
            bool bDone = false;

            try
            {
                if (!IgorJobConfig.GetIsRunning())
                {
                    IgorDebug.CoreLog("Job is starting!");

                    IgorAssert.StartJob();

                    CheckForNamedJobFlag();
                }

                if (IgorJobConfig.GetWasMenuTriggered())
                {
                    bWasStartedManually = true;
                }
                else
                {
                    bWasStartedManually = bFromMenu;

                    IgorJobConfig.SetWasMenuTriggered(bWasStartedManually);
                }

                if (!IgorJobConfig.GetIsRunning() || EnabledModules.Count == 0)
                {
                    RegisterAllModules();
                }

                if (!IgorJobConfig.GetIsRunning() || ActiveModulesForJob.Count == 0)
                {
                    ProcessArgs();
                }

                if (ExecuteSteps())
                {
                    IgorJobConfig.SetIsRunning(false);

                    bDone = true;
                }
            }
            catch (Exception e)
            {
                IgorDebug.CoreLogError("Caught exception while running the job.  Exception is " + (e == null ? "NULL exception!" : e.ToString() +
                                                                                                   (e.InnerException == null ? "\n\nNULL inner exception." : ("\n\nInner: " + e.InnerException.ToString()))));

                bThrewException = true;
            }
            finally
            {
                if (bThrewException || bDone)
                {
                    Cleanup();
                }
            }

            JobReturnStatus NewStatus = new JobReturnStatus();

            NewStatus.bDone               = bDone;
            NewStatus.bFailed             = bThrewException || IgorAssert.HasJobFailed();
            NewStatus.bWasStartedManually = bWasStartedManually;

            return(NewStatus);
        }