20231221获取人员接口 按照图片二进制更新
This commit is contained in:
parent
38aea9bbc5
commit
1f08356eb1
|
@ -266,32 +266,21 @@ namespace WebAPI.Controllers
|
||||||
}
|
}
|
||||||
else
|
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);
|
Directory.CreateDirectory(fileUrl);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
getPerson.PhotoUrl = path + flieName;
|
||||||
|
System.IO.File.WriteAllBytes((fileUrl + flieName), image);
|
||||||
|
//AttachFileService.Base64ToImage(person.headImage, path, person.PersonName);
|
||||||
db.SubmitChanges();
|
db.SubmitChanges();
|
||||||
responeData.message = "更新照片!";
|
responeData.message = "更新照片!";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue