Config.cs 2.9 KB

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