|
@@ -6,6 +6,7 @@ using Aspose.Words.Tables;
|
|
using DiffMatchPatch;
|
|
using DiffMatchPatch;
|
|
using EyeSoft.Runtime.InteropServices;
|
|
using EyeSoft.Runtime.InteropServices;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
+using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using Microsoft.VisualBasic;
|
|
using Microsoft.VisualBasic;
|
|
@@ -50,6 +51,7 @@ using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
using System.Drawing.Printing;
|
|
using System.Drawing.Printing;
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
|
|
+using System.IO;
|
|
using System.IO.Compression;
|
|
using System.IO.Compression;
|
|
using System.Text.Json;
|
|
using System.Text.Json;
|
|
using System.Web;
|
|
using System.Web;
|
|
@@ -5095,6 +5097,153 @@ FROM
|
|
return Ok(jw);
|
|
return Ok(jw);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [HttpPost]
|
|
|
|
+ public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
|
|
|
|
+ {
|
|
|
|
+ if (dto.Files == null || dto.Files.Count == 0)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(false, "无文件信息!"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(false, "文件大小超过20M!"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(dto.Userid < 1)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(false, "请传入有效的Userid!"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
|
|
|
|
+ .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
|
|
|
|
+ .Select((u,j)=> new
|
|
|
|
+ {
|
|
|
|
+ u.CnName,
|
|
|
|
+ UserId = u.Id,
|
|
|
|
+ j.JobName,
|
|
|
|
+ })
|
|
|
|
+ .First();
|
|
|
|
+
|
|
|
|
+ if (jobInfo == null)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(false, "请传入有效的Userid!"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<string> commonFileExtensions = new List<string>
|
|
|
|
+ {
|
|
|
|
+ // 文本文件
|
|
|
|
+ ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
|
|
|
|
+
|
|
|
|
+ // 图片文件
|
|
|
|
+ ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
|
|
|
|
+
|
|
|
|
+ // 视频文件
|
|
|
|
+ ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
|
|
|
|
+
|
|
|
|
+ // 音频文件
|
|
|
|
+ ".mp3", ".wav", ".ogg", ".aac", ".flac",
|
|
|
|
+
|
|
|
|
+ // 压缩文件
|
|
|
|
+ ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
|
|
|
|
+
|
|
|
|
+ // 数据文件
|
|
|
|
+ ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
|
|
|
|
+ var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
|
|
|
|
+ commonFileExtensions.AddRange(settingExtend);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception)
|
|
|
|
+ {}
|
|
|
|
+
|
|
|
|
+ var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
|
|
|
|
+
|
|
|
|
+ if (setdata == null)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(false, "请传入有效的FileType!"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<GroupShareFile> insertList = new List<GroupShareFile>();
|
|
|
|
+
|
|
|
|
+ string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"\\{setdata.Name}\\";
|
|
|
|
+
|
|
|
|
+ if (!Directory.Exists(winPath))
|
|
|
|
+ {
|
|
|
|
+ Directory.CreateDirectory(winPath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach (var item in dto.Files)
|
|
|
|
+ {
|
|
|
|
+ var houzui = Path.GetExtension(item.FileName);
|
|
|
|
+
|
|
|
|
+ if (!commonFileExtensions.Contains(houzui))
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(false, "未知后缀名称!"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
|
|
|
|
+ var saveFilePath = winPath + fileName;
|
|
|
|
+
|
|
|
|
+ using (FileStream fs = System.IO.File.Create(saveFilePath))
|
|
|
|
+ {
|
|
|
|
+ item.CopyTo(fs);
|
|
|
|
+ fs.Flush();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var fileDetail = new GroupShareFile()
|
|
|
|
+ {
|
|
|
|
+ CreateUserId = dto.Userid,
|
|
|
|
+ CreateTime = DateTime.Now,
|
|
|
|
+ UploadJob = jobInfo.JobName,
|
|
|
|
+ FileName = fileName,
|
|
|
|
+ FileType = dto.FileType,
|
|
|
|
+ Diid = dto.Diid,
|
|
|
|
+ FilePath = winPath + fileName,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ insertList.Add(fileDetail);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _sqlSugar.Insertable<GroupShareFile>(insertList).ExecuteCommand();
|
|
|
|
+
|
|
|
|
+ return Ok(JsonView(true,"保存成功!"));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [HttpPost]
|
|
|
|
+ public IActionResult QuerySharedFile(QuerySharedFileDto dto)
|
|
|
|
+ {
|
|
|
|
+ var queryExpression = Expressionable.Create<GroupShareFile>()
|
|
|
|
+ .AndIF(dto.Diid != 0, x => x.Diid == dto.Diid)
|
|
|
|
+ .AndIF(dto.FileType != 0, x => x.FileType == dto.FileType)
|
|
|
|
+ .And(x => x.IsDel == 0);
|
|
|
|
+
|
|
|
|
+ int totalCount = 0;
|
|
|
|
+ var dbQuery = _sqlSugar.Queryable<GroupShareFile>()
|
|
|
|
+ .Where(queryExpression.ToExpression())
|
|
|
|
+ .Select(x => new
|
|
|
|
+ {
|
|
|
|
+ x.Id,
|
|
|
|
+ FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
|
|
|
|
+ x.FileName,
|
|
|
|
+ x.FileType,
|
|
|
|
+ x.CreateTime,
|
|
|
|
+ })
|
|
|
|
+ .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
|
|
|
|
+
|
|
|
|
+ return Ok(JsonView(true, "success", new
|
|
|
|
+ {
|
|
|
|
+ FileList = dbQuery,
|
|
|
|
+ dto.PageSize,
|
|
|
|
+ dto.PageIndex,
|
|
|
|
+ totalCount
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 查询各模块已保存文件
|
|
/// 查询各模块已保存文件
|
|
/// </summary>
|
|
/// </summary>
|