diff --git a/24Hour/Controllers/Common/LawyerArchivesController.cs b/24Hour/Controllers/Common/LawyerArchivesController.cs index 383b7d8..715c622 100644 --- a/24Hour/Controllers/Common/LawyerArchivesController.cs +++ b/24Hour/Controllers/Common/LawyerArchivesController.cs @@ -1437,7 +1437,7 @@ namespace _24Hour.Controllers.Common lawyerservices = default(List), users = default(List) }); - foreach (var userim in importdata.users) + foreach (var userim in importdata.users.Where(x => x != null)) { var user = await _db.Queryable() .Where(x => x.cardId == userim.cardId) @@ -1497,7 +1497,7 @@ namespace _24Hour.Controllers.Common _db.CommitTran(); } } - foreach (var lawyersvc in importdata.lawyerservices) + foreach (var lawyersvc in importdata.lawyerservices.Where(x => x != null)) { var svc = await _db.Queryable() .Where(x => x.Id == lawyersvc.Id).FirstAsync(); @@ -1609,7 +1609,6 @@ namespace _24Hour.Controllers.Common var users = await _db.Queryable() .In(x => x.Id, userids) .ToListAsync(); - //把创建人Id变为创建人的身份证 lawyerarchives.All(x => { @@ -1634,11 +1633,10 @@ namespace _24Hour.Controllers.Common var lawyerdir = Path.Combine(packegdir, "lawyerservices", item.Id); if (Directory.Exists(lawyerdir) == false) Directory.CreateDirectory(lawyerdir); - var files = item.annex.ConvertToModel>() ?? new List(); var annecdir = Path.Combine(lawyerdir, "annexs"); if (Directory.Exists(annecdir) == false) Directory.CreateDirectory(annecdir); - foreach (var file in files) + foreach (var file in files.Where(x => x != null)) { var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + file.Replace("/", @"\"); if (System.IO.File.Exists(filepath)) @@ -1648,13 +1646,13 @@ namespace _24Hour.Controllers.Common } } - var legalphotots = item.legalAidPhoto.ConvertToModel>() ?? new List(); var legalAidPhotoDir = Path.Combine(lawyerdir, "legalAidPhoto"); if (Directory.Exists(legalAidPhotoDir) == false) Directory.CreateDirectory(legalAidPhotoDir); - foreach (var legalphotot in legalphotots) + foreach (var legalphotot in legalphotots.Where(x=>x!=null)) { + logger.LogInformation(legalphotot); var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + legalphotot.Replace("/", @"\"); if (System.IO.File.Exists(filepath)) { @@ -1664,12 +1662,10 @@ namespace _24Hour.Controllers.Common } - var relationshipProofPhotos = item.relationshipProofPhoto.ConvertToModel>() ?? new List(); var relationshipProofPhotoDir = Path.Combine(lawyerdir, "relationshipProofPhoto"); if (Directory.Exists(relationshipProofPhotoDir) == false) Directory.CreateDirectory(relationshipProofPhotoDir); - - foreach (var relationshipProofPhoto in relationshipProofPhotos) + foreach (var relationshipProofPhoto in relationshipProofPhotos.Where(x => x != null)) { var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + relationshipProofPhoto.Replace("/", @"\"); if (System.IO.File.Exists(filepath)) @@ -1678,11 +1674,10 @@ namespace _24Hour.Controllers.Common System.IO.File.Copy(filepath, targetfile); } } - var otherPhotos = item.otherPhoto.ConvertToModel>() ?? new List(); var otherPhotoDir = Path.Combine(lawyerdir, "otherPhoto"); if (Directory.Exists(otherPhotoDir) == false) Directory.CreateDirectory(otherPhotoDir); - foreach (var otherPhoto in otherPhotos) + foreach (var otherPhoto in otherPhotos.Where(x => x != null)) { var filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot") + otherPhoto.Replace("/", @"\"); if (System.IO.File.Exists(filepath)) @@ -1736,12 +1731,13 @@ namespace _24Hour.Controllers.Common } } } - + logger.LogInformation("step4"); ZipFile.CreateFromDirectory(packegdir, packegzipname); Directory.Delete(packegdir, true); result.result = $"/temp/{packegdirname}.zip"; - result.IsSucceed = true; + result.IsSucceed = true; + logger.LogInformation("step5"); return result; } catch (Exception ex)