优化查询所有文件夹接口

master
孙亮 3 months ago
parent 24f9057bd1
commit 61cc70164a

@ -1,41 +1,15 @@
using IBKLinker_Minio.Entity;
using log4net;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Minio;
using System.Net.PeerToPeer;
using System.IO;
using System.Reactive.Linq;
using Minio.DataModel;
using System.Security.AccessControl;
using System.IO.Pipes;
using System.Net.Mime;
using IBKLinker_Minio.Entity.MinioController;
using SOA.Objects;
using SOA.Persistent;
using System.Web.Http.Results;
using System.Runtime.InteropServices.ComTypes;
using System.Xml;
using Swashbuckle.Swagger;
using System.Runtime.ConstrainedExecution;
using System.Net.Http;
using System.Web.UI.WebControls;
using System.Runtime.Remoting.Contexts;
using System.Runtime.InteropServices;
using System.Net;
using NPOI.XSSF.UserModel;
using NPOI.SS.UserModel;
using System.Net.Http.Headers;
using NPOI.SS.Formula.Functions;
using System.Xml.Linq;
using NPOI.HPSF;
using System.Configuration;
using NPOI.SS.Formula.Atp;
using IBKLinker_Minio.Controller.MinioController;
namespace IBKLinker_Minio.Common
{
@ -103,7 +77,6 @@ namespace IBKLinker_Minio.Common
}
#endregion
#region 文件夹递归查询
/// <summary>
/// 文件夹递归查询
@ -111,10 +84,10 @@ namespace IBKLinker_Minio.Common
public List<StoragePath> GetSubDirectories(int parentPk)
{
List<StoragePath> subDirs = new List<StoragePath>();
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
foreach (var subDir in MinioApiController.rootDirectories)
{
List<MinioStoragePath> subDirectories = db.Query<MinioStoragePath>("select * from MINIO_STORAGE_PATH where UPK ='" + parentPk + "' and CLEAR_FLAG='0' and FILE_TYPE='0' ORDER BY PK").ToList();//查询子级中是否还有子级
foreach (var subDir in subDirectories)
if (subDir.Upk == parentPk)
{
RequstStoragePath subDirModel = new RequstStoragePath();
subDirModel.Pk = subDir.Pk;//主键ID
@ -228,5 +201,7 @@ namespace IBKLinker_Minio.Common
}
}
#endregion
}
}

