private void AuditAnyRequiredChanges(ICommandRepository repository, IEnumerable<DbEntityEntry> modifiedItems, DbContext dbContext) { var manager = ((IObjectContextAdapter)dbContext).ObjectContext.ObjectStateManager; var relations = manager.GetObjectStateEntries(EntityState.Deleted).Where(p => p.IsRelationship); // The entityType could be either a normal type of proxy wrapper therefore we need to use GetObjectType. var auditableEntities = modifiedItems.Where(p => auditItems.Select(p1 => p1.ClassType).Contains(ObjectContext.GetObjectType(p.Entity.GetType()))); foreach (var context in auditableEntities) { // Check each property for changes var BluePearEntityType = ObjectContext.GetObjectType(context.Entity.GetType()); var auditItem = auditItems.Single(p => p.ClassType == BluePearEntityType); auditItem.AuditPropertyItems.ToList().ForEach(auditPropertyItem => { var oldValue = default(object); var currentValue = default(object); if (!auditPropertyItem.IsRelationship) { var olddbValue = context.OriginalValues.GetValue<object>(auditPropertyItem.PropertyName); var newDbValue = auditPropertyItem.PropertyInfo.GetValue(context.Entity); // Transform them if required oldValue = auditPropertyItem.GetValue(olddbValue); currentValue = auditPropertyItem.GetValue(newDbValue); } else { foreach (var deletedEntity in relations.Where(p => p.EntitySet.Name == BluePearEntityType.Name + "_" + auditPropertyItem.PropertyName)) { var entityId = ((EntityKey)deletedEntity.OriginalValues[0]).EntityKeyValues[0].Value; if ((int)entityId == ((IEntity)context.Entity).ID) { oldValue = ((EntityKey)deletedEntity.OriginalValues[1]).EntityKeyValues[0].Value; break; } } // if its null it hasn't changed if (oldValue == null) return; currentValue = ((IEntity)context.Member(auditPropertyItem.PropertyName).CurrentValue).ID; } if (!currentValue.Equals(oldValue)) { // Add the audit! var item = new AuditPropertyTrail(); item.EntityType = BluePearEntityType.Name; item.EntityId = ((IEntity)context.Entity).ID; item.PropertyName = auditPropertyItem.PropertyName; item.NewValue = currentValue.ToString(); item.OldValue = oldValue.ToString(); repository.Add(item); } }); } }
public AuthenticationApplicationService( IPasswordLoginCommand passwordLoginCommand, IJwtFactory jwtFactory, ITransactionManager transactionManager, ICommandRepository <Identity> identityCommandRepository, IRefreshTokenLoginCommand refreshTokenLoginCommand, IQueryRepository <AuthenticationService> authenticationServiceCommandRepository, IGoogleAuthenticationValidator googleAuthenticationValidator, IFacebookAuthenticationValidator facebookAuthenticationValidator, IClientCredentialLoginCommand clientCredentialLoginCommand, ICreateIdentityCommand createIdentityCommand, IGetIdentityByClientCredentialIdentifierQuery getIdentityByClientCredentialIdentifierQuery, IRegisterClientCredentialCommand registerClientCredentialCommand) { _passwordLoginCommand = passwordLoginCommand; _jwtFactory = jwtFactory; _transactionManager = transactionManager; _identityCommandRepository = identityCommandRepository; _refreshTokenLoginCommand = refreshTokenLoginCommand; _authenticationServiceCommandRepository = authenticationServiceCommandRepository; _googleAuthenticationValidator = googleAuthenticationValidator; _facebookAuthenticationValidator = facebookAuthenticationValidator; _clientCredentialLoginCommand = clientCredentialLoginCommand; _createIdentityCommand = createIdentityCommand; _getIdentityByClientCredentialIdentifierQuery = getIdentityByClientCredentialIdentifierQuery; _registerClientCredentialCommand = registerClientCredentialCommand; }
public MongoDbEntityModifedAllEvent(ICommandRepository commandRepository, ISpecificationQueryStrategy <TEntity> specificationStrategy, IEnumerable <MongoUpdateItem <TEntity> > mongoUpdateItems, WriteConcern writeConcern) : base(commandRepository, null) { MongoUpdateItems = mongoUpdateItems; SpecificationStrategy = specificationStrategy; WriteConcern = writeConcern; }
public MongoDbEntityModifedAllEvent(ICommandRepository commandRepository, ISpecificationQueryStrategy <TEntity> specificationStrategy, IMongoUpdate mongoUpdate, WriteConcern writeConcern) : base(commandRepository, null) { MongoUpdate = mongoUpdate; SpecificationStrategy = specificationStrategy; WriteConcern = writeConcern; }
public override async Task Setup() { await base.Setup(); BatchRepository = new BatchRepository(DbConnectionFactory); Sut = new CommandRepository(DbConnectionFactory); }
public CommandInitializer(ICommandRepository repository, [Named("CommandHelper")] IHelper <Action> helper, IStaticDataManager staticDataManager) { Repository = (CommandRepository)repository; Helper = helper; _staticDataManager = staticDataManager; }
public MongoDBCommandService(ICommandRepository commandRepository, IMapper mapper) { _mapper = mapper; _commandRepository = commandRepository; CheckAndSaveCommands(); }
public CommandReceiver(IQueueingFactory queueingFactory, IConfigurationProvider configurationProvider, ICommandMessageMapper commandMapper, ICommandRepository commandRepository) { this.queueingFactory = queueingFactory; this.configurationProvider = configurationProvider; this.commandMapper = commandMapper; this.commandRepository = commandRepository; }
protected RepositoryCommandEntityEvent(ICommandRepository commandRepository, object entity) : base(commandRepository) { Check.NotNull(entity, "entity"); Entity = entity; }
public AdminService(IQueryRepository <Company> qcompany, ICommandRepository <Company> cmdCompany, IQueryRepository <LoginUser> qLoginUser, ICommandRepository <LoginUser> cmdLoginUser) { this.qcompany = qcompany; this.cmdCompany = cmdCompany; this.qLoginUser = qLoginUser; this.cmdLoginUser = cmdLoginUser; }
public CommandDomainService(ICommandRepository <TEntity> repository, ILogger logger) { ContractUtility.Requires <ArgumentNullException>(repository != null, "repository instance cannot be null"); ContractUtility.Requires <ArgumentNullException>(logger != null, "logger instance cannot be null"); _repository = repository; this.logger = logger; }
public static void UpdateEntityState <TEntity>(this ICommandRepository repository, TEntity entity, EntityState entityState) where TEntity : class { Check.NotNull(repository, "repository"); Check.NotNull(entity, "entity"); _DefaultImplementation.UpdateEntityState(repository, entity, entityState); }
public static void AddRange <TEntity>(this ICommandRepository commandRepository, IEnumerable <TEntity> entities) where TEntity : class { Check.NotNull(commandRepository, "commandRepository"); Check.NotNull(entities, "entities"); _DefaultImplementation.AddRange(commandRepository, entities); }
public static int ExecuteStoredProcudure(this ICommandRepository repository, string sql, params object[] args) { Check.NotNull(repository, "repository"); Check.NotEmpty(sql, "sql"); return(_DefaultImplementation.ExecuteStoredProcudure(repository, sql, args)); }
/// <summary> /// Initializes a new instance of the <see cref="QuerySkillMatrixController"/> class. /// </summary> /// <param name="skillRepository">The skill repository.</param> public CommandTemplateController( ICommandRepository <Template> commandRepository, IQueryRepository <Template, string> queryRepository) { this.commandRepository = commandRepository; this.queryRepository = queryRepository; }
public AnalyticCommandReceiver(IRabbitMQConfiguration rabbitConf, ICommandRepository commandRepository, IHubContext <CommandHub> hub) : base(rabbitConf, rabbitConf.AnalyticCommandQueueName) { _rabbitMQConfiguration = rabbitConf; _commandRepository = commandRepository; _hub = hub; }
protected ICommandRepository <Employee> GetEmployeeCommandServiceRepositoryInstance(IUnitOfWork unitOfWork = null) { string name = typeof(Employee).Name + SERVICE_SUFFIX; ICommandRepository <Employee> repository = unitOfWork.IsNull() ? _container.Resolve <ICommandRepository <Employee> >(name) : _container.Resolve <ICommandRepository <Employee> >(name, new ParameterOverride("unitOfWork", unitOfWork)); return(repository); }
public void test_delete_of_department_should_delete_the_underlying_employee() { //Arrange using (ICommandRepository <Department> departmentCommandRepository = GetCommandRepositoryInstance <Department>()) using (ICommandRepository <Employee> employeeCommandRepository = GetCommandRepositoryInstance <Employee>()) using (IQueryableRepository <Employee> employeeQueryableRepository = GetQueryableRepositoryInstance <Employee>()) { //Arrange Department departmentFake = FakeData.GetDepartmentFake(); Employee employeeFake = FakeData.GetEmployeeFake(); employeeFake.EmployeeName = "XYZ"; employeeFake.DeptID = departmentFake.Id; employeeFake.Department = departmentFake; //Action //Employee insert will automatically insert the department object before inserting this employee object //since department object is marked as required in the employee map. employeeCommandRepository.Insert(employeeFake); // Should delete the employee object automatically since the map is defined so // (WillCascadeOnDelete is set to true). departmentCommandRepository.Delete(departmentFake); //Assert employeeQueryableRepository.Count().Should().Be(0); }; }
/// <summary> /// 构造函数注入 /// </summary> /// <param name="uow"></param> /// <param name="bus"></param> /// <param name="cache"></param> public BaseGuidCommandHandler(IUnitOfWork <TContext> unitOfWork, IMediatorHandler bus, IQueryRepository <TEntity, TContext> queryRepository, ICommandRepository <TEntity, TContext> commandRepository) : base(unitOfWork, bus) { QueryRepository = queryRepository; CommandRepository = commandRepository; }
public AuthenticationService(ICommandRepository <LoginUser> cmdRepository, IQueryRepository <LoginUser> qRepository, IEncryptionService encryptionService, IFormsAuthenticationService formsAuthenticationService) { this.formsAuthenticationService = formsAuthenticationService; this.cmdRepository = cmdRepository; this.qRepository = qRepository; this.encryptionService = encryptionService; }
public CommandService(ICommandRepository commandRepository, IDbContextScopeFactory dbContextScopeFactory, IReferenceGenerator generator) { this.commandRepository = commandRepository; this.dbContextScopeFactory = dbContextScopeFactory; this.generator = generator; }
protected ICommandRepository <TEntity> GetCommandRepositoryInstance <TEntity>(IUnitOfWork unitOfWork = null) where TEntity : ICommandAggregateRoot { string respositoryName = unitOfWork.IsNotNull() ? REPOSITORY_WITH_UNIT_OF_WORK : REPOSITORY_WITHOUT_UNIT_OF_WORK; ICommandRepository <TEntity> repository = unitOfWork.IsNull() ? _container.Resolve <ICommandRepository <TEntity> >(respositoryName) : _container.Resolve <ICommandRepository <TEntity> >(respositoryName, new ParameterOverride("unitOfWork", unitOfWork)); return(repository); }
public CommandsController( ICommandRepository commandRepository, IMapper mapper) { _commandRepository = commandRepository; _mapper = mapper; }
public IdentityApplicationService( ITransactionManager transactionManager, IResetPasswordCommand resetPasswordCommand, ICommandRepository <Identity> identityCommandRepository, ICommandRepository <AuthenticationService> authenticationServiceCommandRepository, IQueryRepository <Identity> identityQueryRepository, IChangePasswordCommand changePasswordCommand, IRegisterPasswordCommand registerPasswordCommand, ICreateIdentityCommand createIdentityCommand, IForgotPasswordCommand forgotPasswordCommand, IConfirmIdentityCommand confirmIdentityCommand, ICreateRefreshTokenCommand createRefreshTokenCommand, IResendConfirmIdentityCommand resendConfirmIdentityCommand, ILogoutCommand logoutCommand) { _transactionManager = transactionManager; _resetPasswordCommand = resetPasswordCommand; _identityCommandRepository = identityCommandRepository; _authenticationServiceCommandRepository = authenticationServiceCommandRepository; _identityQueryRepository = identityQueryRepository; _changePasswordCommand = changePasswordCommand; _registerPasswordCommand = registerPasswordCommand; _createIdentityCommand = createIdentityCommand; _forgotPasswordCommand = forgotPasswordCommand; _confirmIdentityCommand = confirmIdentityCommand; _createRefreshTokenCommand = createRefreshTokenCommand; _logoutCommand = logoutCommand; _resendConfirmIdentityCommand = resendConfirmIdentityCommand; }
public CommandHandler(CentralValidations validator, IUnityOfWork unityOfWork, ICommandRepository commandRepository, DomainEventBus eventBus) { _validator = validator; _uoW = unityOfWork; _commandRepository = commandRepository; _eventBus = eventBus; }
public void test_fluent_delete_of_department_should_delete_the_underlying_employee() { //Arrange ICommandRepository <Department> departmentCommandRepository = GetCommandRepositoryInstance <Department>(); ICommandRepository <Employee> employeeCommandRepository = GetCommandRepositoryInstance <Employee>(); IQueryableRepository <Employee> employeeQueryableRepository = GetQueryableRepositoryInstance <Employee>(); Department departmentFake = FakeData.GetDepartmentFake(); Employee employeeFake = FakeData.GetEmployeeFake(); employeeFake.EmployeeName = "XYZ"; employeeFake.DeptID = departmentFake.Id; employeeFake.Department = departmentFake; int employeesCount = 0; //Action //Employee insert will automatically insert the department object before inserting this employee object //since department object is marked as required in the employee map. // Should delete the employee object automatically since the map is defined so // (WillCascadeOnDelete is set to true). FluentRepoNamespace.FluentRepository .SetUpCommandRepository(employeeCommandRepository, departmentCommandRepository) .Insert(employeeFake) .DeleteAsync(departmentFake) .SetUpQueryRepository(employeeQueryableRepository) .Query <Employee>(x => x, x => employeesCount = x.Count()) .ExecuteAsync(shouldAutomaticallyDisposeAllDisposables: true); //Assert employeesCount.Should().Be(0); }
public void Modify <T>(ICommandRepository repository, Action <T> modifyAction, T entity) where T : class { Check.NotNull(repository, "modifyAction"); Check.NotNull(entity, "entity"); modifyAction.Invoke(entity); }
public void Configure(ICommandRepository repository, LoginCredentials loginCredentials) { if (loginCredentials.IsBot) { repository.Enable(Name.From("cheese")); } }
public CommandService(ICommandRepository repo, IActuatorRepository actuatorRepo, IServiceScopeFactory serviceScopeFactory, ISerialCancellation serialCancellation) { _repo = repo; _actuatorRepo = actuatorRepo; _serviceScopeFactory = serviceScopeFactory; _serialCancellation = serialCancellation; }
public RejectAccountAccessConsentCommandHandler( ICommandRepository commandRepository, ILogger <RejectAccountAccessConsentCommandHandler> logger) { _commandRepository = commandRepository; _logger = logger; }
public CommandService(ILogger logger, ICommandRepository commandRepository, IMessageWriter messageWriter) { this._logger = logger; this._commandRepository = commandRepository; this._messageWriter = messageWriter; Clients = new Dictionary<int, TcpClient>(); }
public ArticleHandler(IQueryRepository queryRepository, ICommandRepository commandRepository, IMapper mapper, IQueuePusher queue) { _queryRepository = queryRepository; _commandRepository = commandRepository; _mapper = mapper; _queue = queue; }
public CommandService(ICommandRepository commandRepo, IClientRepository clientRepo, IAddressRepository addressRepo, ICityRepository cityRepo, IWineRepository wineRepo) { _commandRepo = commandRepo; _clientRepo = clientRepo; _addressRepo = addressRepo; _cityRepo = cityRepo; _wineRepo = wineRepo; }
public ScriptCommandDecorator( ScriptEnvironmentBase scriptEnvironment, ICommandRepository commandRepository, IUnityContainer container) { this.scriptEnvironment = scriptEnvironment; this.commandRepository = commandRepository; this.container = container; }
public int Save(ICommandRepository repository, Func<int> saveFunc) { Check.NotNull(repository, "repository"); Check.NotNull(repository, "saveFunc"); var retVal = saveFunc.Invoke(); return retVal; }
public CustomCommands() { InitializeComponent(); _repo = new CommandRepository(Global.ConnectionString); //Added to support default instance behavour in C# if (defaultInstance == null) defaultInstance = this; }
public IssueController( ICommandRepository commandRepository, ICommandExecutor commandExecutor, IUserAccess userAccess, IIssueAccess issueAccess) { this.commandRepository = commandRepository; this.commandExecutor = commandExecutor; this.userAccess = userAccess; this.issueAccess = issueAccess; }
protected override IEnumerable<IAuditItem> GetAuditItems(ICommandRepository commandRepository) { // Set up monitoring on specific columns (Add change information to the AuditPropertyTrails table). return new[] { new AuditItem( typeof(Instructor), // new AuditPropertyItem(PropertyInfo<Instructor>.GetMemberName(p => p.FirstMidName), p => ((string)p).ToLower()), new AuditPropertyItem(PropertyInfo<Instructor>.GetMemberName(p => p.FirstMidName)), new AuditPropertyItem(PropertyInfo<Instructor>.GetMemberName(p => p.LastName))), }; }
public virtual int Save(ICommandRepository commandRepository, Func<int> saveFunc) { auditItems = GetAuditItems(commandRepository); var dbContext = commandRepository.ObjectContext as DbContext; if (dbContext == null) throw new NotSupportedException("AuditSaveCommand.Save can only be used with a DBContext"); // Modified Items var modifiedItems = dbContext.ChangeTracker.Entries().Where(entity => entity != null && entity.State == EntityState.Modified); if (modifiedItems.Any()) AuditAnyRequiredChanges(commandRepository, modifiedItems, dbContext); return saveFunc.Invoke(); }
protected abstract IEnumerable<IAuditItem> GetAuditItems(ICommandRepository commandRepository);
public MongoDbUnitOfWorkRepository(MongoDatabase mongoDatabase, IQueryRepository queryRepository, ICommandRepository commandRepository) : base(queryRepository, commandRepository) { ObjectContext = mongoDatabase; }
protected RepositoryCommandEvent(ICommandRepository commandRepository) { Check.NotNull(commandRepository, "commandRepository"); CommandRepository = commandRepository; }
public CommandListResult(ICommandRepository repository) { _repository = repository; }
public CommandLineProcessor(ICommandRepository commands) { _commands = commands; }
public VerbNounCommandLineHandler(ICommandRepository commands) : base(commands) { }
public ArticleService(ICommandRepository commandRepository, IQueryRepository queryRepository, IMapper mapper) { _commandRepository = commandRepository; _queryRepository = queryRepository; _mapper = mapper; }
public MongoDbRepositorySavedEvent(ICommandRepository commandRepository) : base(commandRepository) { }
public NamedCommandLineHandler(ICommandRepository commands) { _commands = commands; }
public UserController(ICommandRepository commandRepository, ICommandExecutor commandExecutor, IUserAccess userAccess) { this.commandRepository = commandRepository; this.commandExecutor = commandExecutor; this.userAccess = userAccess; }
private void RunCustomCommands(string weiboId, string command) { var splitCommand = command.Split(' ')[0]; NotifyIcon.Text = @"检查自定义命令..."; DebugPrintHelper("当前状态:检查自定义命令..."); try { _repo = new CommandRepository(Global.ConnectionString); var cmd = _repo.FindOne(splitCommand.ToLower()); if(cmd != null && !string.IsNullOrEmpty(cmd.File)) { SendComment(weiboId, string.Format("#PC遥控器#正在为您执行您的自定义命令: {0}。", command)); var optionsCommand = command.Remove(0, splitCommand.Length); while (optionsCommand.StartsWith(" ")) { optionsCommand = optionsCommand.Remove(0, 1); } DebugPrintHelper(string.Format("当前执行的自定义命令为: \"{0} {1}\"", cmd.File, optionsCommand)); Process.Start(cmd.File, optionsCommand); SendComment(weiboId, "#PC遥控器#执行自定义命令完成。"); } } catch (Exception ex) { DebugPrintHelper(ex.Message); SendComment(weiboId, "执行自定义命令出错。请过一会重试。"); } }
public RepositorySavedEvent(ICommandRepository commandRepository) { Check.NotNull(commandRepository, "commandRepository"); CommandRepository = commandRepository; }
public VirtualDeviceService(IVirtualDeviceRepository deviceRepo, ICommandRepository commandRepo, ICommandQueueService cqs) { _deviceRepo = deviceRepo; _commandRepo = commandRepo; _cqs = cqs; }
protected NamedCommandLocator(ICommandRepository commands) { _commands = commands; }
public ArticleProcessor(ICommandRepository commandRepository, IMapper mapper) { _commandRepository = commandRepository; _mapper = mapper; }
public NounVerbCommandLocator(ICommandRepository commands) : base(commands) { }
public CommandLineHandler(ICommandRepository commands) { Commands = commands; }
public EntityDeletedEvent(ICommandRepository commandRepository, object entity) : base(commandRepository, entity) { }
public MongoDbEntityAddedEvent(ICommandRepository commandRepository, object entity, WriteConcernResult result) : base(commandRepository, entity) { WriteConcernResult = result; }
public EntityModifiedEvent(ICommandRepository commandRepository, object entity) : base(commandRepository, entity) { }