/// <summary> /// 初始化SQL /// </summary> private static void InitSQL() { ////////////////////////////////////////////////////////////////////////// // 开始在编译后的程序集合内获取密码 Type l_Type = ScriptCompiler.FindTypeByFullName("Demo_R.O.S.E.Scripts.Globals.GlobalConfig"); if (l_Type != null) { FieldInfo l_FieldInfo = l_Type.GetField("SQLPassword"); if (l_FieldInfo != null) { string l_strSQLPassword = l_FieldInfo.GetValue(string.Empty) as string; if (l_strSQLPassword != null && l_strSQLPassword != string.Empty) { s_ConfigInfo.SQLPassword = l_strSQLPassword; } } l_FieldInfo = l_Type.GetField("LoginServerPassword"); if (l_FieldInfo != null) { string l_strLoginPassword = l_FieldInfo.GetValue(string.Empty) as string; if (l_strLoginPassword != null && l_strLoginPassword != string.Empty) { s_ConfigInfo.LoginPassword = l_strLoginPassword; } } l_FieldInfo = l_Type.GetField("CharServerPassword"); if (l_FieldInfo != null) { string l_strCharPassword = l_FieldInfo.GetValue(string.Empty) as string; if (l_strCharPassword != null && l_strCharPassword != string.Empty) { s_ConfigInfo.CharPassword = l_strCharPassword; } } l_FieldInfo = l_Type.GetField("WorldServerPassword"); if (l_FieldInfo != null) { string l_strWorldPassword = l_FieldInfo.GetValue(string.Empty) as string; if (l_strWorldPassword != null && l_strWorldPassword != string.Empty) { s_ConfigInfo.WorldPassword = l_strWorldPassword; } } } ////////////////////////////////////////////////////////////////////////// // 设置SQL的连接信息 if (s_ConfigInfo.SQLConnection == string.Empty || s_ConfigInfo.SQLUser == string.Empty || s_ConfigInfo.SQLHost == string.Empty || s_ConfigInfo.SQLDatabase == string.Empty) { s_ConfigInfo.SQLConnectionUrl = BaseDatabase.ConnectionURL; } else { BaseDatabase.ConnectionURL = s_ConfigInfo.SQLConnectionUrl = s_ConfigInfo.SQLConnection + "://" + s_ConfigInfo.SQLUser + ":" + s_ConfigInfo.SQLPassword + "@" + s_ConfigInfo.SQLHost //+ ( s_ConfigInfo.m_strSQLPort == 0 ? string.Empty : ":" + s_ConfigInfo.m_strSQLPort ) // 数据库引擎暂时不支持 + "/" + s_ConfigInfo.SQLDatabase; } ////////////////////////////////////////////////////////////////////////// // 开始连接数据库 if (s_SQLRecreate == false) { BaseDatabase.BuildDefault(); } else { // 重建数据库 BaseDatabase.BuildRecreate(); } }