ConfigServiceModel.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Edge.Core.Configuration
  5. {
  6. public enum ConfigValueType
  7. {
  8. // most likely the json or xml content.
  9. PlainText,
  10. // saved as base 64 string for binary.
  11. File
  12. }
  13. public class ConfigDescription
  14. {
  15. /// <summary>
  16. /// Unique id for a config.
  17. /// </summary>
  18. public Guid ConfigId { get; set; }
  19. /// <summary>
  20. /// the owner id of the config, could be a BusinessUnit Guid or Device's SerialNumber
  21. /// </summary>
  22. public string OwnerId { get; set; }
  23. /// <summary>
  24. /// the type of the config
  25. /// </summary>
  26. public ConfigValueType ValueType { get; set; }
  27. /// <summary>
  28. /// Name of the config
  29. /// </summary>
  30. public string Name { get; set; }
  31. public bool Enabled { get; set; }
  32. /// <summary>
  33. /// user friendly message for help understand the purpose of this config
  34. /// </summary>
  35. public string Description { get; set; }
  36. /// <summary>
  37. /// Created server time
  38. /// </summary>
  39. public DateTime CreatedTime { get; set; }
  40. public IEnumerable<ConfigFileDescription> ConfigFileDescriptions { get; set; }
  41. /// <summary>
  42. /// MD5 hash for concrete config value, used to detect if a config had been changed.
  43. /// </summary>
  44. public string ValueMD5 { get; set; }
  45. public string GroupName { get; set; }
  46. }
  47. public class ConfigFileDescription
  48. {
  49. public Guid Id { get; set; }
  50. public virtual string Name { get; set; }
  51. /// <summary>
  52. /// Original full file name, like abcd.txt
  53. /// </summary>
  54. public virtual string FullName { get; set; }
  55. public virtual long Length { get; set; }
  56. public virtual string ContentHash { get; set; }
  57. public DateTime CreatedServerTime { get; set; }
  58. }
  59. public class Configuration
  60. {
  61. public Guid Id { get; set; }
  62. /// <summary>
  63. /// Gets or sets the owner id who owns this configuration value.
  64. /// could be a Device, or a BusinessUnit, then this value could be a DeviceSerialNumber, or a BU's guid.
  65. /// </summary>
  66. public string OwnerId { get; set; }
  67. public ConfigValueType ValueType { get; set; }
  68. /// <summary>
  69. /// Gets or sets the name of this configuration, unique for each Owner
  70. /// </summary>
  71. public string Name { get; set; }
  72. public virtual Guid? GroupId { get; set; }
  73. public string Description { get; set; }
  74. /// <summary>
  75. /// Gets or sets if enable this configuration.
  76. /// </summary>
  77. public bool Enabled { get; set; }
  78. /// <summary>
  79. /// --!!!!!!---> IF xml content, make sure no space between nodes
  80. /// Gets or sets the concreate configuration values,
  81. /// Use base64 encode string for faciliates the binary content.
  82. /// or json(xml) for other cases.
  83. /// </summary>
  84. public string Value { get; set; }
  85. public virtual List<ConfigurationFile> Files { get; set; }
  86. public DateTime CreatedServerTime { get; set; }
  87. public virtual Guid CreatedByUser { get; set; }
  88. }
  89. public class ConfigurationFile
  90. {
  91. public Guid Id { get; set; }
  92. public virtual Guid ConfigurationId { get; set; }
  93. public virtual Configuration Configuration { get; set; }
  94. public virtual string Name { get; set; }
  95. /// <summary>
  96. /// Original full file name, like abcd.txt
  97. /// </summary>
  98. public virtual string FullName { get; set; }
  99. public virtual long Length { get; set; }
  100. public virtual string ContentHash { get; set; }
  101. public virtual byte[] Value { get; set; }
  102. public DateTime CreatedServerTime { get; set; }
  103. }
  104. }