From 1d8d92f13770013e647dc40d93065eea8fbb3c2a Mon Sep 17 00:00:00 2001 From: zhangli <1109134334@qq.com> Date: Mon, 13 Sep 2021 10:53:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=B1=8D=E7=AE=A1=E7=90=86=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=85=A7=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StuInfoBasic/StuInfoBasicService.cs | 71 ++++++++++++------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs index a1dc54122..1b4af9cc0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs @@ -396,57 +396,74 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } public void SynPhoto() { + var logpath = @"D:\新版数字化校园\Publish\log"; try { - var stuList = this.BaseRepository("CollegeMIS").FindList() + var stuList = this.BaseRepository("CollegeMIS").FindList(x => x.Grade == "21") .ToList(); var url = AppDomain.CurrentDomain.BaseDirectory; + System.IO.File.AppendAllText(logpath, "同步照片\r\n"); + var num = 0; foreach (var stuInfo in stuList) { - //照片不为空 - if (!string.IsNullOrEmpty(stuInfo.Photo)) + var F_FileName = stuInfo.ksh + ".jpg"; + var F_FilePath = $"{url}/Resource/UserPhoto/KSZP/{F_FileName}"; + //判断文件是否存在 + if (System.IO.File.Exists(F_FilePath)) { - var annex = this.BaseRepository() - .FindEntity(a => a.F_FolderId == stuInfo.Photo); - if (annex == null) + //照片不为空 + if (!string.IsNullOrEmpty(stuInfo.Photo)) { + var annex = this.BaseRepository() + .FindEntity(a => a.F_FolderId == stuInfo.Photo); + if (annex == null) + { + var annexEntity = new AnnexesFileEntity() + { + F_Id = Guid.NewGuid().ToString(), + F_FileName = F_FileName, + F_FilePath = F_FilePath, + F_FolderId = stuInfo.Photo + }; + this.BaseRepository().Insert(annexEntity); + + } + else + { + annex.F_FileName = F_FileName; + annex.F_FilePath = F_FilePath; + this.BaseRepository().Update(annex); + } + } + else + { + stuInfo.Photo = Guid.NewGuid().ToString(); + var annexEntity = new AnnexesFileEntity() { F_Id = Guid.NewGuid().ToString(), - F_FileName = stuInfo.IdentityCardNo + ".jpg", - F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg", + F_FileName = F_FileName, + F_FilePath = F_FilePath, F_FolderId = stuInfo.Photo }; + annexEntity.Create(); + this.BaseRepository("CollegeMIS").Update(stuInfo); this.BaseRepository().Insert(annexEntity); - - } - else - { - annex.F_FileName = stuInfo.IdentityCardNo + ".jpg"; - annex.F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg"; - this.BaseRepository().Update(annex); } + + num++; } else { - stuInfo.Photo = Guid.NewGuid().ToString(); - var annexEntity = new AnnexesFileEntity() - { - F_Id = Guid.NewGuid().ToString(), - F_FileName = stuInfo.IdentityCardNo + ".jpg", - F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg", - F_FolderId = stuInfo.Photo - }; - annexEntity.Create(); - this.BaseRepository("CollegeMIS").Update(stuInfo); - this.BaseRepository().Insert(annexEntity); + System.IO.File.AppendAllText(logpath, F_FilePath + "学生:" + stuInfo.StuName + "文件不存在" + "\r\n"); } - } + System.IO.File.AppendAllText(logpath, "同步照片:" + num + "个学生\r\n"); } catch (Exception ex) { + System.IO.File.AppendAllText(logpath, "同步照片异常:" + ex.Message + "\r\n"); if (ex is ExceptionEx) { throw;