/// <summary>
 /// Mysql初始化
 /// </summary>
 /// <param name="mySqlSetting"></param>
 public MySqlMethod(MySqlSetting mySqlSetting)
 {
     if (mySqlSetting != null)
     {
         scsb = new MySqlConnectionStringBuilder()
         {
             Database     = mySqlSetting.InitialCatalog + "db",
             Server       = mySqlSetting.DataSource,
             UserID       = mySqlSetting.UserID,
             Password     = mySqlSetting.Password,
             CharacterSet = "utf8"
         };
         Logscsb = new MySqlConnectionStringBuilder()
         {
             Database     = mySqlSetting.InitialCatalog + "Log",
             Server       = mySqlSetting.DataSource,
             UserID       = mySqlSetting.UserID,
             Password     = mySqlSetting.Password,
             CharacterSet = "utf8"
         };
         Webscsb = new MySqlConnectionStringBuilder()
         {
             Database     = mySqlSetting.InitialCatalog + "Web",
             Server       = mySqlSetting.DataSource,
             UserID       = mySqlSetting.UserID,
             Password     = mySqlSetting.Password,
             CharacterSet = "utf8"
         };
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Mysql初始化
 /// </summary>
 /// <param name="mySqlSetting"></param>
 public Ewatch_MySqlMethod(MySqlSetting mySqlSetting)
 {
     if (mySqlSetting != null)
     {
         scsb = new MySqlConnectionStringBuilder()
         {
             Database     = "Ewatchdb",
             Server       = mySqlSetting.DataSource,
             UserID       = mySqlSetting.UserID,
             Password     = mySqlSetting.Password,
             CharacterSet = "utf8"
         };
         Logscsb = new MySqlConnectionStringBuilder()
         {
             Database     = "EwatchLog",
             Server       = mySqlSetting.DataSource,
             UserID       = mySqlSetting.UserID,
             Password     = mySqlSetting.Password,
             CharacterSet = "utf8"
         };
         Webscsb = new MySqlConnectionStringBuilder()
         {
             Database     = "EwatchWeb",
             Server       = mySqlSetting.DataSource,
             UserID       = mySqlSetting.UserID,
             Password     = mySqlSetting.Password,
             CharacterSet = "utf8"
         };
     }
 }
Esempio n. 3
0
        public static MySqlSetting MySqlLoad()
        {
            MySqlSetting setting = null;

            if (!Directory.Exists($"{MyWorkPath}\\stf"))
            {
                Directory.CreateDirectory($"{MyWorkPath}\\stf");
            }
            string SettingPath = $"{MyWorkPath}\\stf\\MySql.json";

            try
            {
                if (File.Exists(SettingPath))
                {
                    string json = File.ReadAllText(SettingPath, Encoding.UTF8);
                    setting = JsonConvert.DeserializeObject <MySqlSetting>(json);
                }
                else
                {
                    MySqlSetting Setting = new MySqlSetting()
                    {
                        DataSource     = "127.0.0.1",
                        InitialCatalog = "Environment",
                        UserID         = "root",
                        Password       = "******"
                    };
                    setting = Setting;
                    string output = JsonConvert.SerializeObject(setting, Formatting.Indented, new JsonSerializerSettings());
                    File.WriteAllText(SettingPath, output);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, " MySQLDB資訊設定載入錯誤");
            }
            return(setting);
        }