@@ -22,14 +22,16 @@ public class BizLicenseService : ServiceBase, IBizLicenseService
22
22
private IBizLicenseRepository _bizLicenseRepo ;
23
23
private IUploadDeliveryRepository _uploadRepo ;
24
24
private IOrganizationRepository _orgRepo ;
25
+ private ICodeSetRepository _codeSetRepo ;
25
26
26
27
public BizLicenseService ( ICurrentUser currentUser , IFieldValidatorService validator , IUnitOfWork unitOfWork , IMapper mapper , IHttpContextAccessor httpContextAccessor , ILogger < StrDssLogger > logger ,
27
- IBizLicenseRepository bizLicenseRepo , IUploadDeliveryRepository uploadRepo , IOrganizationRepository orgRepo )
28
+ IBizLicenseRepository bizLicenseRepo , IUploadDeliveryRepository uploadRepo , IOrganizationRepository orgRepo , ICodeSetRepository codeSetRepo )
28
29
: base ( currentUser , validator , unitOfWork , mapper , httpContextAccessor , logger )
29
30
{
30
31
_bizLicenseRepo = bizLicenseRepo ;
31
32
_uploadRepo = uploadRepo ;
32
33
_orgRepo = orgRepo ;
34
+ _codeSetRepo = codeSetRepo ;
33
35
}
34
36
35
37
public async Task < BizLicenseDto ? > GetBizLicense ( long businessLicenceId )
@@ -39,6 +41,11 @@ public BizLicenseService(ICurrentUser currentUser, IFieldValidatorService valida
39
41
40
42
public async Task ProcessBizLicenseUploadAsync ( )
41
43
{
44
+ if ( ! _validator . CommonCodes . Any ( ) )
45
+ {
46
+ _validator . CommonCodes = await _codeSetRepo . LoadCodeSetAsync ( ) ;
47
+ }
48
+
42
49
var upload = await _uploadRepo . GetUploadToProcessAsync ( UploadDeliveryTypes . LicenseData ) ;
43
50
44
51
if ( upload != null )
@@ -49,7 +56,19 @@ public async Task ProcessBizLicenseUploadAsync()
49
56
50
57
await ProcessBizLicenseUploadAsync ( upload ) ;
51
58
52
- await _bizLicenseRepo . ProcessBizLicTempTable ( ) ;
59
+ _unitOfWork . Commit ( ) ;
60
+
61
+ var errorCount = upload . DssUploadLines . Count ( x => x . IsValidationFailure ) ;
62
+
63
+ if ( errorCount == 0 )
64
+ {
65
+ await _bizLicenseRepo . ProcessBizLicTempTable ( ) ;
66
+ _logger . LogInformation ( $ "Success: Finished Business License Upload { upload . UploadDeliveryId } - { upload . ProvidingOrganizationId } - { upload . ProvidingOrganization . OrganizationNm } ") ;
67
+ }
68
+ else
69
+ {
70
+ _logger . LogInformation ( $ "Fail: Finished Business License Upload { upload . UploadDeliveryId } - { upload . ProvidingOrganizationId } - { upload . ProvidingOrganization . OrganizationNm } ") ;
71
+ }
53
72
54
73
transaction . Commit ( ) ;
55
74
}
@@ -136,7 +155,7 @@ private void SaveUploadLine(DssUploadLine uploadLine, Dictionary<string, List<st
136
155
uploadLine . ErrorTxt = systemError ;
137
156
}
138
157
139
- uploadLine . IsProcessed = false ;
158
+ uploadLine . IsProcessed = true ;
140
159
}
141
160
}
142
161
}
0 commit comments