示例#1
0
        public JsonResult Jobs()
        {
            var jobs = mediaService.GetJobs().OrderByDescending(job => job.StartTime);
            var x    = from j in jobs
                       select new JobItem
            {
                JobId     = j.Id,
                Name      = j.Name,
                StartTime = j.StartTime.HasValue ? j.StartTime.Value.ToString("dd/MM/yyyy hh:mm:ss") : "",
                EndTime   = j.EndTime.HasValue ? j.EndTime.Value.ToString("dd/MM/yyyy hh:mm:ss") : "",
                State     = j.State.ToString(),
                Tasks     = from t in j.Tasks
                            select new TaskItem
                {
                    Name               = t.Name,
                    StartTime          = t.StartTime.HasValue ? t.StartTime.Value.ToString("dd/MM/yyyy hh:mm:ss") : "",
                    EndTime            = t.EndTime.HasValue ? t.EndTime.Value.ToString("dd/MM/yyyy hh:mm:ss") : "",
                    State              = t.State.ToString(),
                    ProgressPercentage = t.Progress
                }
            };

            return(Json(x, JsonRequestBehavior.AllowGet));
        }