Ejemplo n.º 1
0
        public Database(Configuration configuration)
        {
            this.connectionString = configuration.ConnectionString;
            if (this.connectionString == null)
            {
                throw new Exception("Configuration.ConnectionString is missing");
            }

            if (!this.connectionString.ToLowerInvariant().Contains(FullUriKey))
            {
                throw new Exception("Configuration.ConnectionString has no FullUri");
            }

            this.isInMemory = this.connectionString.ToLowerInvariant().Contains(InMemoryKey);

            if (this.isInMemory && !this.connectionString.ToLowerInvariant().Contains(SharedCacheKey))
            {
                throw new Exception("Configuration.ConnectionString is in memory and FullUri has no \"?cache=shared\" parameter");
            }

            if (this.isInMemory)
            {
                this.id = Guid.NewGuid().ToString("N").ToLowerInvariant();
            }
            else
            {
                var connectionStringBuilder = new SQLiteConnectionStringBuilder(this.connectionString);
                var dataSource = connectionStringBuilder.FullUri;
                if (dataSource.Contains(UriQueySeparator))
                {
                    dataSource = dataSource.Substring(0, dataSource.IndexOf(UriQueySeparator, StringComparison.Ordinal));
                }

                this.id = Path.GetFileName(dataSource);
            }

            this.objectFactory = configuration.ObjectFactory;
            if (this.objectFactory == null)
            {
                throw new Exception("Configuration.ObjectFactory is missing");
            }

            this.roleCache      = configuration.RoleCache ?? new RoleCache();
            this.classCache     = configuration.ClassCache ?? new ClassCache();
            this.commandTimeout = configuration.CommandTimeout ?? 30;
            this.isolationLevel = configuration.IsolationLevel ?? IsolationLevel.Serializable;
            this.autoIncrement  = configuration.AutoIncrement ?? false;

            this.mapping = new Mapping(this);

            if (this.isInMemory)
            {
                this.inMemoryConnection = new SQLiteConnection(this.ConnectionString);
                this.inMemoryConnection.Open();
            }

            this.idSequence = IdSequence.GetOrCreate(this);
        }
Ejemplo n.º 2
0
 public DeleteRoleCommandHandler(
     CofoundryDbContext dbContext,
     UserCommandPermissionsHelper userCommandPermissionsHelper,
     IRoleCache roleCache
     )
 {
     _dbContext = dbContext;
     _roleCache = roleCache;
 }
 public GetRoleDetailsByRoleCodeQueryHandler(
     CofoundryDbContext dbContext,
     IInternalRoleRepository internalRoleRepository,
     IRoleCache roleCache
     )
 {
     _dbContext = dbContext;
     _internalRoleRepository = internalRoleRepository;
     _roleCache = roleCache;
 }
Ejemplo n.º 4
0
 public InternalRoleRepository(
     IRoleCache roleCache,
     CofoundryDbContext dbContext,
     IRoleDetailsMapper roleDetailsMapper
     )
 {
     _roleCache         = roleCache;
     _dbContext         = dbContext;
     _roleDetailsMapper = roleDetailsMapper;
 }
Ejemplo n.º 5
0
 public InternalRoleRepository(
     IRoleCache roleCache,
     CofoundryDbContext dbContext,
     RoleMappingHelper roleMappingHelper
     )
 {
     _roleCache         = roleCache;
     _dbContext         = dbContext;
     _roleMappingHelper = roleMappingHelper;
 }
Ejemplo n.º 6
0
 public DeleteRoleCommandHandler(
     CofoundryDbContext dbContext,
     UserCommandPermissionsHelper userCommandPermissionsHelper,
     IRoleCache roleCache,
     ITransactionScopeManager transactionScopeFactory
     )
 {
     _dbContext = dbContext;
     _roleCache = roleCache;
     _transactionScopeFactory = transactionScopeFactory;
 }
Ejemplo n.º 7
0
 public PosService(OnlineSalesContext context,
                   IHttpContextAccessor httpContext,
                   IRoleCache roleCache,
                   ILogger <PosService> logger,
                   ListQuery <Pos, PosDTO> q)
     : base(httpContext, context)
 {
     _logger    = logger;
     _query     = q;
     _roleCache = roleCache;
 }
