public DataManager()
        {
            //_global = global;

            _sqlServer = GlobalVar.configObject.SqlServer;
            _sqlDbName = GlobalVar.configObject.SqlDbName;
            _sqlUser   = GlobalVar.configObject.SqlUser;
            _sqlPwd    = GlobalVar.configObject.SqlPwd;

            var mapEntity = Assembly.GetAssembly(typeof(RawData))
                            .GetTypes()
                            .Where(m => m.GetInterfaces().FirstOrDefault(x => x == typeof(IEntity)) != null && m.IsClass)
                            .Select(m =>
            {
                var makeme = typeof(FactoryMap <>).MakeGenericType(m);
                return(makeme);
            }).ToList();

            UnitOfWorkFactory.RegisterDatabase(_sqlDbName, new NhibernateConfig
            {
                Maps   = mapEntity,
                Config =
                    DatabaseConfigFactory.GetDataConfig(false, _sqlServer, 0, _sqlDbName,
                                                        _sqlUser, _sqlPwd, false, null),
                IsUpdateTable = true
            });


            // chạy task đồng bộ dữ liệu account lên memory
            //_taskSyncAccount = new Task(SyncAccount, _cancelSyncAccount.Token);
            //_taskSyncAccount.Start();
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            string databaseType = comboDatabaseType.Text;
            DatabaseConfigFactory   configFactory   = new DatabaseConfigFactory();
            DatabaseConfig          config          = configFactory.Create(databaseType);
            SecurityDatabaseService databaseService = new SecurityDatabaseService();

            if (databaseType == "mssql")
            {
                MSSqlDatabaseConfig tempConfig = (MSSqlDatabaseConfig)config;
                tempConfig.DataSource     = txtMSSqlIP.Text.Trim();
                tempConfig.InitialCatelog = txtMSSqlDatabaseName.Text.Trim();
                tempConfig.UserID         = txtMSSqlUserID.Text.Trim();
                tempConfig.Password       = txtMSSqlPwd.Text.Trim();
                tempConfig.DatabasePath   = txtMSSqlDatabasePath.Text.Trim();
                try
                {
                    databaseService.CreateDatabase(tempConfig);
                }
                catch (Exception ex)
                {
                    customError.ShowError(ex.Message);
                }
            }
            else
            {
                SqliteDatabaseConfig tempConfig = (SqliteDatabaseConfig)config;
                tempConfig.DataSource = txtSqliteDatabaseName.Text.Trim();
                try
                {
                    databaseService.CreateDatabase(tempConfig);
                }
                catch (Exception ex)
                {
                    customError.ShowError(ex.Message);
                }
            }
        }