20231221获取门禁人员接口增加更新照片功能
This commit is contained in:
parent
f49eba5e5f
commit
38aea9bbc5
|
@ -7,6 +7,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using BLL;
|
||||
using Model;
|
||||
using WebAPI.Filter;
|
||||
|
||||
namespace WebAPI.Controllers
|
||||
|
@ -235,7 +236,15 @@ namespace WebAPI.Controllers
|
|||
newPerson.AuditorDate = DateTime.Now;
|
||||
}
|
||||
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);
|
||||
newPerson.HeadImage = image;
|
||||
|
@ -257,15 +266,47 @@ namespace WebAPI.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(person.OutTime))
|
||||
if (string.IsNullOrEmpty(getPerson.PhotoUrl) && (person.headImage.Length > 0 || !string.IsNullOrEmpty(person.PhotoUrl)))
|
||||
{
|
||||
var outTime = Funs.GetNewDateTimeOrNow(person.OutTime);
|
||||
PersonService.PersonOut(getPerson.PersonId, outTime);
|
||||
responeData.message = "更新出场时间";
|
||||
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
|
||||
{
|
||||
responeData.message = "该身份证号码人员已存在!";
|
||||
if (!string.IsNullOrEmpty(person.OutTime))
|
||||
{
|
||||
var outTime = Funs.GetNewDateTimeOrNow(person.OutTime);
|
||||
PersonService.PersonOut(getPerson.PersonId, outTime);
|
||||
responeData.message = "更新出场时间";
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.message = "该身份证号码人员已存在!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,7 +324,7 @@
|
|||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:10684/</IISUrl>
|
||||
<IISUrl>http://localhost:14957/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
|
|
Loading…
Reference in New Issue