Configuration.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.Json.Serialization;
  4. using BO.ProcessServer.Business.Enums;
  5. namespace BO.ProcessServer.Options
  6. {
  7. internal class Configuration
  8. {
  9. [JsonPropertyName("api-base-url")] public Uri ApiBaseUrl { get; set; }
  10. [JsonPropertyName("api-user")] public string ApiUser { get; set; }
  11. [JsonPropertyName("api-pwd")] public string ApiUserPwd { get; set; }
  12. [JsonPropertyName("api-magic")] public string ApiMagic { get; set; }
  13. [JsonPropertyName("api-timeout")] public string ApiTimeoutRaw { get; set; }
  14. public TimeSpan ApiTimeout => TimeSpan.Parse(ApiTimeoutRaw);
  15. public CfgSystem System { get; set; }
  16. public class CfgSystem
  17. {
  18. [JsonPropertyName("mode")] public AppModeEnum Mode { get; set; }
  19. [JsonPropertyName("identification")] public string Identification { get; set; }
  20. [JsonPropertyName("preferred-interface")] public string PreferredInterface { get; set; }
  21. [JsonPropertyName("pool-pull-documents")] public int PoolPullDocuments { get; set; }
  22. [JsonPropertyName("pool-pull-interval")] public string PoolPullIntervalRaw { get; set; }
  23. public TimeSpan PoolPullInterval => TimeSpan.Parse(PoolPullIntervalRaw);
  24. [JsonPropertyName("pool-path-base")] public string PoolPathBase { get; set; }
  25. [JsonPropertyName("pool-path-pending")] public string PoolPathPending { get; set; }
  26. [JsonPropertyName("pool-path-working")] public string PoolPathWorking { get; set; }
  27. [JsonPropertyName("pool-path-done")] public string PoolPathDone { get; set; }
  28. [JsonPropertyName("pool-path-fail")] public string PoolPathFail { get; set; }
  29. [JsonPropertyName("pool-retention")] public CfgPoolRetention Retention { get; set; }
  30. [JsonPropertyName("status-monitoring")] public CfgStatusMonitoring Status { get; set; }
  31. [JsonPropertyName("scenario-path-base")] public string ScenarioPathBase { get; set; }
  32. [JsonPropertyName("scenario-parallels")] public int ScenarioParallelThreads { get; set; }
  33. [JsonPropertyName("scenarios")] public IEnumerable<CfgScenario> Scenarios { get; set; }
  34. [JsonPropertyName("proxy")] public CfgProxies Proxy { get; set; }
  35. }
  36. public class CfgScenarioAcceptFilter
  37. {
  38. [JsonPropertyName("code")] public string Code { get; set; }
  39. [JsonPropertyName("value")] public string Value { get; set; }
  40. }
  41. public class CfgScenario
  42. {
  43. [JsonPropertyName("name")] public string Name { get; set; }
  44. [JsonPropertyName("cmd")] public string ShellCommand { get; set; }
  45. [JsonPropertyName("args")] public string ShellCommandArguments { get; set; }
  46. [JsonPropertyName("accept-filters")] public IEnumerable<CfgScenarioAcceptFilter> AcceptFilters { get; set; }
  47. [JsonPropertyName("timeout-interval")] public string TimeoutIntervalRaw { get; set; }
  48. public TimeSpan TimeoutInterval => TimeSpan.Parse(TimeoutIntervalRaw);
  49. [JsonPropertyName("exitcode-succ")] public int ExitCodeSucc { get; set; }
  50. [JsonPropertyName("exitcode-fail")] public int ExitCodeFail { get; set; }
  51. }
  52. public class CfgStatusMonitoring
  53. {
  54. [JsonPropertyName("enabled")] public bool Enabled { get; set; }
  55. [JsonPropertyName("monitoring-interval")] public string IntervalRaw { get; set; }
  56. public TimeSpan Interval => TimeSpan.Parse(IntervalRaw);
  57. [JsonPropertyName("file")] public string File { get; set; }
  58. }
  59. public class CfgPoolRetention
  60. {
  61. [JsonPropertyName("enabled")] public bool Enabled { get; set; }
  62. [JsonPropertyName("retention-interval")] public string IntervalRaw { get; set; }
  63. public TimeSpan Interval => TimeSpan.Parse(IntervalRaw);
  64. [JsonPropertyName("size")] public long Size { get; set; }
  65. [JsonPropertyName("items")] public int Items { get; set; }
  66. }
  67. public class CfgProxies
  68. {
  69. [JsonPropertyName("process")] public CfgProxiesProcess Process { get; set; }
  70. [JsonPropertyName("app")] public CfgProxiesApp App { get; set; }
  71. }
  72. public class CfgProxiesProcess
  73. {
  74. [JsonPropertyName("succ")] public IEnumerable<bool> Succ { get; set; }
  75. [JsonPropertyName("output")]public IEnumerable<string> Output { get; set; }
  76. }
  77. public class CfgProxiesApp
  78. {
  79. [JsonPropertyName("default-documents-count")] public int DefaultDocumentsCount { get; set; }
  80. [JsonPropertyName("max-documents-count")] public int MaxDocumentsCount { get; set; }
  81. [JsonPropertyName("default-artifacts-count")] public int DefaultArtifactCount { get; set; }
  82. [JsonPropertyName("extension")] public IEnumerable<string> Extension { get; set; }
  83. [JsonPropertyName("nameprefix")] public IEnumerable<string> NameProfix { get; set; }
  84. [JsonPropertyName("presetcreditcost")] public IEnumerable<int> PresetCreditCost { get; set; }
  85. [JsonPropertyName("presetwatermark")] public IEnumerable<bool> PresetWatermark { get; set; }
  86. [JsonPropertyName("presetquality")] public IEnumerable<int> PresetQuality { get; set; }
  87. [JsonPropertyName("presetprocessprofile")] public IEnumerable<string> PresetProcessProfile { get; set; }
  88. [JsonPropertyName("presettest")] public IEnumerable<bool> PresetTest { get; set; }
  89. }
  90. }
  91. }