< Summary

Information
Class: Services.BitrixStockServices.SyncClientEntry
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/BitrixStockServices/BitrixStockSyncPresetModels.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 158
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_Name()100%11100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/BitrixStockServices/BitrixStockSyncPresetModels.cs

#LineLine coverage
 1using System.Text.Json;
 2using System.Text.Json.Serialization;
 3
 4namespace Services.BitrixStockServices;
 5
 6/// <summary>Элемент упорядоченного списка клиентов Ozon в пресете.</summary>
 7public class SyncClientEntry
 8{
 249    public int Id { get; set; }
 2410    public string? Name { get; set; } = string.Empty;
 11}
 12
 13/// <summary>Настройки этапов 2 и 3 для автоматического запуска из пресета.</summary>
 14public class PresetStageSettings
 15{
 16    // Этап 1 — статусы заказов, участвующие в резерве (по умолчанию: Не указан, Заказан реализатору)
 17    public List<int>? ReserveStatusIds { get; set; } = new();
 18
 19    // Этап 2 — накат на Ozon
 20    public bool AutoRunApply { get; set; } = false;
 21    public List<string>? ApplyActions { get; set; } = new() { "Push", "Decrease", "Clear" };
 22    /// <summary>0=Skip, 1=Include, 2=UnarchiveFirst</summary>
 23    public int ApplyArchivedMode { get; set; } = 0;
 24    /// <summary>0=All, 1=AutoOnly, 2=ManualOnly</summary>
 25    public int ApplyUnarchiveFilter { get; set; } = 0;
 26    public int? ApplyMaxLines { get; set; }
 27    public List<int>? ApplyDisabledWarehouseMappingIds { get; set; } = new();
 28
 29    // Этап 3 — очистка лишних складов
 30    public bool AutoRunCleanup { get; set; } = false;
 31    public bool CleanupOnlyPending { get; set; } = true;
 32
 33    // Этап 4 — авто-накат цен (после этапа 3)
 34    public bool AutoRunPricePush { get; set; } = false;
 35
 36    // Этап 5 — очистка «сирот» (товары с остатком на Ozon, но отсутствующие в снэпшоте)
 37    public bool AutoRunOzonOrphanCleanup { get; set; } = false;
 38    /// <summary>Источник каталога этапа 5: OzonProductsDb (default) или WarehouseStockReport (legacy xlsx).</summary>
 39    public string Stage5CatalogSource { get; set; } = "OzonProductsDb";
 40    /// <summary>Этап 5 — отключённые связи складов (Id из WarehouseMapping). Эти склады
 41    /// НЕ запрашиваются у Ozon и не обнуляются. Пусто = все склады отчёта (как раньше).</summary>
 42    public List<int>? OrphanDisabledWarehouseMappingIds { get; set; } = new();
 43
 44    // Оптимизация цен (Модель 2) — хранятся в StageSettingsJson, миграция не нужна
 45    public decimal NoPromoMarkupPercent { get; set; } = 5.0m;
 46    public decimal PromoMarkupPercent   { get; set; } = 10.0m;
 47}
 48
 49public class BitrixStockSyncPreset
 50{
 51    public int Id { get; set; }
 52    public string? Name { get; set; } = string.Empty;
 53    /// <summary>Первый (основной) клиент — для обратной совместимости.</summary>
 54    public int OzonClientId { get; set; }
 55    public string? OzonClientName { get; set; } = string.Empty;
 56    /// <summary>Все клиенты в порядке приоритета (включая основного).</summary>
 57    public List<SyncClientEntry>? OzonClients { get; set; } = new();
 58    public string? ArticleFilter { get; set; }
 59    public List<string>? SelectedStores { get; set; } = new();
 60    public List<int>? DisabledWarehouseMappingIds { get; set; } = new();
 61    public PresetStageSettings StageSettings { get; set; } = new();
 62    public DateTime CreatedAt { get; set; }
 63    public DateTime UpdatedAt { get; set; }
 64    public string? CreatedBy { get; set; }
 65
 66    [JsonIgnore]
 67    public string StageSettingsJson
 68    {
 69        get => JsonSerializer.Serialize(StageSettings);
 70        set => StageSettings = string.IsNullOrWhiteSpace(value)
 71            ? new PresetStageSettings()
 72            : JsonSerializer.Deserialize<PresetStageSettings>(value) ?? new PresetStageSettings();
 73    }
 74
 75    [JsonIgnore]
 76    public string SelectedStoresJson
 77    {
 78        get => JsonSerializer.Serialize(SelectedStores);
 79        set => SelectedStores = string.IsNullOrWhiteSpace(value)
 80            ? new List<string>()
 81            : JsonSerializer.Deserialize<List<string>>(value) ?? new List<string>();
 82    }
 83
 84    [JsonIgnore]
 85    public string DisabledWarehouseMappingIdsJson
 86    {
 87        get => JsonSerializer.Serialize(DisabledWarehouseMappingIds);
 88        set => DisabledWarehouseMappingIds = string.IsNullOrWhiteSpace(value)
 89            ? new List<int>()
 90            : JsonSerializer.Deserialize<List<int>>(value) ?? new List<int>();
 91    }
 92
 93    [JsonIgnore]
 94    public string OzonClientsJson
 95    {
 96        get => JsonSerializer.Serialize(OzonClients);
 97        set
 98        {
 99            try
 100            {
 101                OzonClients = string.IsNullOrWhiteSpace(value)
 102                    ? new List<SyncClientEntry>()
 103                    : JsonSerializer.Deserialize<List<SyncClientEntry>>(value) ?? new List<SyncClientEntry>();
 104            }
 105            catch { OzonClients = new List<SyncClientEntry>(); }
 106            // Синхронизируем основной клиент
 107            if (OzonClients.Any())
 108            {
 109                OzonClientId = OzonClients[0].Id;
 110                OzonClientName = OzonClients[0].Name;
 111            }
 112        }
 113    }
 114
 115    /// <summary>Возвращает все ID клиентов для запуска отчёта.</summary>
 116    public List<int> GetOrderedClientIds() =>
 117        (OzonClients ?? []).Count > 0 ? OzonClients!.Select(c => c.Id).ToList()
 118        : OzonClientId > 0 ? new List<int> { OzonClientId }
 119        : new List<int>();
 120}
 121
 122public class BitrixStockSyncPresetCreateRequest
 123{
 124    public string? Name { get; set; } = string.Empty;
 125    /// <summary>Клиенты в порядке приоритета.</summary>
 126    public List<SyncClientEntry>? OzonClients { get; set; } = new();
 127    /// <summary>Устаревшее — для обратной совместимости.</summary>
 128    public int OzonClientId { get; set; }
 129    public string? OzonClientName { get; set; }
 130    public string? ArticleFilter { get; set; }
 131    public List<string>? SelectedStores { get; set; } = new();
 132    public List<int>? DisabledWarehouseMappingIds { get; set; } = new();
 133    public PresetStageSettings? StageSettings { get; set; }
 134
 135    public List<SyncClientEntry> GetEffectiveClients() =>
 136        (OzonClients ?? []).Count > 0 ? OzonClients!
 137        : OzonClientId > 0 ? new List<SyncClientEntry> { new() { Id = OzonClientId, Name = OzonClientName ?? $"ID {OzonC
 138        : new List<SyncClientEntry>();
 139}
 140
 141public class BitrixStockSyncPresetUpdateRequest
 142{
 143    public string? Name { get; set; } = string.Empty;
 144    /// <summary>Клиенты в порядке приоритета.</summary>
 145    public List<SyncClientEntry>? OzonClients { get; set; } = new();
 146    /// <summary>Устаревшее — для обратной совместимости.</summary>
 147    public int OzonClientId { get; set; }
 148    public string? OzonClientName { get; set; }
 149    public string? ArticleFilter { get; set; }
 150    public List<string>? SelectedStores { get; set; } = new();
 151    public List<int>? DisabledWarehouseMappingIds { get; set; } = new();
 152    public PresetStageSettings? StageSettings { get; set; }
 153
 154    public List<SyncClientEntry> GetEffectiveClients() =>
 155        (OzonClients ?? []).Count > 0 ? OzonClients!
 156        : OzonClientId > 0 ? new List<SyncClientEntry> { new() { Id = OzonClientId, Name = OzonClientName ?? $"ID {OzonC
 157        : new List<SyncClientEntry>();
 158}

Methods/Properties

get_Id()
get_Name()