|
|
|
@ -38,6 +38,7 @@ using IBKLinker_Minio.Common;
|
|
|
|
|
using NPOI.POIFS.Crypt.Dsig;
|
|
|
|
|
using NPOI.SS.Formula.Atp;
|
|
|
|
|
using Org.BouncyCastle.Asn1.Pkcs;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
{
|
|
|
|
@ -64,13 +65,14 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
public RequestEntity AddAuthority(MinioAuthority minioAuthority)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity request = new RequestEntity();
|
|
|
|
|
MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
///创建数据库连接上下文对象
|
|
|
|
|
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
|
|
|
|
|
{
|
|
|
|
|
///拿到表自增长的值赋值给自增长主键pk
|
|
|
|
|
minioAuthority.Id = getPk("S_MINIO_AUTHORITY", "MINIO_AUTHORITY");
|
|
|
|
|
minioAuthority.Id = bb.getPk("S_MINIO_AUTHORITY", "MINIO_AUTHORITY");
|
|
|
|
|
///给创建时间赋值
|
|
|
|
|
minioAuthority.CreatorTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
@ -575,6 +577,7 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
[HttpPost, Route("AddRolePermission")]
|
|
|
|
|
public RequestEntity AddRolePermission(RolePermissionModel minioRolePermission)
|
|
|
|
|
{
|
|
|
|
|
MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法
|
|
|
|
|
RequestEntity request = new RequestEntity();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -595,7 +598,7 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
{
|
|
|
|
|
db.BeginTransaction();
|
|
|
|
|
///拿到表自增长的值赋值给自增长主键pk
|
|
|
|
|
minioRolePermission.minioRolePermission.Pk = getPk("S_MINIO_ROLE_PERMISSION", "MINIO_ROLE_PERMISSION");
|
|
|
|
|
minioRolePermission.minioRolePermission.Pk = bb.getPk("S_MINIO_ROLE_PERMISSION", "MINIO_ROLE_PERMISSION");
|
|
|
|
|
///给创建时间赋值
|
|
|
|
|
minioRolePermission.minioRolePermission.CreatorTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
@ -767,13 +770,18 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
public RequestEntity AddStoragePath(List<MinioStoragePath> minioStoragePath)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity request = new RequestEntity();
|
|
|
|
|
MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法
|
|
|
|
|
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MinioClient minio = new MinioClient("172.15.88.212:9000", "minioadmin", "minioadmin");//连接所需minio所在地址、登录名、密码
|
|
|
|
|
string buckname = "dayetegang";//桶名称
|
|
|
|
|
MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法
|
|
|
|
|
MinioClient minio = bb.ConnectMinIO();//调用连接minio数据库方法
|
|
|
|
|
string BuckName = bb.GetBuckName();//调用取桶名称方法
|
|
|
|
|
var bucket = minio.BucketExistsAsync(BuckName);//判断桶是否存在
|
|
|
|
|
if (bucket.Result == false) //不存在就创建
|
|
|
|
|
{
|
|
|
|
|
minio.MakeBucketAsync(BuckName);//创建桶
|
|
|
|
|
}
|
|
|
|
|
string Operate = "";//操作
|
|
|
|
|
List<MinioStoragePath> date = new List<MinioStoragePath>();
|
|
|
|
|
List<MinioStoragePath> checkdatelist = new List<MinioStoragePath>();
|
|
|
|
@ -848,7 +856,7 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
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数据库
|
|
|
|
|
var uploadTask = minio.PutObjectAsync(BuckName, "/" + item.FileName, new MemoryStream(bt), bt.Length, contentType);//上传文件到minio数据库
|
|
|
|
|
uploadTask.Wait();
|
|
|
|
|
if (uploadTask.Status == TaskStatus.RanToCompletion && !uploadTask.IsFaulted)//判断是否上传成功
|
|
|
|
|
{
|
|
|
|
@ -903,10 +911,16 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
public RequestEntity UpdateStoragePath(List<MinioStoragePath> data)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity request = new RequestEntity();
|
|
|
|
|
MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MinioClient minio = new MinioClient("172.15.88.212:9000", "minioadmin", "minioadmin");//连接所需minio所在地址、登录名、密码
|
|
|
|
|
string buckname = "dayetegang";//桶名称
|
|
|
|
|
MinioClient minio = bb.ConnectMinIO();//调用连接minio数据库方法
|
|
|
|
|
string BuckName = bb.GetBuckName();//调用取桶名称方法
|
|
|
|
|
var bucket = minio.BucketExistsAsync(BuckName);//判断桶是否存在
|
|
|
|
|
if (bucket.Result == false) //不存在就创建
|
|
|
|
|
{
|
|
|
|
|
minio.MakeBucketAsync(BuckName);//创建桶
|
|
|
|
|
}
|
|
|
|
|
///创建数据库连接上下文对象
|
|
|
|
|
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
|
|
|
|
|
{
|
|
|
|
@ -918,7 +932,6 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
DateTime time = DateTime.Now;//取当前时间
|
|
|
|
|
MinioStoragePath date = new MinioStoragePath();
|
|
|
|
|
List<MinioStoragePath> datelist = new List<MinioStoragePath>();
|
|
|
|
|
MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法
|
|
|
|
|
string Operate = "";//操作
|
|
|
|
|
if (data.Count > 0)
|
|
|
|
|
{
|
|
|
|
@ -942,7 +955,7 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
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数据库
|
|
|
|
|
var uploadTask = minio.PutObjectAsync(BuckName, "/" + item.FileName, new MemoryStream(bt), bt.Length, contentType);//上传文件到minio数据库
|
|
|
|
|
uploadTask.Wait();
|
|
|
|
|
if (uploadTask.Status == TaskStatus.RanToCompletion && !uploadTask.IsFaulted)//判断是否上传成功
|
|
|
|
|
{
|
|
|
|
@ -997,14 +1010,14 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
public RequestEntity RemoveStoragePath(List<MinioStoragePath> master)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity request = new RequestEntity();
|
|
|
|
|
MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法
|
|
|
|
|
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DateTime time = DateTime.Now;//取当前时间
|
|
|
|
|
MinioClient minio = new MinioClient("172.15.88.212:9000", "minioadmin", "minioadmin");
|
|
|
|
|
string buckname = "dayetegang";//桶名称
|
|
|
|
|
MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法
|
|
|
|
|
MinioClient minio = bb.ConnectMinIO();//调用连接minio数据库方法
|
|
|
|
|
string BuckName = bb.GetBuckName();//调用取桶名称方法
|
|
|
|
|
string Operate = "";//操作
|
|
|
|
|
string FilePk = "";//文件pk
|
|
|
|
|
string fileUPk = "";//文件父级pk
|
|
|
|
@ -1015,7 +1028,7 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
{
|
|
|
|
|
if (item.FileType == 1) //如果类型是文件
|
|
|
|
|
{
|
|
|
|
|
var DelTask = minio.RemoveObjectAsync(buckname, item.FileName);//minio操作删除文件
|
|
|
|
|
var DelTask = minio.RemoveObjectAsync(BuckName, item.FileName);//minio操作删除文件
|
|
|
|
|
DelTask.Wait();
|
|
|
|
|
if (DelTask.Status == TaskStatus.RanToCompletion && !DelTask.IsFaulted)//判断是否删除成功
|
|
|
|
|
{
|
|
|
|
@ -1275,10 +1288,9 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in minioStoragePath)
|
|
|
|
|
{
|
|
|
|
|
MinioStoragePath date = new MinioStoragePath();//定义单条返回数据
|
|
|
|
|
var minio = new MinioClient("172.15.88.212:9000", "minioadmin", "minioadmin");//链接minio数据库
|
|
|
|
|
string bucketName = "dayetegang";
|
|
|
|
|
var uploadTask = bb.Download(bucketName, item.FileName);//异步取base64
|
|
|
|
|
MinioStoragePath date = new MinioStoragePath();//定义单条返回数据
|
|
|
|
|
string BuckName = bb.GetBuckName();//调用取桶名称方法
|
|
|
|
|
var uploadTask = bb.Download(BuckName, item.FileName);//异步取base64
|
|
|
|
|
uploadTask.Wait();//等待取值
|
|
|
|
|
if (uploadTask.Status == TaskStatus.RanToCompletion && !uploadTask.IsFaulted) //判读是否有数值
|
|
|
|
|
{
|
|
|
|
@ -1364,7 +1376,7 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
if (master.InventoryName != null && master.InventoryType != null)
|
|
|
|
|
{
|
|
|
|
|
string ExcelName = "";//定义导出Excel文件名称
|
|
|
|
|
FileStream file = new FileStream("D:/linshi/" + "清单模板.xlsx", FileMode.Open, FileAccess.Read);
|
|
|
|
|
FileStream file = new FileStream(Application.StartupPath + "\\Files\\" + "清单模板.xlsx", FileMode.Open, FileAccess.Read);
|
|
|
|
|
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
|
|
|
|
|
string sql = "select * from MINIO_STORAGE_PATH where 1=1 and FILE_TYPE='1' ";
|
|
|
|
|
if (master.InventoryType == "0")//标准类型
|
|
|
|
@ -1513,71 +1525,5 @@ namespace IBKLinker_Minio.Controller.MinioController
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 公用方法
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 矫正pk值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sequenceName"></param>
|
|
|
|
|
/// <param name="tableName"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public Int32 getPk(String sequenceName, String tableName)
|
|
|
|
|
{
|
|
|
|
|
///创建数据库连接上下文对象
|
|
|
|
|
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
|
|
|
|
|
{
|
|
|
|
|
///拿到表自增长序列最大pk值
|
|
|
|
|
int pk_SequenceCurrentMax = Convert.ToInt32(db.QueryScalar("select " + sequenceName + ".nextval from dual"));
|
|
|
|
|
///拿到表目前最大pk值
|
|
|
|
|
Object pk_TableCurrentMaxObj = db.QueryScalar("select t.pk from " + tableName + " t where rownum <=1 order by t.pk desc");
|
|
|
|
|
int pk_TableCurrentMax = pk_SequenceCurrentMax;
|
|
|
|
|
//如果表最大值查询结果不为空进行对比,
|
|
|
|
|
if (pk_TableCurrentMaxObj != null)
|
|
|
|
|
{
|
|
|
|
|
pk_TableCurrentMax = Convert.ToInt32(pk_TableCurrentMaxObj);
|
|
|
|
|
//拿到表中最大值和序列最大值之间的差值
|
|
|
|
|
int num_BetweenTableSequence = pk_TableCurrentMax - pk_SequenceCurrentMax + 1;
|
|
|
|
|
//更改序列递增规则,使下一次拿到的序列号比表中最大pk大1
|
|
|
|
|
db.QueryScalar("alter sequence " + sequenceName + " increment by " + num_BetweenTableSequence.ToString());
|
|
|
|
|
//执行nexval拿到下一个序列号
|
|
|
|
|
pk_TableCurrentMax = Convert.ToInt32(db.QueryScalar("select " + sequenceName + ".nextval from dual"));
|
|
|
|
|
//更改序列递增规则为每次递增一个。
|
|
|
|
|
db.QueryScalar("alter sequence " + sequenceName + " increment by 1");
|
|
|
|
|
}
|
|
|
|
|
return pk_TableCurrentMax;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编写内容:下载文件转换流数据方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Base64(string FilePath)
|
|
|
|
|
{
|
|
|
|
|
string data = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (MemoryStream msReader = new MemoryStream())
|
|
|
|
|
{
|
|
|
|
|
using (FileStream fs = new FileStream(FilePath, FileMode.Open))
|
|
|
|
|
{
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
int readLen = 0;
|
|
|
|
|
while ((readLen = fs.Read(buffer, 0, buffer.Length)) > 0)
|
|
|
|
|
{
|
|
|
|
|
msReader.Write(buffer, 0, readLen);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
data = Convert.ToBase64String(msReader.ToArray());//转换base64
|
|
|
|
|
}
|
|
|
|
|
return data;//返回值
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logger.InfoFormat(ex.ToString());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|