From 2667bb38d65d94d4b8672bf1e7ff89d76b21d902 Mon Sep 17 00:00:00 2001 From: sunliang <593170460@qq.com> Date: Mon, 20 Nov 2023 18:01:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=89=A9?= =?UTF-8?q?=E7=90=86=E5=88=A0=E9=99=A4=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MinioController/MinioApiController.cs | 54 ++++++++----------- .../MinioController/MinioStoragePath.cs | 2 +- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs index a5ac32f..847a4c5 100644 --- a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs +++ b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs @@ -776,6 +776,7 @@ namespace IBKLinker_Minio.Controller.MinioController data.CreatorTime = DateTime.Now;//创建时间 data.ClearFlag = "0";//删除状态为未删除 data.FileLevel = date[0].FileLevel + 1;//层级 + data.DocumentType = item.DocumentType;//文件种类 db.Insert(data); request.msg = "文件上传成功!"; request.code = "0"; @@ -853,6 +854,7 @@ namespace IBKLinker_Minio.Controller.MinioController date.ModifyUsers = item.ModifyUsers;//修改用户 date.ModifyTime = time;//修改时间 date.ClearFlag = "0";//删除标记 0未删除 1删除 + date.DocumentType = item.DocumentType;//文件种类 if (item.Bate64 != null)//如果是修改文件 { var contentType = item.FileCategory; @@ -930,43 +932,31 @@ namespace IBKLinker_Minio.Controller.MinioController //db.Delete(master); foreach (var item in master) { - #region 记录日志 - MOdata.Pk = Convert.ToInt32(db.QueryScalar("select S_MINIO_OPERATIONLOG.nextval from dual"));///拿到表自增长的值赋值给自增长主键pk; - MOdata.OperateUser = item.CreatorUser;//操作者 - MOdata.OperateTime = DateTime.Now;//操作时间 - MOdata.Operater = item.CreatorUser + " 更新了 " + item.FileName + " 这个文档。 " + DateTime.Now.ToString();//操作 - MOdata.CreationTime = DateTime.Now;//创建时间 - db.Insert(MOdata);//写入数据库 - #endregion if (item.FileType == 1) //如果类型是文件 { - sql = "begin "; - sql += string.Format("update MINIO_STORAGE_PATH set CLEAR_FLAG='1',CLEAR_USERS='{0}',CLEAR_TIME='{1}' where PK='{2}';", item.ClearUsers, time, item.Pk);//更新文件路径表中的删除状态 - sql += string.Format(" delete from MINIO_FILEASSOCIATION where FILE_PK like'%{0}%' or ASSOCIATION_FILE_PK like'%{0}%';", item.Pk);//删除关联表中的关联关系 - sql += "end;"; - db.Execute(sql); - //minio.RemoveObjectAsync(buckname, item.FileName);//minio操作删除文件 + var DelTask = minio.RemoveObjectAsync(buckname, item.FileName);//minio操作删除文件 + DelTask.Wait(); + if (DelTask.Status == TaskStatus.RanToCompletion && !DelTask.IsFaulted)//判断是否删除成功 + { + sql = "begin "; + sql += string.Format("delete from MINIO_STORAGE_PATH where 1=1 and PK='{2}';", item.ClearUsers, time, item.Pk);//更新文件路径表中的删除状态 + sql += string.Format(" delete from MINIO_FILEASSOCIATION where FILE_PK like'%{0}%' or ASSOCIATION_FILE_PK like'%{0}%';", item.Pk);//删除关联表中的关联关系 + sql += "end;"; + db.Execute(sql); + #region 记录日志 + MOdata.Pk = Convert.ToInt32(db.QueryScalar("select S_MINIO_OPERATIONLOG.nextval from dual"));///拿到表自增长的值赋值给自增长主键pk; + MOdata.OperateUser = item.ClearUsers;//操作者 + MOdata.OperateTime = DateTime.Now;//操作时间 + MOdata.Operater = item.ClearUsers + " 删除了 " + item.FileName + " 这个文档。 " + DateTime.Now.ToString();//操作 + MOdata.CreationTime = DateTime.Now;//创建时间 + db.Insert(MOdata);//写入数据库 + #endregion + } } - else + else //如果类型是文件夹 { - //string sel =string.Format( "select * from MINIO_STORAGE_PATH where UPK='{0}'",item.Pk); - //IList date = db.Query(sel);//查询删除文件夹时文件夹是否存在文件 - //if (date.Count > 0) - //{ - // sql = "begin "; - // foreach (var data in date) - // { - // sql += string.Format("update MINIO_STORAGE_PATH set CLEAR_FLAG='1',CLEAR_USERS='{0}',CLEAR_TIME='{1}' where PK='{2}' ", item.ClearUsers, item.ClearTime, data.Pk); - // sql += string.Format(" delete from MINIO_FILEASSOCIATION where FILE_PK like'%{0}%' or ASSOCIATION_FILE_PK like'%{0}%';", item.Pk);//删除关联表中的关联关系 - // } - // sql += string.Format("update MINIO_STORAGE_PATH set CLEAR_FLAG='1',CLEAR_USERS='{0}',CLEAR_TIME='{1}' where PK='{2}' ", item.ClearUsers, time, item.Pk);//更新文件路径表中的删除状态 - //} - //else - //{ - sql = string.Format("update MINIO_STORAGE_PATH set CLEAR_FLAG='1',CLEAR_USERS='{0}',CLEAR_TIME='{1}' where PK='{2}' ", item.ClearUsers, time, item.Pk);//更新文件路径表中的删除状态 - //} + sql = string.Format("delete from MINIO_STORAGE_PATH where 1=1 and PK='{2}' ", item.ClearUsers, time, item.Pk);//更新文件路径表中的删除状态 db.Execute(sql); - } } request.code = "0"; diff --git a/IBKLinker-Minio/Entity/MinioController/MinioStoragePath.cs b/IBKLinker-Minio/Entity/MinioController/MinioStoragePath.cs index 16167fa..3683ebe 100644 --- a/IBKLinker-Minio/Entity/MinioController/MinioStoragePath.cs +++ b/IBKLinker-Minio/Entity/MinioController/MinioStoragePath.cs @@ -123,7 +123,7 @@ namespace IBKLinker_Minio.Entity.MinioController /// - ///文件种类 主要分为技术协议、质量要点、工艺卡用于关联文件使用 + ///文件种类 主要分为1、技术协议、2、质量要点、3、工艺卡 4、其他 用于关联文件使用 /// [Persistent("DOCUMENT_TYPE"), DisplayName("文件种类")] public string DocumentType { get; set; }