diff --git a/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs b/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs index a3886a51..2e4f7af3 100644 --- a/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs +++ b/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs @@ -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 = "更新照片!"; }