Config.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System.IO;
  2. using MySql.Data.MySqlClient;
  3. using StackExchange.Redis;
  4. public class Config
  5. {
  6. public const bool GameOnline = true;
  7. public ConfigurationOptions redis;
  8. public MySqlConnectionStringBuilder mysql;
  9. public string mongo => GameOnline ? "mongodb://localhost:27017" : "mongodb://localhost:27017";
  10. /// <summary>
  11. /// 结束倒计时
  12. /// </summary>
  13. public int CountDownTimes => GameOnline ? 10 * 60 : 2 * 60;
  14. /// <summary>
  15. /// 结算地址
  16. /// </summary>
  17. public string SettleUrl
  18. {
  19. get
  20. {
  21. var host = "192.168.10.87";
  22. if (GameOnline)
  23. {
  24. host = "115.159.121.129";
  25. }
  26. return $"http://{host}/ylsj2019/Gameserver/Amfphp/service_call/InquireApi/WorldBosSettle.php";
  27. }
  28. }
  29. public string OutDir
  30. {
  31. get
  32. {
  33. var dir = "/data/stat_out/";
  34. VerifyFolder(dir);
  35. return dir;
  36. }
  37. }
  38. /// <summary>
  39. /// 确保路径存在
  40. /// </summary>
  41. /// <param name="dir"></param>
  42. internal static void VerifyFolder(string dir)
  43. {
  44. if (!Directory.Exists(dir))
  45. {
  46. Directory.CreateDirectory(dir);
  47. }
  48. }
  49. private Config() { }
  50. static private Config _ins;
  51. public static Config Ins
  52. {
  53. get
  54. {
  55. if (null == _ins)
  56. {
  57. if (GameOnline)
  58. {
  59. var host = "127.0.0.1";
  60. var port = 6379;
  61. var pwd = "wanggang1985";
  62. _ins = new Config()
  63. {
  64. redis = ConfigurationOptions.Parse($"{host}:{port},password={pwd},connectTimeout=2000"),
  65. mysql = new MySqlConnectionStringBuilder
  66. {
  67. Server = "127.0.0.1",
  68. UserID = "gwang",
  69. Password = "wanggang1985",
  70. Port = 3306,
  71. Database = "ylsj2019_pay",
  72. CharacterSet = "utf8"
  73. }
  74. };
  75. }
  76. else
  77. {
  78. var host = "192.168.10.16";
  79. var port = 6004;
  80. var pwd = "wanggang1985";
  81. _ins = new Config()
  82. {
  83. redis = ConfigurationOptions.Parse($"{host}:{port},password={pwd},connectTimeout=2000"),
  84. mysql = new MySqlConnectionStringBuilder
  85. {
  86. Server = "192.168.10.16",
  87. UserID = "gwang",
  88. Password = "wanggang1985",
  89. Port = 3306,
  90. Database = "ylsj2019_pay",
  91. CharacterSet = "utf8"
  92. }
  93. };
  94. }
  95. }
  96. return _ins;
  97. }
  98. }
  99. }