diff --git a/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs b/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs
index 65f47951..a3886a51 100644
--- a/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs
+++ b/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs
@@ -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 = "该身份证号码人员已存在!";
+ }
}
}
}
diff --git a/SGGL/WebAPI/WebAPI.csproj b/SGGL/WebAPI/WebAPI.csproj
index 1da74a06..baa3a8a3 100644
--- a/SGGL/WebAPI/WebAPI.csproj
+++ b/SGGL/WebAPI/WebAPI.csproj
@@ -324,7 +324,7 @@
True
0
/
- http://localhost:10684/
+ http://localhost:14957/
False
False