20231221获取门禁人员接口增加更新照片功能
This commit is contained in:
parent
f49eba5e5f
commit
38aea9bbc5
|
@ -7,6 +7,7 @@ using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
using BLL;
|
using BLL;
|
||||||
|
using Model;
|
||||||
using WebAPI.Filter;
|
using WebAPI.Filter;
|
||||||
|
|
||||||
namespace WebAPI.Controllers
|
namespace WebAPI.Controllers
|
||||||
|
@ -235,7 +236,15 @@ namespace WebAPI.Controllers
|
||||||
newPerson.AuditorDate = DateTime.Now;
|
newPerson.AuditorDate = DateTime.Now;
|
||||||
}
|
}
|
||||||
newPerson.OutTime = Funs.GetNewDateTime(person.OutTime);
|
newPerson.OutTime = Funs.GetNewDateTime(person.OutTime);
|
||||||
if (person.headImage != null)
|
if (person.headImage.Length == 0 && !string.IsNullOrEmpty(person.PhotoUrl))
|
||||||
|
{
|
||||||
|
var getS = AttachFileService.SetImageToByteArray(person.PhotoUrl);
|
||||||
|
if (getS != null)
|
||||||
|
{
|
||||||
|
person.headImage = getS.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (person.headImage.Length > 0)
|
||||||
{
|
{
|
||||||
var image = Convert.FromBase64String(person.headImage);
|
var image = Convert.FromBase64String(person.headImage);
|
||||||
newPerson.HeadImage = image;
|
newPerson.HeadImage = image;
|
||||||
|
@ -256,6 +265,37 @@ namespace WebAPI.Controllers
|
||||||
responeData.message = "新增人员成功!";
|
responeData.message = "新增人员成功!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(getPerson.PhotoUrl) && (person.headImage.Length > 0 || !string.IsNullOrEmpty(person.PhotoUrl)))
|
||||||
|
{
|
||||||
|
if (person.headImage.Length == 0 && !string.IsNullOrEmpty(person.PhotoUrl))
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
db.SubmitChanges();
|
||||||
|
responeData.message = "更新照片!";
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(person.OutTime))
|
if (!string.IsNullOrEmpty(person.OutTime))
|
||||||
{
|
{
|
||||||
|
@ -269,6 +309,7 @@ namespace WebAPI.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
responeData.code = 0;
|
responeData.code = 0;
|
||||||
|
|
|
@ -324,7 +324,7 @@
|
||||||
<AutoAssignPort>True</AutoAssignPort>
|
<AutoAssignPort>True</AutoAssignPort>
|
||||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||||
<IISUrl>http://localhost:10684/</IISUrl>
|
<IISUrl>http://localhost:14957/</IISUrl>
|
||||||
<NTLMAuthentication>False</NTLMAuthentication>
|
<NTLMAuthentication>False</NTLMAuthentication>
|
||||||
<UseCustomServer>False</UseCustomServer>
|
<UseCustomServer>False</UseCustomServer>
|
||||||
<CustomServerUrl>
|
<CustomServerUrl>
|
||||||
|
|
Loading…
Reference in New Issue