Ejemplo n.º 8
0
 public UserService(OnlineSalesContext context,
                    IHttpContextAccessor httpContext,
                    IOptions <MailerOptions> options,
                    IRoleCache roleCache,
                    ListQuery <AppUser, AppUserDTO> q,
                    ILogger <UserService> logger)
     : base(httpContext, context)
 {
     _query     = q;
     _options   = options.Value;
     _roleCache = roleCache;
     _logger    = logger;
 }
Ejemplo n.º 9
0
        public Database(Configuration configuration)
        {
            this.connectionString = configuration.ConnectionString;
            if (this.connectionString == null)
            {
                throw new Exception("Configuration.ConnectionString is missing");
            }

            var connectionStringBuilder = new SqlConnectionStringBuilder(this.connectionString);
            var applicationName         = connectionStringBuilder.ApplicationName.Trim();

            if (!string.IsNullOrWhiteSpace(applicationName))
            {
                this.Id = applicationName;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(connectionStringBuilder.InitialCatalog))
                {
                    this.Id = connectionStringBuilder.InitialCatalog.ToLowerInvariant();
                }
                else
                {
                    using (this.connection = new SqlConnection(this.connectionString))
                    {
                        this.connection.Open();
                        this.Id = this.connection.Database.ToLowerInvariant();
                    }
                }
            }

            this.objectFactory = configuration.ObjectFactory;
            if (this.objectFactory == null)
            {
                throw new Exception("Configuration.ObjectFactory is missing");
            }

            if (!this.objectFactory.MetaPopulation.IsValid)
            {
                throw new ArgumentException("Domain is invalid");
            }

            this.Mapping        = new Mapping(this);
            this.roleCache      = configuration.RoleCache ?? new RoleCache();
            this.classCache     = configuration.ClassCache ?? new ClassCache();
            this.CommandTimeout = configuration.CommandTimeout ?? 30;
            this.IsolationLevel = configuration.IsolationLevel ?? IsolationLevel.Snapshot;
            this.SchemaName     = configuration.SchemaName ?? "allors";
            this.useViews       = configuration.UseViews ?? true;
        }
Ejemplo n.º 10
0
 public UpdateRoleCommandHandler(
     CofoundryDbContext dbContext,
     IQueryExecutor queryExecutor,
     IPermissionRepository permissionRepository,
     IRoleCache roleCache,
     ICommandExecutor commandExecutor
     )
 {
     _dbContext            = dbContext;
     _queryExecutor        = queryExecutor;
     _permissionRepository = permissionRepository;
     _roleCache            = roleCache;
     _commandExecutor      = commandExecutor;
 }
