예제 #1
0
 /// <summary>
 /// 数据库链接
 /// </summary>
 void LoadConfig()
 {
     if (!File.Exists(ConfigPath))
     {
         SaveConfig();
     }
     lock (DatabaseLock) {
         Config = JsonConvert.DeserializeFile(ConfigPath, Config);
         MySqlHelper?.Dispose();
         StringBuilder connectionString = new StringBuilder();
         connectionString.Append($"datasource={Config.DatabaseIP};");
         connectionString.Append($"database={Config.DatabaseName};");
         connectionString.Append($"user id={Config.DatabaseAccount};");
         connectionString.Append($"password={Config.DatabasePassword};");
         try
         {
             MySqlHelper = new MySqlHelper(connectionString.ToString());
         } catch (Exception exception)
         {
             QMLog.Error(exception.ToString());
         }
     }
 }