Example #1
0
        public async Task <MessageModel <string> > Delete(int jobId)
        {
            var data = new MessageModel <string>();

            var model = await _tasksQzServices.QueryById(jobId);

            if (model != null)
            {
                _unitOfWork.BeginTran();
                data.success = await _tasksQzServices.Delete(model);

                try
                {
                    data.response = jobId.ObjToString();
                    if (data.success)
                    {
                        data.msg = "删除成功";
                        var ResuleModel = await _schedulerCenter.StopScheduleJobAsync(model);

                        data.msg = $"{data.msg}=>任务状态=>{ResuleModel.msg}";
                    }
                    else
                    {
                        data.msg = "删除失败";
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    if (data.success)
                    {
                        _unitOfWork.CommitTran();
                    }
                    else
                    {
                        _unitOfWork.RollbackTran();
                    }
                }
            }
            else
            {
                data.msg = "任务不存在";
            }
            return(data);
        }