Exemplo n.º 1
0
        public static bool CheckDatabaseInfo()
        {
            Logger.Log("Check Database Info...");
            try
            {
                var path = DB.DatabaseInfoPath;
                if (File.Exists(path))
                {
                    #region Project_JJK 로 연결되어 있으면 삭제하고 다시 만든다.
                    if (File.ReadAllText(path, Encoding.UTF8).Contains("Project_JJK"))
                    {
                        File.Delete(path);
                    }
                    #endregion
                    #region 파일을 찾았다!
                    else
                    {
                        Logger.Log("Check Database Info: found file.");
                        return true;
                    }
                    #endregion
                }

                "Database 정보를 구성합니다.".Dump();
                var dbInfo = new DatabaseInfo();
                dbInfo.Host = ConsoleHelper.ReadInput("Host");
                dbInfo.Port = ConsoleHelper.ReadInput("Port").ToInt(3306);
                dbInfo.UserName = ConsoleHelper.ReadInput("UserName");
                dbInfo.Password = ConsoleHelper.ReadInput("Password");
                dbInfo.Database = ConsoleHelper.ReadInput("Database");
                var json = JsonConvert.SerializeObject(dbInfo);
                File.WriteAllText(path, json, Encoding.UTF8);
                "Database 정보가 저장되었습니다.".Dump();
                return true;
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return false;
            }
        }
Exemplo n.º 2
0
 public static void SetConnectionString()
 {
     if (!File.Exists(DatabaseInfoPath))
         return;
     _dbInfo = JsonConvert.DeserializeObject<DatabaseInfo>(File.ReadAllText(DatabaseInfoPath));
     _connectionString = _dbInfo.ConnectionStringBuilder.ToString();
 }