예제 #1
0
        public virtual async Task <IActionResult> DeleteSoftBatchAsync(UpdateEnableViewModel info)
        {
            CommonResult result = new CommonResult();

            string where = string.Empty;
            if (typeof(TKey) == typeof(string))
            {
                where = "id in ('" + info.Ids.Join(",").Trim(',').Replace(",", "','") + "')";
            }
            else if (typeof(TKey) == typeof(int))
            {
                where = "id in (" + info.Ids.Join(",") + ")";
            }
            if (!string.IsNullOrEmpty(where))
            {
                bool bl = false;
                if (info.Flag == "1")
                {
                    bl = true;
                }
                bool blResult = await iService.DeleteSoftBatchAsync(bl, where, CurrentUser.UserId);

                if (blResult)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = ErrCode.err0;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43002;
                    result.ErrCode = "43002";
                }
            }
            return(ToJsonContent(result));
        }
예제 #2
0
        public override async Task <IActionResult> SetEnabledMarktBatchAsync(UpdateEnableViewModel info)
        {
            CommonResult result = new CommonResult();
            bool         bl     = false;

            if (info.Flag == "1")
            {
                bl = true;
            }
            string where = string.Empty;
            where        = "id in ('" + info.Ids.Join(",").Replace(",", "','") + "')";
            dynamic[] jobsId = info.Ids;
            if (!bl)
            {
                foreach (var item in jobsId)
                {
                    if (string.IsNullOrEmpty(item.ToString()))
                    {
                        continue;
                    }
                    TaskManager job = iService.Get(item.ToString());
                    if (job == null)
                    {
                        throw new Exception("任务不存在");
                    }
                    IScheduler scheduler = await schedulerFactory.GetScheduler();

                    TriggerKey triggerKey = new TriggerKey(job.Id, job.GroupName);
                    // 停止触发器
                    await scheduler.PauseTrigger(triggerKey);

                    // 移除触发器
                    await scheduler.UnscheduleJob(triggerKey);

                    // 删除任务
                    await scheduler.DeleteJob(new JobKey(job.Id));
                }
            }
            if (!string.IsNullOrEmpty(where))
            {
                bool blresut = await iService.SetEnabledMarkByWhereAsync(bl, where, CurrentUser.UserId);

                if (blresut)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = ErrCode.err0;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43002;
                    result.ErrCode = "43002";
                }
            }
            return(ToJsonContent(result));
        }