예제 #1
0
        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
                }));
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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
                }));
            }
        }
예제 #4
0
 public RatingRepository(DataBaseOptions dbSettings)
 {
     _dbSettings = dbSettings.ThrowIfNull(nameof(dbSettings));
 }
예제 #5
0
 public BasicInfoRepository(DataBaseOptions dbSettings)
 {
     _dbSettings    = dbSettings.ThrowIfNull(nameof(dbSettings));
     _dataProcessor = new DataProcessor(_dbSettings);
 }
예제 #6
0
 public TmdbMovieRepository(DataBaseOptions dbSettings)
 {
     _dbSettings          = dbSettings;
     _basicInfoRepository = new BasicInfoRepository(dbSettings);
     _dataProcessor       = new DataProcessor(_dbSettings);
 }
예제 #7
0
 public DataProcessor(DataBaseOptions dbSettings)
 {
     _dbSettings = dbSettings.ThrowIfNull(nameof(dbSettings));
 }
예제 #8
0
 public OrganizationBaseRepository(DataBaseOptions options)
 {
     _repository = new DataRepositoryBase <OrganizationBase>(options);
 }