Ejemplo n.º 11
0
 public UpdateRoleCommandHandler(
     CofoundryDbContext dbContext,
     IQueryExecutor queryExecutor,
     IPermissionRepository permissionRepository,
     IRoleCache roleCache,
     ICommandExecutor commandExecutor,
     ITransactionScopeManager transactionScopeFactory
     )
 {
     _dbContext               = dbContext;
     _queryExecutor           = queryExecutor;
     _permissionRepository    = permissionRepository;
     _roleCache               = roleCache;
     _commandExecutor         = commandExecutor;
     _transactionScopeFactory = transactionScopeFactory;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LoginDialogViewModel"/> class.
        /// </summary>
        /// <param name="unitOfWork">Unit of work.</param>
        /// <param name="resourceHandler">Resource handler.</param>
        /// <param name="messageBoxProvider">Message box provider.</param>
        /// <param name="roleCache">Role cache.</param>
        /// <param name="mode">Mode (Add/Edit).</param>
        /// <param name="model">Login model.</param>
        public LoginDialogViewModel(
            IUnitOfWork unitOfWork,
            IResourceHandler resourceHandler,
            IMessageBoxProvider messageBoxProvider,
            IRoleCache roleCache,
            WorkModeType mode,
            LoginModel model = null)
            : base(mode)
        {
            this.unitOfWork         = unitOfWork;
            this.resourceHandler    = resourceHandler;
            this.messageBoxProvider = messageBoxProvider;
            this.roleCache          = roleCache;

            Task.Factory.StartNewWithDefaultCulture(() => this.Load(model));
        }
Ejemplo n.º 13
0
 public CaseService(OnlineSalesContext context,
                    IHttpContextAccessor httpContext,
                    IRoleCache roleCache,
                    ILogger <CaseService> logger,
                    ListQuery <OnlineOrder, CaseDTO> q,
                    IIndusService indus,
                    IOptions <CaseOptions> options,
                    IMailerService mail)
     : base(httpContext, context)
 {
     _logger    = logger;
     _query     = q;
     _roleCache = roleCache;
     _indus     = indus;
     _mail      = mail;
     _options   = options.Value;
 }
Ejemplo n.º 14
0
 public RegisterDefinedRolesCommandHandler(
     CofoundryDbContext dbContext,
     ICommandExecutor commandExecutor,
     IRoleCache roleCache,
     IPermissionValidationService permissionValidationService,
     IEnumerable <IRoleDefinition> roleDefinitions,
     IRoleInitializerFactory roleInitializerFactory,
     IPermissionRepository permissionRepository
     )
 {
     _dbContext                   = dbContext;
     _commandExecutor             = commandExecutor;
     _roleCache                   = roleCache;
     _permissionValidationService = permissionValidationService;
     _roleDefinitions             = roleDefinitions;
     _roleInitializerFactory      = roleInitializerFactory;
     _permissionRepository        = permissionRepository;
 }
 public RegisterPermissionsAndRolesCommandHandler(
     CofoundryDbContext dbContext,
     ICommandExecutor commandExecutor,
     IRoleCache roleCache,
     IPermissionValidationService permissionValidationService,
     IEnumerable <IRoleDefinition> roleDefinitions,
     IRoleInitializerFactory roleInitializerFactory,
     IPermissionRepository permissionRepository,
     IEntityDefinitionRepository entityDefinitionRepository,
     ITransactionScopeManager transactionScopeFactory
     )
 {
     _dbContext                   = dbContext;
     _commandExecutor             = commandExecutor;
     _roleCache                   = roleCache;
     _permissionValidationService = permissionValidationService;
     _roleDefinitions             = roleDefinitions;
     _roleInitializerFactory      = roleInitializerFactory;
     _permissionRepository        = permissionRepository;
     _entityDefinitionRepository  = entityDefinitionRepository;
     _transactionScopeFactory     = transactionScopeFactory;
 }
Ejemplo n.º 16
0
 static CacheFactory()
 {
     roleCache       = new RoleCache();
     accountCache    = new AccountCache();
     battleRoomCache = new BattleRoomCache();
 }
 public UserController(IUserService service, IRoleCache roleCache, ILogger <UserController> logger)
 {
     _service   = service;
     _roleCache = roleCache;
     _logger    = logger;
 }
Ejemplo n.º 18
0
        public Database(Configuration configuration)
        {
            this.connectionString = configuration.ConnectionString;
            if (this.connectionString == null)
            {
                throw new Exception("Configuration.ConnectionString is missing");
            }

            var connectionStringBuilder = new SqlConnectionStringBuilder(this.connectionString);
            var applicationName = connectionStringBuilder.ApplicationName.Trim();
            if (!string.IsNullOrWhiteSpace(applicationName))
            {
                this.id = applicationName;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(connectionStringBuilder.InitialCatalog))
                {
                    this.id = connectionStringBuilder.InitialCatalog.ToLowerInvariant();
                }
                else
                {
                    using (this.connection = new SqlConnection(this.connectionString))
                    {
                        this.connection.Open();
                        this.id = this.connection.Database.ToLowerInvariant();
                    }
                }
            }

            this.objectFactory = configuration.ObjectFactory;
            if (this.objectFactory == null)
            {
                throw new Exception("Configuration.ObjectFactory is missing");
            }

            if (!this.objectFactory.MetaPopulation.IsValid)
            {
                throw new ArgumentException("Domain is invalid");
            }

            this.objectIds = configuration.ObjectIds ?? new ObjectIdsInteger();
            this.roleCache = configuration.RoleCache ?? new RoleCache();
            this.classCache = configuration.ClassCache ?? new ClassCache();
            this.commandTimeout = configuration.CommandTimeout ?? 30;
            this.isolationLevel = configuration.IsolationLevel ?? IsolationLevel.Snapshot;
            this.schemaName = configuration.SchemaName ?? "allors";
            this.useViews = configuration.UseViews ?? true;

            if (this.ObjectIds is ObjectIdsInteger)
            {
                this.mapping = new MappingInteger(this);
            }
            else if (this.ObjectIds is ObjectIdsLong)
            {
                this.mapping = new MappingLong(this);
            }
            else
            {
                throw new NotSupportedException("ObjectIds of type " + this.ObjectIds.GetType() + " are not supported.");
            }
        }