Пример #1
0
        public virtual async Task <IActionResult> DeleteBatchAsync(DeletesInputDto 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 = await iService.DeleteBatchWhereAsync(where).ConfigureAwait(false);

                if (bl)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = ErrCode.err0;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43003;
                    result.ErrCode = "43003";
                }
            }
            return(ToJsonContent(result));
        }
Пример #2
0
        /// <summary>
        /// 按条件批量删除
        /// </summary>
        /// <param name="idsInfo">主键Id集合</param>
        /// <param name="trans">事务对象</param>
        /// <returns></returns>
        public CommonResult DeleteBatchWhere(DeletesInputDto idsInfo, IDbTransaction trans = null)
        {
            CommonResult result = new CommonResult();

            string where = string.Empty;
            for (int i = 0; i < idsInfo.Ids.Length; i++)
            {
                if (idsInfo.Ids[0] != null)
                {
                    where = string.Format("ParentId='{0}'", idsInfo.Ids[0]);
                    IEnumerable <Organize> list = _repository.GetListWhere(where);
                    if (list.Count() > 0)
                    {
                        result.ErrMsg = "功能存在子集数据,不能删除";
                        return(result);
                    }
                }
            }
            where = "id in ('" + idsInfo.Ids.Join(",").Trim(',').Replace(",", "','") + "')";
            bool bl = repository.DeleteBatchWhere(where);

            if (bl)
            {
                result.ErrCode = "0";
            }
            return(result);
        }
Пример #3
0
        public override async Task <IActionResult> DeleteBatchAsync(DeletesInputDto info)
        {
            CommonResult result = new CommonResult();

            string where = string.Empty;
            where        = "id in ('" + info.Ids.Join(",").Trim(',').Replace(",", "','") + "')";

            if (!string.IsNullOrEmpty(where))
            {
                dynamic[] jobsId = info.Ids;
                foreach (var item in jobsId)
                {
                    if (string.IsNullOrEmpty(item.ToString()))
                    {
                        continue;
                    }
                    UploadFile        uploadFile        = new UploadFileApp().Get(item.ToString());
                    YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                    SysSetting        sysSetting        = yuebonCacheHelper.Get("SysSetting").ToJson().ToObject <SysSetting>();
                    if (uploadFile != null)
                    {
                        if (System.IO.File.Exists(sysSetting.LocalPath + "/" + uploadFile.FilePath))
                        {
                            System.IO.File.Delete(sysSetting.LocalPath + "/" + uploadFile.FilePath);
                        }
                        if (!string.IsNullOrEmpty(uploadFile.Thumbnail))
                        {
                            if (System.IO.File.Exists(sysSetting.LocalPath + "/" + uploadFile.Thumbnail))
                            {
                                System.IO.File.Delete(sysSetting.LocalPath + "/" + uploadFile.Thumbnail);
                            }
                        }
                    }
                }
                bool bl = await iService.DeleteBatchWhereAsync(where).ConfigureAwait(false);

                if (bl)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = ErrCode.err0;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43003;
                    result.ErrCode = "43003";
                }
            }
            return(ToJsonContent(result));
        }
Пример #4
0
        public override async Task <IActionResult> DeleteBatchAsync(DeletesInputDto info)
        {
            CommonResult result = new CommonResult();

            string where = string.Empty;
            where        = "id in ('" + info.Ids.Join(",").Trim(',').Replace(",", "','") + "')";
            dynamic[] jobsId = info.Ids;
            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 bl = await iService.DeleteBatchWhereAsync(where).ConfigureAwait(false);

                if (bl)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = ErrCode.err0;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43003;
                    result.ErrCode = "43003";
                }
            }
            return(ToJsonContent(result));
        }
Пример #5
0
        public override async Task <IActionResult> DeleteBatchAsync(DeletesInputDto info)
        {
            CommonResult result = new CommonResult();

            if (info.Ids.Length > 0)
            {
                result = await iService.DeleteBatchWhereAsync(info).ConfigureAwait(false);

                if (result.Success)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = ErrCode.err0;
                }
                else
                {
                    result.ErrCode = "43003";
                }
            }
            return(ToJsonContent(result));
        }