Configuration.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. }
  35. public class CfgScenarioAcceptFilter
  36. {
  37. [JsonPropertyName("code")] public string Code { get; set; }
  38. [JsonPropertyName("value")] public string Value { get; set; }
  39. }
  40. public class CfgScenario
  41. {
  42. [JsonPropertyName("name")] public string Name { get; set; }
  43. [JsonPropertyName("cmd")] public string ShellCommand { get; set; }
  44. [JsonPropertyName("args")] public string ShellCommandArguments { get; set; }
  45. [JsonPropertyName("accept-filters")] public IEnumerable<CfgScenarioAcceptFilter> AcceptFilters { get; set; }
  46. [JsonPropertyName("timeout-interval")] public string TimeoutIntervalRaw { get; set; }
  47. public TimeSpan TimeoutInterval => TimeSpan.Parse(TimeoutIntervalRaw);
  48. [JsonPropertyName("exitcode-succ")] public int ExitCodeSucc { get; set; }
  49. [JsonPropertyName("exitcode-fail")] public int ExitCodeFail { get; set; }
  50. }
  51. public class CfgStatusMonitoring
  52. {
  53. [JsonPropertyName("enabled")] public bool Enabled { get; set; }
  54. [JsonPropertyName("interval")] public string IntervalRaw { get; set; }
  55. public TimeSpan Interval => TimeSpan.Parse(IntervalRaw);
  56. [JsonPropertyName("file")] public string File { get; set; }
  57. }
  58. public class CfgPoolRetention
  59. {
  60. [JsonPropertyName("enabled")] public bool Enabled { get; set; }
  61. [JsonPropertyName("interval")] public string IntervalRaw { get; set; }
  62. public TimeSpan Interval => TimeSpan.Parse(IntervalRaw);
  63. [JsonPropertyName("size")] public long Size { get; set; }
  64. [JsonPropertyName("items")] public int Items { get; set; }
  65. }
  66. }
  67. }