예제 #1
0
 public SchemaBrowserRepository(IAuthorisation authorisation, IMetadataProvider metadataProvider)
     : base(Constants.DataServiceName, authorisation, metadataProvider)
 {
     _utils        = new SchemaBrowserUtils();
     _nextIds      = new ConcurrentDictionary <Type, long>();
     _repositories = new ConcurrentDictionary <Type, ConcurrentDictionary <long, IHaveAssignableId <long> > >();
 }
예제 #2
0
        public ApiModule(IAuthentication authentication, IGlobalisationProvider globalisationProvider, ISchemaBrowserRepository repository)
            : base("api/schemabrowser/ext", globalisationProvider)
        {
            _authentication = authentication;
            _repository     = repository;
            _utils          = new SchemaBrowserUtils();

            Get[@"/TestConnection/{databaseType}"] = args =>
            {
                string       databaseType     = args.databaseType;
                DatabaseType dbType           = databaseType.FromDatabaseValue <DatabaseType>();
                string       connectionString = Request.Query["cs"]; //can't get this to work via normal parameter as it's encoded
                string       message          = string.Empty;

                _utils.TestConnection(dbType, connectionString, out message);

                return(Response.AsJson(message));
            };
        }
예제 #3
0
        public DbConnectionValidator(ISchemaBrowserRepository repository)
        {
            _repository = repository;
            _utils      = new SchemaBrowserUtils();

            RuleFor(x => x.Id)
            .GreaterThanOrEqualTo(0L);

            RuleFor(x => x.Name)
            .NotEmpty()
            .Length(1, 64)
            .Must(BeUnique)
            .WithMessage("The 'Name' must be unique");

            RuleFor(x => x.DataSource)
            .NotEmpty()
            .Length(1, 1000);

            RuleFor(x => x.InitialCatalog)
            .Length(0, 64)
            .Must(OnlyBeSuppliedForSQLServer)
            .WithMessage("An 'Initial Catalog' is required for SQL Server connections");

            RuleFor(x => x.Username)
            .Length(0, 64)
            .Must(OnlyBeSuppliedForNonIntegratedSecurity)
            .WithMessage("A 'User Name' is required");

            RuleFor(x => x.Password)
            .Length(0, 64)
            .Must(OnlyBeSuppliedForNonIntegratedSecurity)
            .WithMessage("A 'Password' is required");

            RuleFor(x => x.ConnectionString)
            .NotEmpty()
            .Length(1, 2000);

            //Custom(p => MustHaveAValidConnectionString(p));
        }
예제 #4
0
 public DbConnectionRecordType(ISchemaBrowserRepository repository)
     : base()
 {
     _repository = repository;
     _utils      = new SchemaBrowserUtils();
 }