Ejemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            var response = new List <TaskJobDto>();
            var list     = _yunYingRepository.GetList <TaskJobInfo>();

            foreach (var item in list)
            {
                TaskJobDto dto = new TaskJobDto
                {
                    JobID           = item.JobID,
                    JobName         = item.JobName,
                    JobDesc         = item.JobDesc,
                    JobClassName    = item.JobClassName,
                    CronExpression  = item.CronExpression,
                    ApiUrl          = item.ApiUrl,
                    LastExecuteTime = item.LastExecuteTime
                };
                int status = await _quartzManager.GetState(item.JobName);

                dto.Status = status;
                if (status == (int)TriggerState.Normal)
                {
                    dto.StatusName = "运行中";
                }
                else if (status == (int)TriggerState.Paused)
                {
                    dto.StatusName = "暂停";
                }
                else if (status == (int)TriggerState.Complete)
                {
                    dto.StatusName = "已完成";
                }
                else if (status == (int)TriggerState.Error)
                {
                    dto.StatusName = "错误";
                }
                else if (status == (int)TriggerState.Blocked)
                {
                    dto.StatusName = "阻塞";
                }
                else if (status == (int)TriggerState.None)
                {
                    dto.StatusName = "";
                }
                response.Add(dto);
            }
            return(View(response));
        }