|
12 | 12 | using EstateManagement.DataTransferObjects.Requests; |
13 | 13 | using EstateManagement.DataTransferObjects.Responses; |
14 | 14 | using Quartz; |
| 15 | + using Quartz.Impl; |
15 | 16 | using SecurityService.Client; |
16 | 17 | using SecurityService.DataTransferObjects.Responses; |
17 | 18 |
|
@@ -130,58 +131,57 @@ private async Task GenerateFileUploads(Guid estateId, |
130 | 131 | // get the contract |
131 | 132 | var contract = contracts.SingleOrDefault(c => c.OperatorId == merchantOperator.OperatorId); |
132 | 133 |
|
133 | | - if (merchantOperator.Name == "Voucher") |
134 | | - { |
135 | | - // Generate a voucher file |
136 | | - var voucherFile = this.GenerateVoucherFile(fileDate, contract.Description.Replace("Contract", ""), numberOfSales); |
137 | | - fileData = voucherFile.fileLines; |
138 | | - // Need to make a deposit for this amount - last sale |
139 | | - Decimal depositAmount = voucherFile.totalValue - voucherFile.lastSale; |
140 | | - await this.MakeMerchantDeposit(accessToken, merchant, depositAmount, fileDate.AddSeconds(1), cancellationToken); |
141 | | - } |
142 | | - else |
143 | | - { |
144 | | - // generate a topup file |
145 | | - var topupFile = this.GenerateTopupFile(fileDate, numberOfSales); |
146 | | - fileData = topupFile.fileLines; |
147 | | - // Need to make a deposit for this amount - last sale |
148 | | - Decimal depositAmount = topupFile.totalValue - topupFile.lastSale; |
149 | | - await this.MakeMerchantDeposit(accessToken, merchant, depositAmount, fileDate.AddSeconds(2), cancellationToken); |
150 | | - } |
| 134 | + // Only process if we find the contract |
| 135 | + if (contract != null) { |
151 | 136 |
|
152 | | - // Write this file to disk |
153 | | - Directory.CreateDirectory($"/home/txnproc/txngenerator/{merchantOperator.Name}"); |
154 | | - using(StreamWriter sw = |
155 | | - new |
156 | | - StreamWriter($"/home/txnproc/txngenerator/{merchantOperator.Name}/{contract.Description.Replace("Contract", "")}-{fileDate:yyyy-MM-dd-HH-mm-ss}")) |
157 | | - { |
158 | | - foreach (String fileLine in fileData) |
159 | | - { |
160 | | - sw.WriteLine(fileLine); |
| 137 | + if (merchantOperator.Name == "Voucher") { |
| 138 | + // Generate a voucher file |
| 139 | + var voucherFile = this.GenerateVoucherFile(fileDate, contract.Description.Replace("Contract", ""), numberOfSales); |
| 140 | + fileData = voucherFile.fileLines; |
| 141 | + // Need to make a deposit for this amount - last sale |
| 142 | + Decimal depositAmount = voucherFile.totalValue - voucherFile.lastSale; |
| 143 | + await this.MakeMerchantDeposit(accessToken, merchant, depositAmount, fileDate.AddSeconds(1), cancellationToken); |
| 144 | + } |
| 145 | + else { |
| 146 | + // generate a topup file |
| 147 | + var topupFile = this.GenerateTopupFile(fileDate, numberOfSales); |
| 148 | + fileData = topupFile.fileLines; |
| 149 | + // Need to make a deposit for this amount - last sale |
| 150 | + Decimal depositAmount = topupFile.totalValue - topupFile.lastSale; |
| 151 | + await this.MakeMerchantDeposit(accessToken, merchant, depositAmount, fileDate.AddSeconds(2), cancellationToken); |
| 152 | + } |
| 153 | + |
| 154 | + // Write this file to disk |
| 155 | + Directory.CreateDirectory($"/home/txnproc/txngenerator/{merchantOperator.Name}"); |
| 156 | + using(StreamWriter sw = |
| 157 | + new |
| 158 | + StreamWriter($"/home/txnproc/txngenerator/{merchantOperator.Name}/{contract.Description.Replace("Contract", "")}-{fileDate:yyyy-MM-dd-HH-mm-ss}")) { |
| 159 | + foreach (String fileLine in fileData) { |
| 160 | + sw.WriteLine(fileLine); |
| 161 | + } |
161 | 162 | } |
162 | | - } |
163 | 163 |
|
164 | | - // Upload the generated files for this merchant/operator |
165 | | - // Get the files |
166 | | - var files = Directory.GetFiles($"/home/txnproc/txngenerator/{merchantOperator.Name}"); |
| 164 | + // Upload the generated files for this merchant/operator |
| 165 | + // Get the files |
| 166 | + var files = Directory.GetFiles($"/home/txnproc/txngenerator/{merchantOperator.Name}"); |
167 | 167 |
|
168 | | - var fileDateTime = fileDate.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second); |
| 168 | + var fileDateTime = fileDate.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second); |
169 | 169 |
|
170 | | - foreach (String file in files) |
171 | | - { |
172 | | - var fileProfileId = this.GetFileProfileIdFromOperator(merchantOperator.Name, cancellationToken); |
173 | | - |
174 | | - await this.UploadFile(accessToken, |
175 | | - file, |
176 | | - merchant.EstateId, |
177 | | - merchant.MerchantId, |
178 | | - fileProfileId, |
179 | | - estateUser.SecurityUserId, |
180 | | - fileDateTime, |
181 | | - cancellationToken); |
182 | | - |
183 | | - // Remove file once uploaded |
184 | | - File.Delete(file); |
| 170 | + foreach (String file in files) { |
| 171 | + var fileProfileId = this.GetFileProfileIdFromOperator(merchantOperator.Name, cancellationToken); |
| 172 | + |
| 173 | + await this.UploadFile(accessToken, |
| 174 | + file, |
| 175 | + merchant.EstateId, |
| 176 | + merchant.MerchantId, |
| 177 | + fileProfileId, |
| 178 | + estateUser.SecurityUserId, |
| 179 | + fileDateTime, |
| 180 | + cancellationToken); |
| 181 | + |
| 182 | + // Remove file once uploaded |
| 183 | + File.Delete(file); |
| 184 | + } |
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
|
0 commit comments