DatabaseSettings.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Net;
  5. using InABox.Clients;
  6. using InABox.Configuration;
  7. using InABox.Core;
  8. namespace Comal.Classes
  9. {
  10. public enum AutoUpdateChannel
  11. {
  12. Stable,
  13. PreRelease,
  14. Unstable
  15. }
  16. public enum DatabaseType
  17. {
  18. Standalone,
  19. Networked,
  20. Local
  21. }
  22. public class DatabaseSettings : ILocalConfigurationSettings
  23. {
  24. public DatabaseSettings()
  25. {
  26. IsActive = true;
  27. DatabaseType = DatabaseType.Standalone;
  28. // If DatabaseType == Standalone
  29. FileName = Path.Combine(CoreUtils.GetPath(), "prs.dbs");
  30. Provider = DatabaseProvider.SQLite;
  31. // If DatabaseType == Pipe
  32. LocalServerName = "";
  33. // If DatabaseType == Networked
  34. //URL = "http://127.0.0.1";
  35. //Port = 8000;
  36. Protocol = SerializerProtocol.Rest;
  37. URLs = new String[] { "" };
  38. StartPanel = "";
  39. Autologin = false;
  40. LoginType = LoginType.UserID;
  41. Logo = null;
  42. LibraryLocation = "";
  43. GoogleAPIKey = "";
  44. JobPrefix = "";
  45. PurchaseOrderPrefix = "";
  46. SecondaryWindows = new Dictionary<Guid, Tuple<string, string, double, double, double, double>>();
  47. ColorScheme = DefaultColorScheme; // CornflowerBlue
  48. }
  49. public bool RestartRequired(DatabaseSettings original)
  50. {
  51. bool result =
  52. (original.DatabaseType != DatabaseType)
  53. || (!String.Equals(FileName, original.FileName))
  54. || (!String.Equals(LocalServerName, original.LocalServerName))
  55. //|| (!String.Equals(URL, original.URL))
  56. //|| (!int.Equals(Port, original.Port))
  57. || (!String.Equals(String.Join(";", URLs), String.Join(";", original.URLs)));
  58. return result;
  59. }
  60. public bool IsActive { get; set; }
  61. [Obsolete("Use DatabaseType instead")]
  62. public bool IsNetwork {
  63. get => DatabaseType == DatabaseType.Networked;
  64. set
  65. {
  66. if (value)
  67. {
  68. DatabaseType = DatabaseType.Networked;
  69. }
  70. else if(DatabaseType == DatabaseType.Networked)
  71. {
  72. DatabaseType = DatabaseType.Standalone;
  73. }
  74. }
  75. }
  76. [Obsolete("Replaced with HostNames", true)]
  77. public string URL { get; set; }
  78. [Obsolete("Replaced with HostNames", true)]
  79. public int Port { get; set; }
  80. public SerializerProtocol Protocol { get; set; }
  81. public string UserID { get; set; }
  82. public string Password { get; set; }
  83. public DatabaseType DatabaseType { get; set; }
  84. public string FileName { get; set; }
  85. public string LocalServerName { get; set; }
  86. public string[] URLs { get; set; }
  87. public LoginType LoginType { get; set; }
  88. public bool Autologin { get; set; }
  89. public string StartPanel { get; set; }
  90. public DatabaseProvider Provider { get; set; }
  91. public string LibraryLocation { get; set; }
  92. public byte[]? Logo { get; set; }
  93. public const string DefaultColorScheme = "#FF6495ED";
  94. public string ColorScheme { get; set; }
  95. public string GoogleAPIKey { get; set; } // Geocoding API vandenbos.frank@gmail.com: "AIzaSyB9ZnKdEpKsbN9cm3K7rNfqeN5fIe_xlJ0";
  96. public string JobPrefix { get; set; }
  97. public string PurchaseOrderPrefix { get; set; }
  98. // Panel Class, Button Name (? this should be panel name, but grrr), left, top, width, height
  99. public Dictionary<Guid, Tuple<string, string, double, double, double, double>> SecondaryWindows { get; set; }
  100. public Dictionary<int, int> ButtonFavourites { get; set; }
  101. }
  102. public enum AutoUpdateType
  103. {
  104. NotSet,
  105. Url,
  106. File
  107. }
  108. }