public IActionResult ConnectionTest([FromBody] DbConfigurationModel model) { string connectionString = DataBaseHelper.GetDbConfiguration(model.DataServerName, model.DataAccountName, model.DataPassword, model.DatabaseName, model.CommandTimeOut); bool isConnectionTest = DataBaseHelper.ConnectionTest(connectionString); if (isConnectionTest) { var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", true, reloadOnChange: true); var config = builder.Build(); DataBaseOptions options = new DataBaseOptions() { ConnectionString = connectionString }; IOrganizationBaseRepository organizationBaseRepository = new OrganizationBaseRepository(options); IOrganizationBaseService _organizationBaseService = new Organization.OrganizationBaseService(organizationBaseRepository); List <OrganizationBase> orglist = _organizationBaseService.Query(n => n.Where(x => x.State == 1)); return(new JsonResult(new JsonResultObject() { IsSuccess = true, Content = orglist.SerializeToJson() })); } else { return(new JsonResult(new JsonResultObject() { IsSuccess = false })); } }
public DbHelperScope(DataBaseOptions settings) { settings.ThrowIfNull(nameof(settings)); settings.ConnectionString.ThrowIfNull(nameof(settings.ConnectionString)); try { _connection = new SqlConnection(settings.ConnectionString); _connection.Open(); _transaction = _connection.BeginTransaction(); } catch (Exception ex) { Dispose(); _logger.Error(ex, "Exception occurred during connection to database."); throw; } }
public IActionResult Save([FromBody] InitializationModel model) { try { var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", true, reloadOnChange: true); var config = builder.Build(); config["DataBase:ConnectionString"] = DataBaseHelper.GetDbConfiguration(model.DataServerName, model.DataAccountName, model.DataPassword, model.DatabaseName, model.CommandTimeOut); config["Initialization:IsInitialization"] = "true"; WriteJson("DataBase:ConnectionString", config["DataBase:ConnectionString"], config["Initialization:IsInitialization"]); if (model.OrganizationBases != null) { DataBaseOptions options = new DataBaseOptions() { ConnectionString = config["DataBase:ConnectionString"] }; IOrganizationBaseRepository organizationBaseRepository = new OrganizationBaseRepository(options); IOrganizationBaseService _organizationBaseService = new Organization.OrganizationBaseService(organizationBaseRepository); model.OrganizationBases.ForEach(x => { _organizationBaseService.Update(x); }); } return(new JsonResult(new JsonResultObject() { IsSuccess = true })); } catch (Exception ex) { return(new JsonResult(new JsonResultObject() { IsSuccess = false, Content = ex.Message })); } }
public RatingRepository(DataBaseOptions dbSettings) { _dbSettings = dbSettings.ThrowIfNull(nameof(dbSettings)); }
public BasicInfoRepository(DataBaseOptions dbSettings) { _dbSettings = dbSettings.ThrowIfNull(nameof(dbSettings)); _dataProcessor = new DataProcessor(_dbSettings); }
public TmdbMovieRepository(DataBaseOptions dbSettings) { _dbSettings = dbSettings; _basicInfoRepository = new BasicInfoRepository(dbSettings); _dataProcessor = new DataProcessor(_dbSettings); }
public DataProcessor(DataBaseOptions dbSettings) { _dbSettings = dbSettings.ThrowIfNull(nameof(dbSettings)); }
public OrganizationBaseRepository(DataBaseOptions options) { _repository = new DataRepositoryBase <OrganizationBase>(options); }