|
|
@@ -101,15 +101,23 @@ namespace BulkPrintingAPI.Controllers
|
|
101
|
101
|
|
|
102
|
102
|
if (!batch.ReadyForDownload)
|
|
103
|
103
|
{
|
|
104
|
|
- try
|
|
|
104
|
+ if (batch.DeliveredQuantity == 0)
|
|
105
|
105
|
{
|
|
106
|
|
- await Utils.DownloadVouchersAsync(_sftpOptions, _context, _logger, batch);
|
|
|
106
|
+ batch.ReadyForDownload = true;
|
|
|
107
|
+ await _context.SaveChangesAsync();
|
|
107
|
108
|
}
|
|
108
|
|
- catch (Exception e)
|
|
|
109
|
+ else
|
|
109
|
110
|
{
|
|
110
|
|
- _logger.LogError(string.Format(
|
|
111
|
|
- "Failed to download vouchers for {0} batchId={1}: {2}",
|
|
112
|
|
- credentials.ToString(), batch.Id, e.Message));
|
|
|
111
|
+ try
|
|
|
112
|
+ {
|
|
|
113
|
+ await Utils.DownloadVouchersAsync(_sftpOptions, _context, _logger, batch);
|
|
|
114
|
+ }
|
|
|
115
|
+ catch (Exception e)
|
|
|
116
|
+ {
|
|
|
117
|
+ _logger.LogError(string.Format(
|
|
|
118
|
+ "Failed to download vouchers for {0} batchId={1}: {2}",
|
|
|
119
|
+ credentials.ToString(), batch.Id, e.Message));
|
|
|
120
|
+ }
|
|
113
|
121
|
}
|
|
114
|
122
|
}
|
|
115
|
123
|
|
|
|
@@ -154,15 +162,18 @@ namespace BulkPrintingAPI.Controllers
|
|
154
|
162
|
|
|
155
|
163
|
_logger.LogDebug("Saved batchId={0} for {1}", orderResponse.Batch.Id, credentials.ToString());
|
|
156
|
164
|
|
|
157
|
|
- try
|
|
|
165
|
+ if (!orderResponse.Batch.ReadyForDownload)
|
|
158
|
166
|
{
|
|
159
|
|
- await Utils.DownloadVouchersAsync(_sftpOptions, _context, _logger, orderResponse.Batch);
|
|
160
|
|
- }
|
|
161
|
|
- catch (Exception e)
|
|
162
|
|
- {
|
|
163
|
|
- _logger.LogError(string.Format(
|
|
164
|
|
- "Failed to download vouchers for {0} batchId={1}: {2}",
|
|
165
|
|
- credentials.ToString(), orderResponse.Batch.Id, e.Message));
|
|
|
167
|
+ try
|
|
|
168
|
+ {
|
|
|
169
|
+ await Utils.DownloadVouchersAsync(_sftpOptions, _context, _logger, orderResponse.Batch);
|
|
|
170
|
+ }
|
|
|
171
|
+ catch (Exception e)
|
|
|
172
|
+ {
|
|
|
173
|
+ _logger.LogError(string.Format(
|
|
|
174
|
+ "Failed to download vouchers for {0} batchId={1}: {2}",
|
|
|
175
|
+ credentials.ToString(), orderResponse.Batch.Id, e.Message));
|
|
|
176
|
+ }
|
|
166
|
177
|
}
|
|
167
|
178
|
|
|
168
|
179
|
return Ok(orderResponse);
|