< Summary

Information
Class: Services.DataServices.OrderHistoryOneCPostingRecorder
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/DataServices/OrderHistoryOneCPostingRecorder.cs
Line coverage
100%
Covered lines: 45
Uncovered lines: 0
Coverable lines: 45
Total lines: 101
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TryRecordAsync()100%1010100%
TryRecordMovementAsync(...)100%11100%
TryRecordReceiptAsync(...)100%11100%
TryRecordExpenseAsync(...)100%11100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/DataServices/OrderHistoryOneCPostingRecorder.cs

#LineLine coverage
 1using Microsoft.Extensions.DependencyInjection;
 2using OzonDomains.Models;
 3using Services.ApiServices._1CApi.Models;
 4using Services.OneCServices;
 5
 6namespace Services.DataServices;
 7
 8/// <summary>
 9/// Безопасная запись проведений 1С в историю заказа (не ломает транзакцию при ошибке БД).
 10/// </summary>
 11public static class OrderHistoryOneCPostingRecorder
 12{
 13    public static async Task TryRecordAsync(
 14        IServiceProvider serviceProvider,
 15        IReadOnlyList<Order> orders,
 16        IReadOnlyList<OneCResponse> responses,
 17        string operationKind,
 18        string changedBy,
 19        int? transactionId,
 20        DateTime historyWindowStart,
 21        string? warehouseSender = null,
 22        string? warehouseRecipient = null)
 23    {
 1124        if (orders == null || orders.Count == 0 || responses == null || responses.Count == 0)
 425            return;
 26
 27        try
 28        {
 729            using var scope = serviceProvider.CreateScope();
 630            var service = scope.ServiceProvider.GetService<IOrderHistoryOneCPostingService>();
 631            if (service == null)
 132                return;
 33
 534            await service.RecordPostingsAsync(
 535                orders,
 536                responses,
 537                operationKind,
 538                changedBy,
 539                transactionId,
 540                historyWindowStart,
 541                warehouseSender,
 542                warehouseRecipient);
 443        }
 244        catch
 45        {
 46            // Не ломаем проведение транзакции из-за журнала 1С.
 247        }
 1148    }
 49
 50    public static Task TryRecordMovementAsync(
 51        IServiceProvider serviceProvider,
 52        IReadOnlyList<Order> orders,
 53        IReadOnlyList<OneCResponse> responses,
 54        string changedBy,
 55        int? transactionId,
 56        DateTime historyWindowStart,
 57        string? warehouseSender = null,
 58        string? warehouseRecipient = null)
 159        => TryRecordAsync(
 160            serviceProvider,
 161            orders,
 162            responses,
 163            OneCPostingOperationKinds.Movement,
 164            changedBy,
 165            transactionId,
 166            historyWindowStart,
 167            warehouseSender,
 168            warehouseRecipient);
 69
 70    public static Task TryRecordReceiptAsync(
 71        IServiceProvider serviceProvider,
 72        IReadOnlyList<Order> orders,
 73        IReadOnlyList<OneCResponse> responses,
 74        string changedBy,
 75        int? transactionId,
 76        DateTime historyWindowStart)
 177        => TryRecordAsync(
 178            serviceProvider,
 179            orders,
 180            responses,
 181            OneCPostingOperationKinds.Receipt,
 182            changedBy,
 183            transactionId,
 184            historyWindowStart);
 85
 86    public static Task TryRecordExpenseAsync(
 87        IServiceProvider serviceProvider,
 88        IReadOnlyList<Order> orders,
 89        IReadOnlyList<OneCResponse> responses,
 90        string changedBy,
 91        int? transactionId,
 92        DateTime historyWindowStart)
 193        => TryRecordAsync(
 194            serviceProvider,
 195            orders,
 196            responses,
 197            OneCPostingOperationKinds.Expense,
 198            changedBy,
 199            transactionId,
 1100            historyWindowStart);
 101}