complete sending data into SAP

This commit is contained in:
dibakor 2026-07-21 11:45:26 +06:00
parent 4f89ed32a7
commit 2143a3761c
3 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,6 @@
 
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using OnlineSalesAutoCrop.CoreAPI.Models; using OnlineSalesAutoCrop.CoreAPI.Models;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.MobileApp; using OnlineSalesAutoCrop.CoreAPI.Models.Requests.MobileApp;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.BackgroupJobs; using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.BackgroupJobs;
@ -33,6 +34,7 @@ public class BackgroundJobService : IBackgroundJobService
foreach (var item in pendingOrderIds) foreach (var item in pendingOrderIds)
{ {
var orderDetails = await _orderService.GetOrderDetailsForSapByIdAsync(item); var orderDetails = await _orderService.GetOrderDetailsForSapByIdAsync(item);
string jsonResult = JsonConvert.SerializeObject(orderDetails);
string httpResponse = await _httpService.SendSAPOrdersAsync(orderDetails); string httpResponse = await _httpService.SendSAPOrdersAsync(orderDetails);
await _orderService.UpdateSendingSapDetailsAsync(new UpdateSapDetailsRequest await _orderService.UpdateSendingSapDetailsAsync(new UpdateSapDetailsRequest

View File

@ -85,7 +85,6 @@ public class IntegrationHttpService : IIntegrationHttpService
{ {
var body = await response.Content.ReadAsStringAsync(cancellationToken); var body = await response.Content.ReadAsStringAsync(cancellationToken);
_logger.LogError("Save Orders call failed: {StatusCode} — {Body}", response.StatusCode, body); _logger.LogError("Save Orders call failed: {StatusCode} — {Body}", response.StatusCode, body);
response.EnsureSuccessStatusCode();
return body; return body;
} }

View File

@ -372,7 +372,13 @@ namespace OnlineSalesAutoCrop.CoreAPI
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json"); client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
}) })
.AddStandardResilienceHandler(); // retry + timeout + circuit breaker, bundled .AddStandardResilienceHandler(options =>
{
options.AttemptTimeout.Timeout = TimeSpan.FromSeconds(90);
options.CircuitBreaker.SamplingDuration = TimeSpan.FromSeconds(180); // must be >= 2x AttemptTimeout
options.TotalRequestTimeout.Timeout = TimeSpan.FromSeconds(180);
options.Retry.MaxRetryAttempts = 1; // see note below
});
#endregion #endregion
} }