diff --git a/SolarPower/Controllers/OperationController.cs b/SolarPower/Controllers/OperationController.cs index 652667a..8608b20 100644 --- a/SolarPower/Controllers/OperationController.cs +++ b/SolarPower/Controllers/OperationController.cs @@ -677,7 +677,7 @@ namespace SolarPower.Controllers _ => "" }; var user = await userRepository.GetOneAsync(person); - if (IsValidEmail(user.Email)) + if (user.Email != null && IsValidEmail(user.Email)) { NoticeSchedule schedule = new NoticeSchedule() { @@ -721,7 +721,7 @@ namespace SolarPower.Controllers }; //var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); - if (IsValidEmail(firm.Email)) + if (firm.Email != null && IsValidEmail(firm.Email)) { NoticeSchedule schedule = new NoticeSchedule() { @@ -909,7 +909,7 @@ namespace SolarPower.Controllers _ => "" }; var user = await userRepository.GetOneAsync(person); - if (IsValidEmail(user.Email)) + if (user.Email != null && IsValidEmail(user.Email)) { NoticeSchedule schedule = new NoticeSchedule() { @@ -952,7 +952,7 @@ namespace SolarPower.Controllers }; // var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); - if (IsValidEmail(firm.Email)) + if (firm.Email != null && IsValidEmail(firm.Email)) { NoticeSchedule schedule = new NoticeSchedule() { diff --git a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs index 43e9001..911a475 100644 --- a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs +++ b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs @@ -250,7 +250,7 @@ namespace SolarPower.Quartz.Jobs var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented)); if (stationReportName != "") { - if (IsValidEmail(user.Email)) + if (user.Email != null && IsValidEmail(user.Email)) { NoticeSchedule DaySchedule = new NoticeSchedule() { @@ -288,7 +288,7 @@ namespace SolarPower.Quartz.Jobs Userid = user.Id }; var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented)); - if (IsValidEmail(user.Email)) + if (user.Email != null && IsValidEmail(user.Email)) { NoticeSchedule MaxSchedule = new NoticeSchedule() { @@ -324,7 +324,7 @@ namespace SolarPower.Quartz.Jobs Userid = user.Id }; var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented)); - if (IsValidEmail(user.Email)) + if (user.Email != null && IsValidEmail(user.Email)) { NoticeSchedule MaxmonthSchedule = new NoticeSchedule() { @@ -370,7 +370,7 @@ namespace SolarPower.Quartz.Jobs var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented)); if (stationReportmonthName != "") { - if (IsValidEmail(user.Email)) + if (user.Email != null && IsValidEmail(user.Email)) { NoticeSchedule MonthSchedule = new NoticeSchedule() { diff --git a/SolarPower/Quartz/Jobs/SendEmailJob.cs b/SolarPower/Quartz/Jobs/SendEmailJob.cs index 0c6897b..25ac79f 100644 --- a/SolarPower/Quartz/Jobs/SendEmailJob.cs +++ b/SolarPower/Quartz/Jobs/SendEmailJob.cs @@ -44,7 +44,7 @@ namespace SolarPower.Quartz.Jobs var updateNoticeSchedules = new List(); foreach (var notice in noticeSchedules) { - if (IsValidEmail(notice.RecipientEmail)) { + if (notice.RecipientEmail != null && IsValidEmail(notice.RecipientEmail)) { var attachments = new List(); var recipientEmails = new List() { diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index 1fe58e6..2ba0976 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -649,7 +649,7 @@ namespace SolarPower.Repository.Implement List value = new List(); foreach (MyUser a in personal) { - if (IsValidEmail(a.Email)) + if (a.Email != null && IsValidEmail(a.Email)) { value.Add($@"(1,'{a.Name}','{a.Email}','{Title}','{content}',{a.Id}, {emailType})"); }