Пример #1
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));
        }
Пример #2
0
        public IActionResult DeleteFile(string id)
        {
            CommonResult result = new CommonResult();

            try
            {
                UploadFile uploadFile = new UploadFileApp().Get(id);

                YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                SysSetting        sysSetting        = yuebonCacheHelper.Get("SysSetting").ToJson().ToObject <SysSetting>();
                string            localpath         = _hostingEnvironment.WebRootPath;
                if (uploadFile != null)
                {
                    string filepath = (localpath + "/" + uploadFile.FilePath).ToFilePath();
                    if (System.IO.File.Exists(filepath))
                    {
                        System.IO.File.Delete(filepath);
                    }
                    string filepathThu = (localpath + "/" + uploadFile.Thumbnail).ToFilePath();
                    if (System.IO.File.Exists(filepathThu))
                    {
                        System.IO.File.Delete(filepathThu);
                    }

                    result.ErrCode = ErrCode.successCode;
                    result.Success = true;
                }
                else
                {
                    result.ErrCode = ErrCode.failCode;
                    result.Success = false;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("", ex);
                result.ErrCode = "500";
                result.ErrMsg  = ex.Message;
            }
            return(ToJsonContent(result));
        }