优化查询所有文件夹接口

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

@ -1,41 +1,15 @@
using IBKLinker_Minio.Entity; using log4net;
using log4net;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Http;
using Minio; using Minio;
using System.Net.PeerToPeer;
using System.IO; 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 IBKLinker_Minio.Entity.MinioController;
using SOA.Objects; using SOA.Objects;
using SOA.Persistent; 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 System.Configuration;
using NPOI.SS.Formula.Atp; using IBKLinker_Minio.Controller.MinioController;
namespace IBKLinker_Minio.Common namespace IBKLinker_Minio.Common
{ {
@ -103,7 +77,6 @@ namespace IBKLinker_Minio.Common
} }
#endregion #endregion
#region 文件夹递归查询 #region 文件夹递归查询
/// <summary> /// <summary>
/// 文件夹递归查询 /// 文件夹递归查询
@ -111,10 +84,10 @@ namespace IBKLinker_Minio.Common
public List<StoragePath> GetSubDirectories(int parentPk) public List<StoragePath> GetSubDirectories(int parentPk)
{ {
List<StoragePath> subDirs = new List<StoragePath>(); 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();//查询子级中是否还有子级 if (subDir.Upk == parentPk)
foreach (var subDir in subDirectories)
{ {
RequstStoragePath subDirModel = new RequstStoragePath(); RequstStoragePath subDirModel = new RequstStoragePath();
subDirModel.Pk = subDir.Pk;//主键ID subDirModel.Pk = subDir.Pk;//主键ID
@ -228,5 +201,7 @@ namespace IBKLinker_Minio.Common
} }
} }
#endregion #endregion
} }
} }

@ -4,45 +4,21 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Http; using System.Web.Http;
using Minio; using Minio;
using System.Net.PeerToPeer;
using System.IO; using System.IO;
using System.Reactive.Linq; 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 IBKLinker_Minio.Entity.MinioController;
using SOA.Objects; using SOA.Objects;
using SOA.Persistent; 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.Net.Http;
using System.Web.UI.WebControls;
using System.Runtime.Remoting.Contexts;
using System.Runtime.InteropServices;
using System.Net; using System.Net;
using NPOI.XSSF.UserModel; using NPOI.XSSF.UserModel;
using NPOI.SS.UserModel;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using NPOI.SS.Formula.Functions;
using System.Xml.Linq;
using NPOI.HPSF;
using IBKLinker_Minio.Common; using IBKLinker_Minio.Common;
using NPOI.POIFS.Crypt.Dsig;
using NPOI.SS.Formula.Atp;
using Org.BouncyCastle.Asn1.Pkcs;
using System.Windows.Forms; using System.Windows.Forms;
using Org.BouncyCastle.Asn1.Ocsp;
using System.Data; using System.Data;
using System.Web.WebSockets;
using System.Security.Cryptography;
namespace IBKLinker_Minio.Controller.MinioController namespace IBKLinker_Minio.Controller.MinioController
{ {
@ -59,7 +35,7 @@ namespace IBKLinker_Minio.Controller.MinioController
/// </summary> /// </summary>
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static List<SliceUploadModel> SliceUploadData = new List<SliceUploadModel>(); public static List<SliceUploadModel> SliceUploadData = new List<SliceUploadModel>();
public static List<MinioStoragePath> rootDirectories = new List<MinioStoragePath>();
#region minio权限表 #region minio权限表
/// <summary> /// <summary>
@ -1258,8 +1234,10 @@ namespace IBKLinker_Minio.Controller.MinioController
List<RequstStoragePath> requstStoragePaths = new List<RequstStoragePath>(); List<RequstStoragePath> requstStoragePaths = new List<RequstStoragePath>();
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db")) 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) foreach (var rootDir in rootDirectories)
{
if (rootDir.Upk == 0 && rootDir.FileLevel == 1)//只要根目录文件夹
{ {
RequstStoragePath rootModel = new RequstStoragePath(); RequstStoragePath rootModel = new RequstStoragePath();
rootModel.Pk = rootDir.Pk;//主键ID rootModel.Pk = rootDir.Pk;//主键ID
@ -1280,6 +1258,7 @@ namespace IBKLinker_Minio.Controller.MinioController
requstStoragePaths.Add(rootModel);//添加list requstStoragePaths.Add(rootModel);//添加list
} }
} }
}
request.data = requstStoragePaths; request.data = requstStoragePaths;
request.code = "0"; request.code = "0";
} }
@ -1785,149 +1764,5 @@ namespace IBKLinker_Minio.Controller.MinioController
} }
#endregion #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; namespace IBKLinker_Minio.Entity.MinioController
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IBKLinker_Minio.Entity.MinioController
{ {
/// <summary> /// <summary>
/// 查询minio文件文件夹路径model包括模糊查询文件名称以及根据时间查询 /// 查询minio文件文件夹路径model包括模糊查询文件名称以及根据时间查询

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

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

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

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

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

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

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

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

@ -1,10 +1,4 @@
using SOA.Persistent; using System;
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
{ {

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

@ -1,13 +1,4 @@
using Org.BouncyCastle.Bcpg.Sig; namespace IBKLinker_Minio.Entity.MinioController
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
{ {
public class UserModel : MinioUser public class UserModel : MinioUser
{ {

Loading…
Cancel
Save