Exemplo n.º 1
0
        private RobotJob.Status GetJobStatus(RobotJob RunRobotJob)
        {
            RobotJob.Status JobStatus = RJQ.GetJobStatus(RunRobotJob.UniqueID);

            string Message = string.Format("{0}({1})>{2}", RunRobotJob.ScriptName, RunRobotJob.UniqueID, JobStatus.ToString());

            this.DisplayData(Message);
            return(JobStatus);
        }
Exemplo n.º 2
0
 public RobotJob.Status GetJobStatus(Guid UniqueID)
 {
     RobotJob.Status JobStatus = RobotJob.Status.Failed;
     lock (syncRoot)
     {
         foreach (RobotJob RJ in this)
         {
             if (RJ.UniqueID == UniqueID)
             {
                 JobStatus = RJ.JobStatus;
             }
         }
     }
     //string Message = string.Format("Statuses of Script UniqueID: {0} is: {1} ",UniqueID,SS );
     //logger.Add(Message);
     return(JobStatus);
 }
Exemplo n.º 3
0
        protected override void DoWork()
        {
            //Get the RobotJob from the dirived clases
            RunRobotJob = BeforeRobotRun();
            if (RunRobotJob == null)
            {
                throw new NullReferenceException("GetRobotJob returned a null RobotJob");
            }
            RobotJob.Status JobStatus = RobotJob.Status.Created;

            // Inserting the Job in the queue
            RunRobotJob.TestJobParameters();
            RJQ = RobotJobsQueue.Instance;

            Guid JobID = RJQ.InsertRobotJob(RunRobotJob);

            RunRobotJob.UniqueID = JobID;

            this.Log(string.Format("Queued {0}, UniqueID: {1} (parameters={2})", RunRobotJob.ScriptName, RunRobotJob.UniqueID, RunRobotJob.RobotJobDisplayParameters));

            do
            {
                // keep monitoring the queue till the job status is changed to
                JobStatus = GetJobStatus(RunRobotJob);

                //pause state
                if (this.ShouldPause)
                {
                    this.SetCurrentStatus(Statuses.Paused, "RobotJob Pausing not implimented yet");
                    while (this.ShouldPause && !this.ShouldStop)
                    {
                        System.Threading.Thread.Sleep(this.StateSamplelingRate);
                    }

                    if (!this.ShouldPause && !this.ShouldStop)
                    {
                        this.SetCurrentStatus(State.Statuses.Started, "Protocol resumed");
                    }
                }

                if (JobStatus == RobotJob.Status.RuntimeError)
                {
                    this.SetCurrentStatus(State.Statuses.RuntimeError, "Runtime Error");

                    while (JobStatus == RobotJob.Status.RuntimeError && !this.ShouldStop)
                    {
                        System.Threading.Thread.Sleep(StateSamplelingRate);
                        JobStatus = GetJobStatus(RunRobotJob);
                    }
                    if (!this.ShouldStop)
                    {
                        this.SetCurrentStatus(State.Statuses.Started, "Runtime Error resumed");
                    }
                    else
                    {
                        break;
                    }
                }
                System.Threading.Thread.Sleep(StateSamplelingRate);
            }while(
                JobStatus != RobotJob.Status.TerminatedByUser &&
                JobStatus != RobotJob.Status.Finished &&
                JobStatus != RobotJob.Status.Failed &&
                !this.ShouldStop);

            //Handling termination statuses
            switch (JobStatus)
            {
            case (RobotJob.Status.Failed):
                this.SetCurrentStatus(State.Statuses.FatalError, "Failed");
                //this.RequestStop("Robot Job Failed");
                break;

            case (RobotJob.Status.TerminatedByUser):
                this.SetCurrentStatus(State.Statuses.FatalError, "Terminated by user");
                //this.RequestStop("Terminated by user");
                break;

            case (RobotJob.Status.Finished):
                this.SetCurrentStatus(State.Statuses.EndedSuccessfully, "Terminated successfully");
                AfterRobotRun();
                break;
            }
        }