@ -36,6 +36,8 @@ using System.Xml.Linq;
using NPOI.HPSF ;
using NPOI.HPSF ;
using IBKLinker_Minio.Common ;
using IBKLinker_Minio.Common ;
using NPOI.POIFS.Crypt.Dsig ;
using NPOI.POIFS.Crypt.Dsig ;
using NPOI.SS.Formula.Atp ;
using Org.BouncyCastle.Asn1.Pkcs ;
namespace IBKLinker_Minio.Controller.MinioController
namespace IBKLinker_Minio.Controller.MinioController
{
{
@ -689,13 +691,13 @@ namespace IBKLinker_Minio.Controller.MinioController
{
{
foreach ( var items in minioStoragePath ) //先循环接收数据
foreach ( var items in minioStoragePath ) //先循环接收数据
{
{
checkdatelist = db . Query < MinioStoragePath > ( "select t.FILE_NAME from MINIO_STORAGE_PATH where 1=1 and FILE_NAME='"+ items . FileName + "' and UPK='"+ items . Upk + "'" ) . ToList ( ) ; //查询上传的文件或新建的文件夹在当前文件夹下是否有重复存在
checkdatelist = db . Query < MinioStoragePath > ( "select t.FILE_NAME from MINIO_STORAGE_PATH t where 1=1 and t. FILE_NAME='"+ items . FileName + "' and t. UPK='"+ items . Upk + "'" ) . ToList ( ) ; //查询上传的文件或新建的文件夹在当前文件夹下是否有重复存在
if ( checkdatelist . Count > 0 ) //如果有
if ( checkdatelist . Count > 0 ) //如果有
{
{
RecordFileName + = items . FileName + "," ; //记录名称
RecordFileName + = items . FileName + "," ; //记录名称
}
}
}
}
if ( RecordFileName = = null ) //如果没有 正常上传
if ( RecordFileName = = "" ) //如果 正常上传
{
{
foreach ( var item in minioStoragePath )
foreach ( var item in minioStoragePath )
{
{
@ -765,7 +767,7 @@ namespace IBKLinker_Minio.Controller.MinioController
MOdata . Pk = Convert . ToInt32 ( db . QueryScalar ( "select S_MINIO_OPERATIONLOG.nextval from dual" ) ) ; ///拿到表自增长的值赋值给自增长主键pk;
MOdata . Pk = Convert . ToInt32 ( db . QueryScalar ( "select S_MINIO_OPERATIONLOG.nextval from dual" ) ) ; ///拿到表自增长的值赋值给自增长主键pk;
MOdata . OperateUser = item . CreatorUser ; //操作者
MOdata . OperateUser = item . CreatorUser ; //操作者
MOdata . OperateTime = DateTime . Now ; //操作时间
MOdata . OperateTime = DateTime . Now ; //操作时间
MOdata . Operater = item . CreatorUser + " 上传了一个新的文档," + item . FileName + DateTime . Now . ToString ( ) ; //操作
MOdata . Operater = item . CreatorUser + " 上传了一个新的文档," + item . FileName + " " + DateTime . Now . ToString ( ) ; //操作
MOdata . CreationTime = DateTime . Now ; //创建时间
MOdata . CreationTime = DateTime . Now ; //创建时间
db . Insert < MinioOperationlog > ( MOdata ) ; //写入数据库
db . Insert < MinioOperationlog > ( MOdata ) ; //写入数据库
# endregion
# endregion
@ -805,6 +807,8 @@ namespace IBKLinker_Minio.Controller.MinioController
RequestEntity request = new RequestEntity ( ) ;
RequestEntity request = new RequestEntity ( ) ;
try
try
{
{
MinioClient minio = new MinioClient ( "172.15.88.212:9000" , "minioadmin" , "minioadmin" ) ; //连接所需minio所在地址、登录名、密码
string buckname = "dayetegang" ; //桶名称
///创建数据库连接上下文对象
///创建数据库连接上下文对象
using ( IDbContext db = ObjectContainer . GetObject < IDbContext > ( "db" ) )
using ( IDbContext db = ObjectContainer . GetObject < IDbContext > ( "db" ) )
{
{
@ -815,27 +819,62 @@ namespace IBKLinker_Minio.Controller.MinioController
///给修改时间赋值
///给修改时间赋值
DateTime time = DateTime . Now ; //取当前时间
DateTime time = DateTime . Now ; //取当前时间
MinioStoragePath date = new MinioStoragePath ( ) ;
MinioStoragePath date = new MinioStoragePath ( ) ;
List < MinioStoragePath > datebase = new List < MinioStoragePath > ( ) ;
List < MinioStoragePath > datelist = new List < MinioStoragePath > ( ) ;
foreach ( var item in data )
MinioOperationlog MOdata = new MinioOperationlog ( ) ;
if ( data . Count > 0 )
{
{
date . Pk = item . Pk ; //主键ID
foreach ( var item in data )
date . Upk = item . Upk ; //子文件夹的父ID
{
date . FileName = item . FileName ; //文件名称
date . Pk = item . Pk ; //主键ID
date . FileType = item . FileType ; //文件类型
date . Upk = item . Upk ; //子文件夹的父ID
date . FilePath = item . FilePath ; //文件路径
date . FileName = item . FileName ; //文件名称
date . CreatorUser = item . CreatorUser ; //创建者
date . FileType = item . FileType ; //文件类型
date . CreatorTime = item . CreatorTime ; //创建时间
date . FilePath = item . FilePath ; //文件路径
date . DownloadNum = item . DownloadNum ; //下载次数
date . CreatorUser = item . CreatorUser ; //创建者
date . FileLevel = item . FileLevel ; //层级
date . CreatorTime = item . CreatorTime ; //创建时间
date . ModifyUsers = item . ModifyUsers ; //修改用户
date . DownloadNum = item . DownloadNum ; //下载次数
date . ModifyTime = time ; //修改时间
date . FileLevel = item . FileLevel ; //层级
date . ClearFlag = "0" ; //删除标记 0未删除 1删除
date . ModifyUsers = item . ModifyUsers ; //修改用户
datebase . Add ( date ) ;
date . ModifyTime = time ; //修改时间
date . ClearFlag = "0" ; //删除标记 0未删除 1删除
if ( item . Bate64 ! = null ) //如果是修改文件
{
var contentType = item . FileCategory ;
string strBase64 = item . Bate64 ; //取文件base64流数据
byte [ ] bt = Convert . FromBase64String ( strBase64 ) ; //获取html base64
var uploadTask = minio . PutObjectAsync ( buckname , "/" + item . FileName , new MemoryStream ( bt ) , bt . Length , contentType ) ; //上传文件到minio数据库
uploadTask . Wait ( ) ;
if ( uploadTask . Status = = TaskStatus . RanToCompletion & & ! uploadTask . IsFaulted ) //判断是否上传成功
{
datelist . Add ( date ) ;
#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 < MinioOperationlog > ( MOdata ) ; //写入数据库
# endregion
}
}
else //正常修改文件/文件夹名称或移动
{
datelist . Add ( date ) ;
}
}
if ( datelist ! = null )
{
db . Update < MinioStoragePath > ( datelist ) ;
db . Commit ( ) ; //提交事务
request . code = "0" ;
request . msg = "修改成功!" ;
}
else
{
request . code = "1" ;
request . msg = "请检查是否符合修改规范!" ;
}
}
}
db . Update < MinioStoragePath > ( datebase ) ;
db . Commit ( ) ; //提交事务
request . code = "0" ;
request . msg = "修改成功!" ;
}
}
catch ( Exception ex )
catch ( Exception ex )
{
{
@ -869,11 +908,20 @@ namespace IBKLinker_Minio.Controller.MinioController
DateTime time = DateTime . Now ; //取当前时间
DateTime time = DateTime . Now ; //取当前时间
MinioClient minio = new MinioClient ( "172.15.88.212:9000" , "minioadmin" , "minioadmin" ) ;
MinioClient minio = new MinioClient ( "172.15.88.212:9000" , "minioadmin" , "minioadmin" ) ;
string buckname = "dayetegang" ; //桶名称
string buckname = "dayetegang" ; //桶名称
MinioOperationlog MOdata = new MinioOperationlog ( ) ;
db . BeginTransaction ( ) ;
db . BeginTransaction ( ) ;
string sql = "" ;
string sql = "" ;
//db.Delete<MinioStoragePath>(master);
//db.Delete<MinioStoragePath>(master);
foreach ( var item in 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 < MinioOperationlog > ( MOdata ) ; //写入数据库
# endregion
if ( item . FileType = = 1 ) //如果类型是文件
if ( item . FileType = = 1 ) //如果类型是文件
{
{
sql = "begin " ;
sql = "begin " ;
@ -885,24 +933,24 @@ namespace IBKLinker_Minio.Controller.MinioController
}
}
else
else
{
{
string sel = string . Format ( "select * from MINIO_STORAGE_PATH where UPK='{0}'" , item . Pk ) ;
//string sel =string.Format( "select * from MINIO_STORAGE_PATH where UPK='{0}'",item.Pk);
IList < MinioStoragePath > date = db . Query < MinioStoragePath > ( sel ) ; //查询删除文件夹时文件夹是否存在文件
//IList<MinioStoragePath> date = db.Query<MinioStoragePath>(sel); //查询删除文件夹时文件夹是否存在文件
if ( date . Count > 0 )
//if (date.Count > 0 )
{
// {
sql = "begin " ;
// sql = "begin ";
foreach ( var data in date )
// 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("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(" 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 ) ; //更新文件路径表中的删除状态
// 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
//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 ( "update MINIO_STORAGE_PATH set CLEAR_FLAG='1',CLEAR_USERS='{0}',CLEAR_TIME='{1}' where PK='{2}' " , item . ClearUsers , time , item . Pk ) ; //更新文件路径表中的删除状态
}
//}
db . Execute ( sql ) ;
db . Execute ( sql ) ;
}
}
}
}
request . code = "0" ;
request . code = "0" ;