@ -4,45 +4,21 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Minio;
using System.Net.PeerToPeer;
using System.IO;
using System.Reactive.Linq;
using Minio.DataModel;
using System.Security.AccessControl;
using System.IO.Pipes;
using System.Net.Mime;
using IBKLinker_Minio.Entity.MinioController;
using SOA.Objects;
using SOA.Persistent;
using System.Web.Http.Results;
using System.Runtime.InteropServices.ComTypes;
using System.Xml;
using Swashbuckle.Swagger;
using System.Runtime.ConstrainedExecution;
using System.Net.Http;
using System.Web.UI.WebControls;
using System.Runtime.Remoting.Contexts;
using System.Runtime.InteropServices;
using System.Net;
using NPOI.XSSF.UserModel;
using NPOI.SS.UserModel;
using System.Net.Http.Headers;
using NPOI.SS.Formula.Functions;
using System.Xml.Linq;
using NPOI.HPSF;
using IBKLinker_Minio.Common;
using NPOI.POIFS.Crypt.Dsig;
using NPOI.SS.Formula.Atp;
using Org.BouncyCastle.Asn1.Pkcs;
using System.Windows.Forms;
using Org.BouncyCastle.Asn1.Ocsp;
using System.Data;
using System.Web.WebSockets;
using System.Security.Cryptography;
namespace IBKLinker_Minio.Controller.MinioController
{
@ -59,7 +35,7 @@ namespace IBKLinker_Minio.Controller.MinioController
/// </summary>
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static List<SliceUploadModel> SliceUploadData = new List<SliceUploadModel>();
public static List<MinioStoragePath> rootDirectories = new List<MinioStoragePath>();
#region minio权限表
/// <summary>
@ -1258,26 +1234,29 @@ namespace IBKLinker_Minio.Controller.MinioController
List<RequstStoragePath> requstStoragePaths = new List<RequstStoragePath>();
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
List<MinioStoragePath> rootDirectories = db.Query<MinioStoragePath>("select * from MINIO_STORAGE_PATH where CLEAR_FLAG='0' and FILE_TYPE='0'and FILE_LEVEL='1' ORDER BY PK").ToList();//查询文件夹
rootDirectories = db.Query<MinioStoragePath>("select * from MINIO_STORAGE_PATH where CLEAR_FLAG='0' and FILE_TYPE='0' ORDER BY PK").ToList();//查询所有文件夹
foreach (var rootDir in rootDirectories)
{
RequstStoragePath rootModel = new RequstStoragePath();
rootModel.Pk = rootDir.Pk;//主键ID
rootModel.Upk = rootDir.Upk;//父级文件夹pk
rootModel.FileName = rootDir.FileName;//文件名称
rootModel.FilePath = rootDir.FilePath;//文件路径
rootModel.FileType = rootDir.FileType;//文件类型
rootModel.FileLevel = rootDir.FileLevel;//层级
rootModel.CreatorTime = rootDir.CreatorTime;//创建时间
rootModel.CreatorUser = rootDir.CreatorUser;//创建者
rootModel.DownloadNum = rootDir.DownloadNum;//下载次数
rootModel.ModifyUsers = rootDir.ModifyUsers;//修改用户
rootModel.ModifyTime = rootDir.ModifyTime;//修改时间
rootModel.ClearUsers = rootDir.ClearUsers;//删除用户
rootModel.ClearTime = rootDir.ClearTime;//删除时间
rootModel.ClearFlag = rootDir.ClearFlag;//删除标记 0未删除 1删除
rootModel.requstStoragePaths = bb.GetSubDirectories(rootDir.Pk);//子级存进list
requstStoragePaths.Add(rootModel);//添加list
if (rootDir.Upk == 0 && rootDir.FileLevel == 1)//只要根目录文件夹
{
RequstStoragePath rootModel = new RequstStoragePath();
rootModel.Pk = rootDir.Pk;//主键ID
rootModel.Upk = rootDir.Upk;//父级文件夹pk
rootModel.FileName = rootDir.FileName;//文件名称
rootModel.FilePath = rootDir.FilePath;//文件路径
rootModel.FileType = rootDir.FileType;//文件类型
rootModel.FileLevel = rootDir.FileLevel;//层级
rootModel.CreatorTime = rootDir.CreatorTime;//创建时间
rootModel.CreatorUser = rootDir.CreatorUser;//创建者
rootModel.DownloadNum = rootDir.DownloadNum;//下载次数
rootModel.ModifyUsers = rootDir.ModifyUsers;//修改用户
rootModel.ModifyTime = rootDir.ModifyTime;//修改时间
rootModel.ClearUsers = rootDir.ClearUsers;//删除用户
rootModel.ClearTime = rootDir.ClearTime;//删除时间
rootModel.ClearFlag = rootDir.ClearFlag;//删除标记 0未删除 1删除
rootModel.requstStoragePaths = bb.GetSubDirectories(rootDir.Pk);//子级存进list
requstStoragePaths.Add(rootModel);//添加list
}
}
}
request.data = requstStoragePaths;
@ -1785,149 +1764,5 @@ namespace IBKLinker_Minio.Controller.MinioController
}
#endregion
#region 同步关联
[HttpPost, Route("UdpDlsync")]
public RequestEntity UdpDlsync(string master)
{
RequestEntity request = new RequestEntity();//定义返回集合
List<MinioStoragePath> data = new List<MinioStoragePath>();//定义输出下载的list
List<MinioStoragePath> newdata = new List<MinioStoragePath>();//定义输出下载的list
List<Dlsync> dldata = new List<Dlsync>();//定义输出下载的list
List<MinioStoragePath> datan = new List<MinioStoragePath>();
List<MinioFileassociation> mfcion = new List<MinioFileassociation>();
DataTable dt = new DataTable();
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
using (IDbContext filedb = ObjectContainer.GetObject<IDbContext>("filedb"))
{
string sql = "";
data = db.Query<MinioStoragePath>("select * from minio_storage_path where upk='" + master + "' order by CREATOR_TIME asc").ToList();
foreach (var item in data)
{
bool Asstion = true;//定义是否执行关联
//sql = string.Format("select g.title from ASSETENTRY g where entryid in (select entryid2 from ASSETLINK t where entryid1 = (select t.entryid from ASSETENTRY t ,(select p.fileid from DLSYNC p where p.name = '{0}' and (p.event='add' or p.event = 'update') )o where t.classpk = o.fileid))", item.FileName);
sql = string.Format("select g.title,g.username,g.createdate from ASSETENTRY g where entryid in (select entryid2 from ASSETLINK t where entryid1 = (select t.entryid from ASSETENTRY t ,(select p.fileid from DLSYNC p where p.name = '{0}' and (p.event='add' or p.event = 'update') and p.version='{1}' and ROWNUM = 1 order by p.version desc)o where t.classpk = o.fileid)) ", item.FileName, item.Version);
dt = db.Query(sql);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
MinioFileassociation dc = new MinioFileassociation();
datan = db.Query<MinioStoragePath>("select * from minio_storage_path where file_name='" + dt.Rows[i]["title"].ToString() + "'").ToList();
if (datan.Count != 0)
{
IList<MinioFileassociation> SelMFdata = new List<MinioFileassociation>();
SelMFdata = db.Query<MinioFileassociation>("select * from MINIO_FILEASSOCIATION where 1=1 and (FILE_PK='" + item.Pk + "' or ASSOCIATION_FILE_PK='" + item.Pk + "')");
if (SelMFdata.Count > 0)
{
foreach (var ca in SelMFdata)
{
if (item.Pk == ca.FilePk && datan[0].Pk == ca.AssociationFilePk) //如果当前要关联的pk 等于已有的关联pk 被关联pk 等于已有的被关联pk
{
Asstion = false;
}
if (item.Pk == ca.AssociationFilePk && datan[0].Pk == ca.FilePk) //如果当前要关联的pk 等于已有的被关联pk 被关联pk 等于已有的关联pk
{
Asstion = false;
}
}
}
if (Asstion)
{
dc.Pk = Convert.ToInt32(db.QueryScalar("select S_MINIO_FILEASSOCIATION.nextval from dual"));
dc.FilePk = item.Pk;
dc.FileName = item.FileName;
dc.CreatorUser = dt.Rows[i]["username"].ToString().Replace(" ", "");
dc.CreatorTime = dt.Rows[i]["createdate"].ToString().ToDateTime();
dc.FilePath = item.FilePath;
dc.FileLevel = item.FileLevel;
dc.DownloadNum = item.DownloadNum;
dc.FileType = item.FileType;
dc.Version = item.Version;
dc.AssociationFilePk = datan[0].Pk;
dc.AssociationFileName = datan[0].FileName;
dc.AssociationFilePath = datan[0].FilePath;
dc.AssociationFileType = datan[0].FileType;
dc.AssociationFileLevel = datan[0].FileLevel;
dc.AssociationDownloadNum = datan[0].DownloadNum;
dc.AssociationVersion = datan[0].Version;
mfcion.Add(dc);
}
}
}
}
}
db.Insert<MinioFileassociation>(mfcion);
}
}
return request;
}
#endregion
#region
[HttpPost, Route("UdpDlsyncFile")]
public RequestEntity UdpDlsyncFile(string master,string parentfolderid)
{
RequestEntity request = new RequestEntity();//定义返回集合
//List<MinioStoragePath> data = new List<MinioStoragePath>();//定义输出下载的list
List<MinioStoragePath> newdata = new List<MinioStoragePath>();//定义输出下载的list
List<Dlsync> dldata = new List<Dlsync>();//定义输出下载的list
List<MinioStoragePath> datan = new List<MinioStoragePath>();
List<MinioFileassociation> mfcion = new List<MinioFileassociation>();
DataTable dt = new DataTable();
DataTable dta = new DataTable();
string ctime = "";
string mtime = "";
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
using (IDbContext filedb = ObjectContainer.GetObject<IDbContext>("filedb"))
{
string sql = "";
//data = db.Query<MinioStoragePath>("select * from minio_storage_path where upk='" + master + "' order by CREATOR_TIME desc").ToList();
//foreach (var item in data)
//{
//sql = string.Format("select g.title from ASSETENTRY g where entryid in (select entryid2 from ASSETLINK t where entryid1 = (select t.entryid from ASSETENTRY t ,(select p.fileid from DLSYNC p where p.name = '{0}' and (p.event='add' or p.event = 'update') )o where t.classpk = o.fileid))", item.FileName);
sql = string.Format("select * from DLSYNC where parentfolderid='{0}' and (event='update' or event='add') ", parentfolderid);
dt = db.Query(sql);
string sel = string.Format("select * from minio_storage_path where pk='{0}'", master); ;
dta = db.Query(sel);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
ctime = dt.Rows[i]["CREATEDATE"].ToString();
mtime = dt.Rows[i]["MODIFIEDDATE"].ToString();
MinioStoragePath dc = new MinioStoragePath();
datan = db.Query<MinioStoragePath>("select * from minio_storage_path where file_name='" + dt.Rows[i]["NAME"].ToString() + "'").ToList();
if (datan.Count < 1)
{
dc.Pk = Convert.ToInt32(db.QueryScalar("select s_minio_storage_path.nextval from dual"));
dc.Upk = Convert.ToInt32(master);
dc.FileName = dt.Rows[i]["NAME"].ToString();
dc.FileType = 1;
dc.FilePath = dta.Rows[0]["FILE_PATH"].ToString()+"/"+ dt.Rows[i]["NAME"].ToString();
dc.CreatorUser = "sunliang";
dc.CreatorTime = ctime.ToDateTime();
dc.DownloadNum = 0;
dc.FileLevel = Convert.ToInt32( dta.Rows[0]["FILE_LEVEL"].ToString())+1;
dc.ModifyTime = mtime.ToDateTime();
dc.ClearFlag = "0";
dc.Version = dt.Rows[i]["VERSION"].ToString();
newdata.Add(dc);
}
}
}
//}
db.Insert<MinioStoragePath>(newdata);
}
}
return request;
}
#endregion
}
}

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IBKLinker_Minio.Entity.MinioController
namespace IBKLinker_Minio.Entity.MinioController
{
/// <summary>
/// 查询minio文件文件夹路径model包括模糊查询文件名称以及根据时间查询

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using SOA.Persistent;

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IBKLinker_Minio.Entity.MinioController
namespace IBKLinker_Minio.Entity.MinioController
{
/// <summary>
/// 文件上传前端发送model

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using SOA.Persistent;

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using SOA.Persistent;

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using SOA.Persistent;

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using SOA.Persistent;

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using SOA.Persistent;

@ -2,9 +2,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IBKLinker_Minio.Entity.MinioController
{

@ -1,10 +1,4 @@
using SOA.Persistent;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
namespace IBKLinker_Minio.Entity.MinioController
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IBKLinker_Minio.Entity.MinioController
namespace IBKLinker_Minio.Entity.MinioController
{
/// <summary>
/// 文件上传标准清单model

@ -1,13 +1,4 @@
using Org.BouncyCastle.Bcpg.Sig;
using SOA.Persistent;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IBKLinker_Minio.Entity.MinioController
namespace IBKLinker_Minio.Entity.MinioController
{
public class UserModel : MinioUser
{

Loading…
Cancel
Save