DatabaseSettings.cs 4.1 KB

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