Beispiel #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
                }));
            }
        }