|
@@ -396,57 +396,74 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration |
|
|
} |
|
|
} |
|
|
public void SynPhoto() |
|
|
public void SynPhoto() |
|
|
{ |
|
|
{ |
|
|
|
|
|
var logpath = @"D:\新版数字化校园\Publish\log"; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var stuList = this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>() |
|
|
|
|
|
|
|
|
var stuList = this.BaseRepository("CollegeMIS").FindList<StuInfoBasicEntity>(x => x.Grade == "21") |
|
|
.ToList(); |
|
|
.ToList(); |
|
|
var url = AppDomain.CurrentDomain.BaseDirectory; |
|
|
var url = AppDomain.CurrentDomain.BaseDirectory; |
|
|
|
|
|
System.IO.File.AppendAllText(logpath, "同步照片\r\n"); |
|
|
|
|
|
var num = 0; |
|
|
foreach (var stuInfo in stuList) |
|
|
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<AnnexesFileEntity>(a => a.F_FolderId == stuInfo.Photo); |
|
|
|
|
|
if (annex == null) |
|
|
|
|
|
|
|
|
//照片不为空 |
|
|
|
|
|
if (!string.IsNullOrEmpty(stuInfo.Photo)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
var annex = this.BaseRepository() |
|
|
|
|
|
.FindEntity<AnnexesFileEntity>(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() |
|
|
var annexEntity = new AnnexesFileEntity() |
|
|
{ |
|
|
{ |
|
|
F_Id = Guid.NewGuid().ToString(), |
|
|
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 |
|
|
F_FolderId = stuInfo.Photo |
|
|
}; |
|
|
}; |
|
|
|
|
|
annexEntity.Create(); |
|
|
|
|
|
this.BaseRepository("CollegeMIS").Update(stuInfo); |
|
|
this.BaseRepository().Insert(annexEntity); |
|
|
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 |
|
|
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) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
|
|
|
|
System.IO.File.AppendAllText(logpath, "同步照片异常:" + ex.Message + "\r\n"); |
|
|
if (ex is ExceptionEx) |
|
|
if (ex is ExceptionEx) |
|
|
{ |
|
|
{ |
|
|
throw; |
|
|
throw; |
|
|