Browse Source

回传2.0图片时 添加解密处理,优化图片导出函数

develop-FileUpload-test
胡超1 2 years ago
parent
commit
068e01aef2
  1. 79
      24Hour/Controllers/Common/LawyerArchivesController.cs

79
24Hour/Controllers/Common/LawyerArchivesController.cs

@ -26,6 +26,7 @@ using NPOI.SS.Formula.Functions;
using SqlSugar;
using SqlSugar.Extensions;
using System.Data;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.WebSockets;
@ -1051,12 +1052,12 @@ namespace _24Hour.Controllers.Common
{
foreach (var item in identityphotos)
{
var urlpath = item.Split('/');
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot", Path.Combine(urlpath));
var path = item.Replace(@"/", @"\");
var filepath = Environment.CurrentDirectory + @"\wwwroot" + path;
if (System.IO.File.Exists(filepath))
{
var basestr = Convert.ToBase64String(System.IO.File.ReadAllBytes(filepath));
var basestr = Elight.Utility.Encrypt.DataEncryption.Decryptiones(filepath);
await twentyClient.UploadImage(new UploadDto()
{
Bmsah = registerinfo.bmsah,
@ -1068,7 +1069,6 @@ namespace _24Hour.Controllers.Common
ImageStr = basestr
});
}
}
}
};
@ -2000,60 +2000,30 @@ namespace _24Hour.Controllers.Common
var lawyerdir = Path.Combine(packegdir, "lawyerservices", item.Id);
if (Directory.Exists(lawyerdir) == false) Directory.CreateDirectory(lawyerdir);
var files = item.annex.ConvertToModel<List<string>>() ?? new List<string>();
var annecdir = Path.Combine(lawyerdir, "annexs");
if (Directory.Exists(annecdir) == false) Directory.CreateDirectory(annecdir);
foreach (var file in files.Where(x => x != null))
{
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + file.Replace("/", @"\");
if (System.IO.File.Exists(filepath))
{
var targetfile = Path.Combine(annecdir, Path.GetFileName(filepath));
System.IO.File.Copy(filepath, targetfile, true);
}
}
var legalphotots = item.legalAidPhoto.ConvertToModel<List<string>>() ?? new List<string>();
var legalAidPhotoDir = Path.Combine(lawyerdir, "legalAidPhoto");
if (Directory.Exists(legalAidPhotoDir) == false) Directory.CreateDirectory(legalAidPhotoDir);
foreach (var legalphotot in legalphotots.Where(x => x != null))
var packetPhotoField = (string? photostring, string? dirname) =>
{
logger.LogInformation(legalphotot);
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + legalphotot.Replace("/", @"\");
if (System.IO.File.Exists(filepath))
if (string.IsNullOrEmpty(photostring))
{
var targetfile = Path.Combine(legalAidPhotoDir, Path.GetFileName(filepath));
System.IO.File.Copy(filepath, targetfile, true);
}
}
var relationshipProofPhotos = item.relationshipProofPhoto.ConvertToModel<List<string>>() ?? new List<string>();
var relationshipProofPhotoDir = Path.Combine(lawyerdir, "relationshipProofPhoto");
if (Directory.Exists(relationshipProofPhotoDir) == false) Directory.CreateDirectory(relationshipProofPhotoDir);
foreach (var relationshipProofPhoto in relationshipProofPhotos.Where(x => x != null))
{
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + relationshipProofPhoto.Replace("/", @"\");
if (System.IO.File.Exists(filepath))
{
var targetfile = Path.Combine(legalAidPhotoDir, Path.GetFileName(filepath));
System.IO.File.Copy(filepath, targetfile, true);
}
return;
}
var otherPhotos = item.otherPhoto.ConvertToModel<List<string>>() ?? new List<string>();
var otherPhotoDir = Path.Combine(lawyerdir, "otherPhoto");
if (Directory.Exists(otherPhotoDir) == false) Directory.CreateDirectory(otherPhotoDir);
foreach (var otherPhoto in otherPhotos.Where(x => x != null))
var photos = photostring.ConvertToModel<List<string>>() ?? new List<string>();
var photoDirname = Path.Combine(lawyerdir, dirname);
if (Directory.Exists(photoDirname) == false) Directory.CreateDirectory(photoDirname);
foreach (var photo in photos.Where(x => x != null))
{
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + otherPhoto.Replace("/", @"\");
var urlpath = photo.Split('/');
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot", Path.Combine(urlpath));
if (System.IO.File.Exists(filepath))
{
var targetfile = Path.Combine(legalAidPhotoDir, Path.GetFileName(filepath));
var targetfile = Path.Combine(photoDirname, Path.GetFileName(filepath));
System.IO.File.Copy(filepath, targetfile, true);
}
}
};
packetPhotoField(item?.annex, "annexs");
packetPhotoField(item?.legalAidPhoto, "legalAidPhoto");
packetPhotoField(item?.relationshipProofPhoto, "relationshipProofPhoto");
packetPhotoField(item?.otherPhoto, "otherPhoto");
}
//存储用户的相关附件
foreach (var item in users)
@ -2067,7 +2037,8 @@ namespace _24Hour.Controllers.Common
if (Directory.Exists(cardidDir) == false) Directory.CreateDirectory(cardidDir);
foreach (var file in cardids)
{
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + file.Replace("/", @"\");
var urlpath = file.Split('/');
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot", Path.Combine(urlpath));
if (System.IO.File.Exists(filepath))
{
System.IO.File.Copy(filepath, Path.Combine(cardidDir, Path.GetFileName(filepath)), true);
@ -2079,7 +2050,9 @@ namespace _24Hour.Controllers.Common
if (Directory.Exists(identityphotosDir) == false) Directory.CreateDirectory(identityphotosDir);
foreach (var file in identityphotos)
{
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + file.Replace("/", @"\");
// var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + file.Replace("/", @"\");
var urlpath = file.Split('/');
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot", Path.Combine(urlpath));
if (System.IO.File.Exists(filepath))
{
System.IO.File.Copy(filepath, Path.Combine(identityphotosDir, Path.GetFileName(filepath)), true);
@ -2091,7 +2064,9 @@ namespace _24Hour.Controllers.Common
if (Directory.Exists(departmentPhotosDir) == false) Directory.CreateDirectory(departmentPhotosDir);
foreach (var file in departmentPhotos)
{
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + file.Replace("/", @"\");
//var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + file.Replace("/", @"\");
var urlpath = file.Split('/');
var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot", Path.Combine(urlpath));
if (System.IO.File.Exists(filepath))
{
System.IO.File.Copy(filepath, Path.Combine(departmentPhotosDir, Path.GetFileName(filepath)), true);

Loading…
Cancel
Save