Exemplo n.º 1
0
        private Response HandleGetAllJobs()
        {
            Job[]         all   = jobs.All(with => { });
            List <object> model = new List <object>(all.Length);

            foreach (Job job in all)
            {
                JobExecution execution = executions.GetByJob(job.Header).FirstOrDefault();
                DateTime?    nextRun   = execution != null?execution.NextRun(job.Schedule) : job.Schedule.Next(null);

                job.Extract(data =>
                {
                    model.Add(new
                    {
                        id          = job.Header.Identifier.ToHex(),
                        version     = job.Header.Version,
                        name        = data.Name,
                        description = data.Description,
                        executable  = data.Executable,
                        arguments   = data.Arguments,
                        blob        = data.Blob.ToHex(),
                        nextRun     = nextRun
                    });
                });
            }

            return(Response.AsJson(model));
        }