示例#1
0
        /// <summary>
        /// Load Configuration DB Server
        /// </summary>
        private static void _GetConfigDB(bool isAuth = false, bool readOnly = false, string configPath = "config", string ext = "db")
        {
            string  path = configPath + "." + ext;
            MParser config;

            if (File.Exists(path))
            {
                config = new MParser(path);
                int idx = isAuth ? 1 : 0;
                Server   = config.Read("Server", Sections[idx]);
                DBName   = config.Read("DBName", Sections[idx]);
                AuthType = readOnly ? isAuth : Convert.ToBoolean(config.Read("AuthType", "Authentication"));
                if (isAuth)
                {
                    UserId   = config.Read("UserId", Sections[idx]);
                    Password = config.Read("Password", Sections[idx]);
                }
            }
            return;
        }
示例#2
0
        /// <summary>
        /// Setting Configuration DB Server
        /// </summary>
        public static bool SetConfigDB(bool isAuth = false, string configPath = "config", string ext = "db")
        {
            try
            {
                MParser config = new MParser(configPath + "." + ext);
                int     idx    = isAuth ? 1 : 0;
                config.Write("Server", Server, Sections[idx]);
                config.Write("DBName", DBName, Sections[idx]);
                if (isAuth)
                {
                    config.Write("UserId", UserId, Sections[idx]);
                    config.Write("Password", Password, Sections[idx]);
                }
                config.Write("AuthType", isAuth + "", "Authentication");

                return(true);
            }
            catch (Exception ex)
            {
                Log.Write(ex.Message, "Database.setConfigDB");
            }

            return(false);
        }