@@ -160,8 +160,8 @@ public async Task ProcessRentalReportUploadAsync(DssUploadDelivery upload)
160
160
return ;
161
161
}
162
162
163
- SendEmails ( upload , doValidateRegistration , errorCount ) ;
164
-
163
+ await SendEmails ( upload , doValidateRegistration , errorCount ) ;
164
+
165
165
processStopwatch . Stop ( ) ;
166
166
_logger . LogInformation ( $ "Finished: { report . ReportPeriodYm . ToString ( "yyyy-MM" ) } , { report . ProvidingOrganization . OrganizationNm } - { processStopwatch . Elapsed . TotalSeconds } seconds") ;
167
167
}
@@ -591,7 +591,7 @@ private async Task<bool> DoRegistrationValidation(Guid? userGuid)
591
591
return hasPermission ;
592
592
}
593
593
594
- private async void SendEmails ( DssUploadDelivery upload , bool doValidateRegistration , int errorCount )
594
+ private async Task SendEmails ( DssUploadDelivery upload , bool doValidateRegistration , int errorCount )
595
595
{
596
596
if ( upload . UploadUserGuid == null ) return ;
597
597
var user = await _userRepo . GetUserByGuid ( ( Guid ) upload . UploadUserGuid ! ) ;
@@ -600,8 +600,8 @@ private async void SendEmails(DssUploadDelivery upload, bool doValidateRegistrat
600
600
if ( history == null ) return ;
601
601
var adminEmail = _config . GetValue < string > ( "ADMIN_EMAIL" ) ;
602
602
if ( adminEmail == null ) return ;
603
- using var transaction = _unitOfWork . BeginTransaction ( ) ;
604
603
604
+ using var transaction = _unitOfWork . BeginTransaction ( ) ;
605
605
if ( doValidateRegistration )
606
606
{
607
607
//upload.UploadDeliveryId
@@ -636,7 +636,6 @@ private async void SendEmails(DssUploadDelivery upload, bool doValidateRegistrat
636
636
637
637
await _emailRepo . AddEmailMessage ( emailEntity ) ;
638
638
emailEntity . ExternalMessageNo = await template . SendEmail ( ) ;
639
- _unitOfWork . Commit ( ) ;
640
639
}
641
640
642
641
if ( errorCount > 0 )
@@ -673,8 +672,9 @@ private async void SendEmails(DssUploadDelivery upload, bool doValidateRegistrat
673
672
674
673
await _emailRepo . AddEmailMessage ( emailEntity ) ;
675
674
emailEntity . ExternalMessageNo = await template . SendEmail ( ) ;
676
- _unitOfWork . Commit ( ) ;
677
675
}
676
+
677
+ _unitOfWork . Commit ( ) ;
678
678
_unitOfWork . CommitTransaction ( transaction ) ;
679
679
}
680
680
}
0 commit comments