20231221获取人员接口 按照图片二进制更新

This commit is contained in:
杨红卫 2023-12-21 17:45:54 +08:00
parent 38aea9bbc5
commit 1f08356eb1
1 changed files with 12 additions and 23 deletions

View File

@ -266,32 +266,21 @@ namespace WebAPI.Controllers
}
else
{
if (string.IsNullOrEmpty(getPerson.PhotoUrl) && (person.headImage.Length > 0 || !string.IsNullOrEmpty(person.PhotoUrl)))
if (person.headImage.Length > 0)
{
if (person.headImage.Length == 0 && !string.IsNullOrEmpty(person.PhotoUrl))
var image = Convert.FromBase64String(person.headImage);
getPerson.HeadImage = image;
string rootPath = ConfigurationManager.AppSettings["localRoot"];
string path = "FileUpLoad/PersonBaseInfo/" + DateTime.Now.ToString("yyyy-MM") + "/";
string fileUrl = (rootPath + path).Replace('/', '\\');
string flieName = Funs.GetNewFileName() + "~" + person.PersonName + ".jpg";
if (!Directory.Exists(fileUrl))
{
var getS = AttachFileService.SetImageToByteArray(person.PhotoUrl);
if (getS != null)
{
person.headImage = getS.ToString();
}
}
if (person.headImage.Length > 0)
{
var image = Convert.FromBase64String(person.headImage);
getPerson.HeadImage = image;
string rootPath = ConfigurationManager.AppSettings["localRoot"];
string path = "FileUpLoad/PersonBaseInfo/" + DateTime.Now.ToString("yyyy-MM") + "/";
string fileUrl = (rootPath + path).Replace('/', '\\');
string flieName = Funs.GetNewFileName() + "~" + person.PersonName + ".jpg";
if (!Directory.Exists(fileUrl))
{
Directory.CreateDirectory(fileUrl);
}
getPerson.PhotoUrl = path + flieName;
System.IO.File.WriteAllBytes((fileUrl + flieName), image);
//AttachFileService.Base64ToImage(person.headImage, path, person.PersonName);
Directory.CreateDirectory(fileUrl);
}
getPerson.PhotoUrl = path + flieName;
System.IO.File.WriteAllBytes((fileUrl + flieName), image);
//AttachFileService.Base64ToImage(person.headImage, path, person.PersonName);
db.SubmitChanges();
responeData.message = "更新照片!";
}