From a68f13316a401002ab66223788e05bf05ff060ee Mon Sep 17 00:00:00 2001 From: sunliang <593170460@qq.com> Date: Sat, 23 Mar 2024 14:45:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E4=B8=AD=E5=9B=A0=E7=A7=BB=E5=8A=A8=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=8F=8A=E5=B1=82=E7=BA=A7=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MinioController/MinioApiController.cs | 173 ++++++++---------- 1 file changed, 80 insertions(+), 93 deletions(-) diff --git a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs index a90ca37..84c6397 100644 --- a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs +++ b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs @@ -965,6 +965,7 @@ namespace IBKLinker_Minio.Controller.MinioController ///给修改时间赋值 DateTime time = DateTime.Now;//取当前时间 MinioStoragePath date = new MinioStoragePath(); + IList UdpMFdata = new List(); List datelist = new List(); string Operate = "";//操作 if (data.Count > 0) @@ -985,6 +986,27 @@ namespace IBKLinker_Minio.Controller.MinioController date.ClearFlag = "0";//删除标记 0未删除 1删除 date.DocumentType = item.DocumentType;//文件种类 date.Version = item.Version;//版本 + #region 判断修改关联信息 + IList SelMFdata = new List(); + SelMFdata = db.Query("select * from MINIO_FILEASSOCIATION where 1=1 and (FILE_PK='" +item.Pk + "' or ASSOCIATION_FILE_PK='" + item.Pk + "')");//查询修改路径的文件关联关系 + if (SelMFdata.Count >0) //如果有数据 + { + foreach (var itemmf in SelMFdata) + { + if (itemmf.FilePk == item.Pk) //判断是关联的文件 + { + itemmf.FilePath = item.FilePath;//替换文件路径 + itemmf.FileLevel = item.FileLevel;//替换文件层级 + } + if (itemmf.AssociationFilePk == item.Pk) //判断是被关联的文件 + { + itemmf.AssociationFilePath = item.FilePath;//替换文件路径 + itemmf.AssociationFileLevel = item.FileLevel;//替换文件层级 + } + UdpMFdata.Add(itemmf);//写入list + } + } + #endregion if (item.Bate64 != null)//如果是修改文件 { var contentType = item.FileCategory; @@ -1008,6 +1030,10 @@ namespace IBKLinker_Minio.Controller.MinioController } if (datelist != null) { + if (UdpMFdata.Count > 0) + { + db.Update(UdpMFdata); + } db.Update(datelist); db.Commit();//提交事务 request.code = "0"; @@ -1577,7 +1603,7 @@ namespace IBKLinker_Minio.Controller.MinioController /// 接收切片 /// [HttpPost, Route("SliceUpload")] - public async Task SliceUploadAsync()//string FileName,string SliceQuantity,string FileNum, string FileId,string Size,string Upk, string FileType, string FilePath, string CreatorUser, string DownloadNum, string FileLevel, string FileCategory + public async Task SliceUploadAsync() { Dictionary dic = new Dictionary(); SliceUploadModel master = new SliceUploadModel(); @@ -1587,7 +1613,7 @@ namespace IBKLinker_Minio.Controller.MinioController var multipartMemoryStreamProvider = await Request.Content.ReadAsMultipartAsync(); foreach (var content in multipartMemoryStreamProvider.Contents) { - if (!string.IsNullOrEmpty(content.Headers.ContentDisposition.FileName)) + if (!string.IsNullOrEmpty(content.Headers.ContentDisposition.FileName))//判断是否是文件 { using (Stream stream = await content.ReadAsStreamAsync()) { @@ -1606,26 +1632,26 @@ namespace IBKLinker_Minio.Controller.MinioController } } } - else + else//否则就为其他字段 { string val = await content.ReadAsStringAsync(); - dic.Add(content.Headers.ContentDisposition.Name.Replace("\"", ""), System.Web.HttpUtility.UrlDecode(val)); + dic.Add(content.Headers.ContentDisposition.Name.Replace("\"", ""), System.Web.HttpUtility.UrlDecode(val));//写入缓存变量中 } } - - + #region 字段赋值 master.FileName = dic["FileName"].ToString();//文件名称 master.SliceQuantity = dic["SliceQuantity"].ToString();//切片总数量 - master.FileNum = dic["FileNum"].ToString(); - master.FileId = dic["FileId"].ToString(); - master.Upk = Convert.ToInt32( dic["Upk"].ToString()); - master.FileType = Convert.ToInt32(dic["FileType"].ToString()); - master.FilePath = dic["FilePath"].ToString(); - master.CreatorUser = dic["CreatorUser"].ToString(); - master.DownloadNum = Convert.ToInt32(dic["DownloadNum"].ToString()); - master.FileLevel = Convert.ToInt32(dic["FileLevel"].ToString()); - master.FileCategory = dic["FileCategory"].ToString(); - SliceUploadData.Add(master); + master.FileNum = dic["FileNum"].ToString();//文件序号 + master.FileId = dic["FileId"].ToString();//文件唯一标识 + master.Upk = Convert.ToInt32( dic["Upk"].ToString());//子文件夹的父ID + master.FileType = Convert.ToInt32(dic["FileType"].ToString());//文件类型 + master.FilePath = dic["FilePath"].ToString();//文件路径 + master.CreatorUser = dic["CreatorUser"].ToString();//创建者 + master.DownloadNum = Convert.ToInt32(dic["DownloadNum"].ToString());//下载次数 + master.FileLevel = Convert.ToInt32(dic["FileLevel"].ToString());//层级 + master.FileCategory = dic["FileCategory"].ToString();//文件格式 + #endregion + SliceUploadData.Add(master);//写入数据到全局变量缓存中 request.code = "0"; request.msg = "已接收切片"; } @@ -1657,7 +1683,6 @@ namespace IBKLinker_Minio.Controller.MinioController minio.MakeBucketAsync(BuckName);//创建桶 } #endregion - string base64 = ""; string Operate = "";//操作 MinioStoragePath date = new MinioStoragePath(); var file = SliceUploadData.Where(a => a.FileId == master.FileId).OrderBy(a => a.FileNum).ToList();//查询已经传完的唯一标识数据并以切片顺序排序 @@ -1671,7 +1696,6 @@ namespace IBKLinker_Minio.Controller.MinioController combinedList.AddRange(item.FileBase64); } var contentType = file[0].FileCategory;//获取文件类型 - //byte[] bt = Convert.FromBase64String(base64);//获取html base64 byte[] bt = combinedList.ToArray(); var uploadTask = minio.PutObjectAsync(BuckName, "/" + file[0].FileName, new MemoryStream(bt), bt.Length, contentType);//上传文件到minio数据库 uploadTask.Wait(); @@ -1738,9 +1762,10 @@ namespace IBKLinker_Minio.Controller.MinioController using (IDbContext filedb = ObjectContainer.GetObject("filedb")) { string sql = ""; - data = db.Query("select * from minio_storage_path where file_type='1' and upk='" + master + "' order by CREATOR_TIME asc").ToList(); + data = db.Query("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 = filedb.Query(sql); @@ -1752,80 +1777,43 @@ namespace IBKLinker_Minio.Controller.MinioController datan = db.Query("select * from minio_storage_path where file_name='" + dt.Rows[i]["title"].ToString() + "'").ToList(); if (datan.Count != 0) { - - - if (item.DocumentType == "1") + + IList SelMFdata = new List(); + SelMFdata = db.Query("select * from MINIO_FILEASSOCIATION where 1=1 and (FILE_PK='" + item.Pk + "' or ASSOCIATION_FILE_PK='" + item.Pk + "')"); + if (SelMFdata.Count > 0) { - if (datan[0].DocumentType == "2" || datan[0].DocumentType == "4") + foreach (var ca in SelMFdata) { - 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); + 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 (item.DocumentType == "2") + if (Asstion) { - if (datan[0].DocumentType == "3" || datan[0].DocumentType == "4") - { - 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); - } - } - if (item.DocumentType == "3") - { - if (datan[0].DocumentType == "4") - { - 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); - } + 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); } } } @@ -1841,10 +1829,10 @@ namespace IBKLinker_Minio.Controller.MinioController #region [HttpPost, Route("UdpDlsyncFile")] - public RequestEntity UdpDlsyncFile(string master,string parentfolderid, string DocumentType) + public RequestEntity UdpDlsyncFile(string master,string parentfolderid) { RequestEntity request = new RequestEntity();//定义返回集合 - List data = new List();//定义输出下载的list + //List data = new List();//定义输出下载的list List newdata = new List();//定义输出下载的list List dldata = new List();//定义输出下载的list List datan = new List(); @@ -1858,12 +1846,12 @@ namespace IBKLinker_Minio.Controller.MinioController using (IDbContext filedb = ObjectContainer.GetObject("filedb")) { string sql = ""; - data = db.Query("select * from minio_storage_path where file_type='1' and upk='" + master + "' order by CREATOR_TIME desc").ToList(); + //data = db.Query("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, data[0].CreatorTime); + sql = string.Format("select * from DLSYNC where parentfolderid='{0}' and (event='update' or event='add') ", parentfolderid); dt = filedb.Query(sql); string sel = string.Format("select * from minio_storage_path where pk='{0}'", master); ; dta = db.Query(sel); @@ -1888,7 +1876,6 @@ namespace IBKLinker_Minio.Controller.MinioController dc.FileLevel = Convert.ToInt32( dta.Rows[0]["FILE_LEVEL"].ToString())+1; dc.ModifyTime = mtime.ToDateTime(); dc.ClearFlag = "0"; - dc.DocumentType = DocumentType; dc.Version = dt.Rows[i]["VERSION"].ToString(); newdata.Add(dc); }