-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathQueueDEConfiguration.cs
More file actions
64 lines (49 loc) · 2.52 KB
/
QueueDEConfiguration.cs
File metadata and controls
64 lines (49 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Linq;
using fiskaltrust.Middleware.Contracts.Models;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace fiskaltrust.Middleware.Localization.QueueDE
{
public class QueueDEConfiguration
{
public bool FlagOptionalSignatures { get; set; } = true;
[JsonProperty("scu-timeout-ms")]
public long? ScuTimeoutMs { get; set; }
[JsonProperty("scu-max-retries")]
public int? ScuMaxRetries { get; set; }
public bool StoreTemporaryExportFiles { get; set; } = false;
public bool DisableDsfinvkExportReferences { get; set; } = false;
private bool EnableTarFileExport { get; set; } = true;
public TarFileExportMode TarFileExportMode { get; set; } = TarFileExportMode.All;
public bool ExcludeDsfinvkOrders { get; set; } = false;
public bool CloseOpenTSETransactionsOnDailyClosing { get; set; } = false;
public bool RegisterClient { get; set; } = false;
public static QueueDEConfiguration FromMiddlewareConfiguration(ILogger<QueueDEConfiguration> logger, MiddlewareConfiguration middlewareConfiguration)
{
var configuration = JsonConvert.DeserializeObject<QueueDEConfiguration>(JsonConvert.SerializeObject(middlewareConfiguration.Configuration));
var enableTarFileExportPair = middlewareConfiguration.Configuration.FirstOrDefault(k => k.Key.ToLower() == nameof(EnableTarFileExport).ToLower());
bool? enableTarFileExport = string.IsNullOrEmpty(enableTarFileExportPair.Value?.ToString()) ? null : bool.Parse(enableTarFileExportPair.Value.ToString());
var tarFileExportModePair = middlewareConfiguration.Configuration.FirstOrDefault(k => k.Key.ToLower() == nameof(TarFileExportMode).ToLower());
if (enableTarFileExport.HasValue && !string.IsNullOrEmpty(tarFileExportModePair.Value?.ToString()))
{
logger.LogWarning($"Both {nameof(EnableTarFileExport)} and {nameof(TarFileExportMode)} are set. {nameof(TarFileExportMode)} = {configuration.TarFileExportMode} is choosen.");
}
else if (enableTarFileExport.HasValue)
{
configuration.TarFileExportMode = enableTarFileExport.Value switch
{
true => TarFileExportMode.All,
false => TarFileExportMode.None,
};
}
return configuration;
}
}
public enum TarFileExportMode
{
None,
All,
Erased
}
}