コード例 #1
0
ファイル: LocalDBContext.cs プロジェクト: Seichis/DataHub
 public LocalDBContext(
     IEntitiesRepository entitiesRepository,
     ILogger logger = null)
 {
     Logger = logger;
     this.entitiesRepository = entitiesRepository;
 }
コード例 #2
0
 public ProjectModel GetProjectByProjectName(string projectName)
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(item => item.Name.Equals(projectName)).First();
     }
 }
コード例 #3
0
 public CategoryModel Get(int id)
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(id);
     }
 }
コード例 #4
0
ファイル: UsersService.cs プロジェクト: reaperdk/timetracker
 public IEnumerable<UserModel> GetAll()
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(item => item.webpages_Roles).ToArray();
     }
 }
コード例 #5
0
 public IEnumerable<PriorityModel> GetAll()
 {
     using (_repository = _getRepository())
     {
         return _repository.Get().ToArray();
     }
 }
コード例 #6
0
ファイル: UsersService.cs プロジェクト: reaperdk/timetracker
 public UserModel GetByUserName(string userName)
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(item => item.UserName.Equals(userName), item => item.webpages_Roles).First();
     }
 }
コード例 #7
0
ファイル: UsersService.cs プロジェクト: reaperdk/timetracker
 public UserModel GetById(int id)
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(item => item.UserId == id, item => item.webpages_Roles).First();
     }
 }
コード例 #8
0
 public StatusModel Get(int id)
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(id);
     }
 }
コード例 #9
0
ファイル: RolesService.cs プロジェクト: reaperdk/timetracker
 public RoleModel GetById(int id)
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(id);
     }
 }
コード例 #10
0
        public ClusterMonitorService(
            IServiceProvider sp,
            IClusterRequestHandler _node,
            IEntitiesRepository entitiesRepository,
            MetricManagementService metricManagementService,
            IMetricTicksRepository metricTicksRepository,
            IDatabaseMetricsCollector databaseMetricsCollector,
            NodeStateService nodeStateService,
            IOptions <ClusterOptions> clusterOptions)
        {
            _metricManagementService = metricManagementService;
            // var sp = serviceProvider.CreateScope().ServiceProvider;
            _mediator = sp.GetService <IMediator>();
            _logger   = sp.GetService <ILogger <ClusterMonitorService> >();
            _state    = sp.GetService <IClusterStateService>();

            _logger.LogInformation("Starting clean up service...");
            node = _node;
            _entitiesRepository       = entitiesRepository;
            _metricTicksRepository    = metricTicksRepository;
            _databaseMetricsCollector = databaseMetricsCollector;
            monitoringTimer           = new System.Threading.Timer(CollectMetricsEventHandler);
            node.MetricGenerated     += metricGenerated;
            _nodeStateService         = nodeStateService;
            _clusterOptions           = clusterOptions;
            Start();
        }
コード例 #11
0
ファイル: TasksService.cs プロジェクト: reaperdk/timetracker
 public TaskModel GetTaskByTaskName(string taskName)
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(item => item.Name.Equals(taskName)).First();
     }
 }
コード例 #12
0
 public PriorityModel Get(int id)
 {
     using (_repository = _getRepository())
     {
         return _repository.Get(id);
     }
 }
コード例 #13
0
 public DataController(
     IEntitiesRepository entitiesRepository,
     DbContext dbContext)
 {
     this.entitiesRepository = entitiesRepository;
     this.dbContext          = dbContext;
 }
コード例 #14
0
 public Models.UserProfile GetUserProfileByUserName(string name)
 {
     using (_userProfileRepository = _userProfileRepositoryInitializer())
     {
         return Mapper.Map<UserProfile, Models.UserProfile>(_userProfileRepository.Get(u => u.UserName.Equals(name)).SingleOrDefault());
     }
 }
コード例 #15
0
 public GetMetricsQueryHandler(ILogger <GetMetricsQueryHandler> logger,
                               IEntitiesRepository entitiesRepository,
                               IMetricTicksRepository metricTicksRepository)
 {
     _entitiesRepository    = entitiesRepository;
     _metricTicksRepository = metricTicksRepository;
     _logger = logger;
 }
コード例 #16
0
 public void Create(ProjectModel project)
 {
     using (_repository = _getRepository())
     {
         _repository.Insert(project);
         _repository.Save();
     }
 }
コード例 #17
0
ファイル: SlotsService.cs プロジェクト: reaperdk/timetracker
 public void Create(SlotModel slot)
 {
     using (_repository = _getRepository())
     {
         _repository.Insert(slot);
         _repository.Save();
     }
 }
コード例 #18
0
 public void UpdateMembership(Models.webpages_Membership toUpdate)
 {
     using (_membershipRepository = _membershipRepositoryInitializer())
     {
         _membershipRepository.Update(Mapper.Map<Models.webpages_Membership, webpages_Membership>(toUpdate));
         _membershipRepository.Save();
     }
 }
コード例 #19
0
ファイル: TasksService.cs プロジェクト: reaperdk/timetracker
 public void Create(TaskModel task)
 {
     using (_repository = _getRepository())
     {
         _repository.Insert(task);
         _repository.Save();
     }
 }
コード例 #20
0
 public void AddUser(Models.UserProfile toAdd)
 {
     using (_userProfileRepository = _userProfileRepositoryInitializer())
     {
         _userProfileRepository.Insert(Mapper.Map<Models.UserProfile, UserProfile>(toAdd));
         _userProfileRepository.Save();
     }
 }
コード例 #21
0
 public void Remove(int id)
 {
     using (_repository = _getRepository())
     {
         _repository.Remove(id);
         _repository.Save();
     }
 }
コード例 #22
0
 public AppLinksService(IPlatformProxy platformProxy, IApplicationSettings applicationSettings, IHashService hashService, IEntitiesRepository entitiesRepository, ILog log)
 {
     _platformProxy = platformProxy;
     _applicationSettings = applicationSettings;
     _hashService = hashService;
     _entitiesRepository = entitiesRepository;
     _log = log;
     _servicePath = _applicationSettings.AppLinkPath;
 }
コード例 #23
0
        public CreateEntityValidator(IEntitiesRepository <ObjectIdentifier> entitiesRepository)
        {
            this.RuleFor(e => e.Name)
            .NotEmpty()
            .Must(name => entitiesRepository.Find(new FindEntityByName(name)) == null)
            .WithMessage("Entity with this name already exists");

            this.RuleFor(e => e.Description).NotEmpty();
        }
コード例 #24
0
 public AppendStepLogCommandHandler(IEntitiesRepository entitiesRepository,
                                    ILogger <AppendStepLogCommandHandler> logger,
                                    IClusterRequestHandler node
                                    )
 {
     _entitiesRepository = entitiesRepository;
     Logger = logger;
     _node  = node;
 }
コード例 #25
0
 public CreateStepCommandHandler(
     IEntitiesRepository entitiesRepository,
     IClusterStateService service,
     IClusterRequestHandler node)
 {
     _entitiesRepository  = entitiesRepository;
     _clusterStateService = service;
     _node = node;
 }
コード例 #26
0
 public AppLinksService(IPlatformProxy platformProxy, IApplicationSettings applicationSettings, IHashService hashService, IEntitiesRepository entitiesRepository, ILog log)
 {
     _platformProxy       = platformProxy;
     _applicationSettings = applicationSettings;
     _hashService         = hashService;
     _entitiesRepository  = entitiesRepository;
     _log         = log;
     _servicePath = _applicationSettings.AppLinkPath;
 }
コード例 #27
0
 public EntitiesDBContext(
     string connectionString,
     IEntitiesRepository entitiesRepository,
     ILogger logger = null)
 {
     this.connectionString = connectionString;
     Logger = logger;
     this.entitiesRepository = entitiesRepository;
 }
コード例 #28
0
 public void Update(ProjectModel project)
 {
     using (_repository = _getRepository())
     {
         ProjectModel toUpdate = _repository.Get(item => item.Id == project.Id).First();
         toUpdate.Name = project.Name;
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }
コード例 #29
0
 public UpdateExecutionScheduleCommandHandler(IEntitiesRepository entitiesRepository,
                                              IClusterStateService service,
                                              IClusterRequestHandler node,
                                              IMediator mediator)
 {
     _entitiesRepository  = entitiesRepository;
     _clusterStateService = service;
     _node     = node;
     _mediator = mediator;
 }
コード例 #30
0
 public void SetSalt(int userId, string salt)
 {
     using (_repository = _getRepository())
     {
         MembershipModel membership = _repository.Get(userId);
         membership.PasswordSalt = salt;
         _repository.Update(membership);
         _repository.Save();
     }
 }
コード例 #31
0
 public CreateUserCommandHandler(
     IEntitiesRepository entitiesRepository,
     ILogger <CreateUserCommandHandler> logger,
     IServiceProvider prov,
     IDataRouter router,
     IClusterRequestHandler node
     )
 {
     _entitiesRepository = entitiesRepository;
     _node = (IClusterRequestHandler)prov.GetService(typeof(IClusterRequestHandler));
 }
コード例 #32
0
 public CreateWorkflowCommandHandler(
     IEntitiesRepository entitiesRepository,
     IMediator mediator,
     IClusterRequestHandler node,
     ILogger <CreateWorkflowCommandHandler> logger)
 {
     _entitiesRepository = entitiesRepository;
     _mediator           = mediator;
     _node   = node;
     _logger = logger;
 }
コード例 #33
0
 public EntitiesService(
     IEntitiesRepository <ObjectIdentifier> entitiesRepository,
     ICommandValidator <CreateEntityCommand, Entity> createCommandValidator,
     ICommandValidator <UpdateEntityCommand, Entity> updateCommandValidator,
     IMapper mapper)
 {
     _entitiesRepository     = entitiesRepository ?? throw new ArgumentNullException(nameof(entitiesRepository));
     _createCommandValidator = createCommandValidator ?? throw new ArgumentNullException(nameof(createCommandValidator));
     _updateCommandValidator = updateCommandValidator ?? throw new ArgumentNullException(nameof(updateCommandValidator));
     _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
 }
コード例 #34
0
 public DocumentService(
     IFrissFileSystemContext frissFileSystemContext,
     IFrissDbContext frissDbContext,
     IFileRepository fileRepository,
     IEntitiesRepository <Document> documentRepository)
 {
     _frissFileSystemContext = frissFileSystemContext;
     _frissDbContext         = frissDbContext;
     _fileRepository         = fileRepository;
     _documentRepository     = documentRepository;
 }
コード例 #35
0
 public EntitiesController(
     IEntitiesRepository entitiesRepository,
     EntitiesDBContext dbContext,
     IQueryableRepository <Entities.FileInfo> filesRepository,
     IBlobRepository blobRepository)
 {
     this.entitiesRepository = entitiesRepository;
     this.dbContext          = dbContext;
     this.filesRepository    = filesRepository;
     this.blobRepository     = blobRepository;
 }
コード例 #36
0
 public InitializeClusterCommandHandler(
     ILogger <InitializeClusterCommandHandler> logger,
     IEntitiesRepository entitiesRepository,
     IMediator mediator,
     IClusterStateService clusterState
     )
 {
     _mediator           = mediator;
     _entitiesRepository = entitiesRepository;
     _logger             = logger;
     _clusterState       = clusterState;
 }
コード例 #37
0
        public MetricManagementService(
            ILogger <MetricManagementService> logger,
            IClusterRequestHandler node,
            NodeStateService nodeStateService,
            IEntitiesRepository entitiesRepository,
            IConfiguration configuration
            )
        {
            _logger = logger;
            _logger.LogInformation("Populating Metrics...");
            _metricLibrary      = new MetricLibrary();
            _node               = node;
            _nodeStateService   = nodeStateService;
            _entitiesRepository = entitiesRepository;
            _configuration      = configuration;
            EnableMetrics       = _configuration.GetValue <bool>("EnableMonitoring");
            if (EnableMetrics)
            {
                writeThread = new Task(async() =>
                {
                    MetricTick tick;
                    while (true)
                    {
                        // Console.WriteLine("Number of tasks " + _ticks.Count());
                        if (_nodeStateService.InCluster)
                        {
                            if (_ticks.TryDequeue(out tick))
                            {
                                tick.Date     = tick.Date.ToUniversalTime();
                                tick.Id       = Guid.NewGuid();
                                var startTime = DateTime.Now;
                                await _node.Handle(new AddShardWriteOperation()
                                {
                                    WaitForSafeWrite = true,
                                    Operation        = ConsensusCore.Domain.Enums.ShardOperationOptions.Create,
                                    Data             = tick,
                                    Metric           = false // Do not metric the metric write operations
                                });
                                _logger.LogDebug("Total write time took " + (DateTime.Now - startTime).TotalMilliseconds + " total ticks left in queue " + _ticks.Count());

                                if (_ticks.Count > 100)
                                {
                                    _logger.LogWarning("Tick count is greater then 100...");
                                }
                            }
                        }
                        await Task.Delay(10);
                    }
                });

                writeThread.Start();
            }
        }
コード例 #38
0
 public string GetPasswordSaltByUserName(string userName)
 {
     using (_userProfileRepository = _userProfileRepositoryInitializer())
     {
         IQueryable<UserProfile> foundUserProfilesByName = _userProfileRepository.Get(u => u.UserName.Equals(userName));
         int userId = foundUserProfilesByName.Any() ? foundUserProfilesByName.Single().UserId : 0;
         using (_membershipRepository = _membershipRepositoryInitializer())
         {
             return _membershipRepository.Get(userId).PasswordSalt;
         }
     }
 }
コード例 #39
0
 public Models.webpages_Membership GetMembershipByUserName(string userName)
 {
     using (_userProfileRepository = _userProfileRepositoryInitializer())
     {
         IQueryable<UserProfile> foundUserProfilesByName = _userProfileRepository.Get(u => u.UserName.Equals(userName));
         int userId = foundUserProfilesByName.Any() ? foundUserProfilesByName.Single().UserId : 0;
         using (_membershipRepository = _membershipRepositoryInitializer())
         {
             return Mapper.Map<webpages_Membership, Models.webpages_Membership>(_membershipRepository.Get(userId));
         }
     }
 }
コード例 #40
0
 public void InitializeCategories()
 {
     using (_repository = _getRepository())
     {
         if (!_repository.Get().Any())
         {
             _repository.Insert(new CategoryModel { Name = "Easy" });
             _repository.Insert(new CategoryModel { Name = "Difficult" });
             _repository.Save();
         }
     }
 }
コード例 #41
0
ファイル: RolesService.cs プロジェクト: reaperdk/timetracker
 public void InitializeRoles()
 {
     using (_repository = _getRepository())
     {
         if (!_repository.Get().Any())
         {
             _repository.Insert(new RoleModel { RoleName = "admin" });
             _repository.Insert(new RoleModel { RoleName = "user" });
             _repository.Save();
         }
     }
 }
コード例 #42
0
ファイル: SlotsService.cs プロジェクト: reaperdk/timetracker
 public void Update(SlotModel slot)
 {
     using (_repository = _getRepository())
     {
         SlotModel toUpdate = _repository.Get(item => item.Id == slot.Id).First();
         toUpdate.Name = slot.Name;
         toUpdate.StartDate = slot.StartDate;
         toUpdate.FinishDate = slot.FinishDate;
         toUpdate.TaskId = slot.TaskId;
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }
コード例 #43
0
 public UnassignStepCommandHandler(IEntitiesRepository entitiesRepository,
                                   ILogger <UnassignStepCommandHandler> logger,
                                   IOptionsMonitor <CindiClusterOptions> options,
                                   IClusterRequestHandler node)
 {
     _entitiesRepository = entitiesRepository;
     _node  = node;
     Logger = logger;
     options.OnChange((change) =>
     {
         _option = change;
     });
 }
コード例 #44
0
 public void InitializePriorities()
 {
     using (_repository = _getRepository())
     {
         if (!_repository.Get().Any())
         {
             _repository.Insert(new PriorityModel { Name = "Low" });
             _repository.Insert(new PriorityModel { Name = "Medium" });
             _repository.Insert(new PriorityModel { Name = "High" });
             _repository.Insert(new PriorityModel { Name = "Very high" });
             _repository.Save();
         }
     }
 }
コード例 #45
0
ファイル: UsersService.cs プロジェクト: reaperdk/timetracker
 public void UpdateCreated(UserModel user)
 {
     using (_repository = _getRepository())
     {
         UserModel toUpdate = _repository.Get(item => item.UserName.Equals(user.UserName)).First();
         int roleId = user.webpages_Roles.First().RoleId;
         toUpdate.webpages_Roles = new []
             {
                 _repository.GetAnother<Model.RoleModel>(item => item.RoleId == roleId).First()
             };
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }
コード例 #46
0
 public AssignStepCommandHandler(
     IEntitiesRepository entitiesRepository,
     IClusterStateService stateService,
     ILogger <AssignStepCommandHandler> logger,
     IClusterRequestHandler node,
     IMemoryCache cache
     )
 {
     _entitiesRepository  = entitiesRepository;
     _clusterStateService = stateService;
     Logger = logger;
     _node  = node;
     _cache = cache;
 }
コード例 #47
0
ファイル: TypesService.cs プロジェクト: reaperdk/timetracker
 public void InitializeTypes()
 {
     using (_repository = _getRepository())
     {
         if (!_repository.Get().Any())
         {
             _repository.Insert(new TypeModel { Name = "Epic" });
             _repository.Insert(new TypeModel { Name = "Task" });
             _repository.Insert(new TypeModel { Name = "Bug" });
             _repository.Insert(new TypeModel { Name = "Exception" });
             _repository.Save();
         }
     }
 }
コード例 #48
0
ファイル: UsersService.cs プロジェクト: reaperdk/timetracker
 public void Update(UserModel user)
 {
     using (_repository = _getRepository())
     {
         UserModel toUpdate = _repository.Get(item => item.UserId == user.UserId, item => item.webpages_Roles).First();
         toUpdate.UserName = user.UserName;
         int roleId = user.webpages_Roles.First().RoleId;
         toUpdate.webpages_Roles.Clear();
         toUpdate.webpages_Roles.Add(
             _repository.GetAnother<Model.RoleModel>(item => item.RoleId == roleId).First()
         );
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }
コード例 #49
0
 public void InitializeStatuses()
 {
     using (_repository = _getRepository())
     {
         if (!_repository.Get().Any())
         {
             _repository.Insert(new StatusModel { Name = "Active" });
             _repository.Insert(new StatusModel { Name = "Completed" });
             _repository.Insert(new StatusModel { Name = "Suspended" });
             _repository.Insert(new StatusModel { Name = "New" });
             _repository.Insert(new StatusModel { Name = "Reactivated" });
             _repository.Save();
         }
     }
 }
コード例 #50
0
 public CompleteStepCommandHandler(IEntitiesRepository entitiesRepository,
                                   IClusterStateService clusterStateService,
                                   ILogger <CompleteStepCommandHandler> logger,
                                   CindiClusterOptions options,
                                   IMediator mediator,
                                   IClusterRequestHandler node,
                                   NodeStateService nodeStateService
                                   )
 {
     _entitiesRepository  = entitiesRepository;
     _clusterStateService = clusterStateService;
     Logger    = logger;
     _option   = options;
     _node     = node;
     _mediator = mediator;
 }
コード例 #51
0
 public DownaloadController(IFileGenerationsRepository repo, IEntitiesRepository entities,
                            IFileGenerationsRepository fileG,
                            IInventoryItemsRepository iventoryItems,
                            IInventoryTransactionDocumentsRepository iventoryTransactionDocuments,
                            IMenuItemPortionsRepository menuItemPortions,
                            IMenuItemPricesRepository menuItemPrices,
                            IMenuItemsRepository menuItems
                            )
 {
     _repo          = repo;
     _entities      = entities;
     _file          = fileG;
     _iventoryItems = iventoryItems;
     _iventoryTransactionDocuments = iventoryTransactionDocuments;
     _menuItemPortions             = menuItemPortions;
     _menuItemPrices = menuItemPrices;
     _menuItems      = menuItems;
 }
コード例 #52
0
 public ScanWorkflowCommandHandler(IEntitiesRepository entitiesRepository,
                                   IClusterStateService clusterStateService,
                                   ILogger <ScanWorkflowCommandHandler> logger,
                                   IOptionsMonitor <CindiClusterOptions> options,
                                   IMediator mediator,
                                   IClusterRequestHandler node
                                   )
 {
     _entitiesRepository  = entitiesRepository;
     _clusterStateService = clusterStateService;
     Logger  = logger;
     _option = options.CurrentValue;
     options.OnChange((change) =>
     {
         _option = change;
     });
     _mediator = mediator;
     _node     = node;
 }
コード例 #53
0
        public UpdateEntityValidator(IEntitiesRepository <ObjectIdentifier> entitiesRepository)
        {
            this.RuleFor(e => e.Id)
            .NotEmpty()
            .Must((command, id) =>
            {
                if (!ObjectIdentifier.TryParse(id, out ObjectIdentifier entityId))
                {
                    return(false);
                }

                var entity = entitiesRepository.Get(entityId);
                return(entity != null);
            })
            .WithMessage("Entity with such id doesn't exist");

            this.RuleFor(e => e.Name)
            .NotEmpty()
            .Must(name => entitiesRepository.Find(new FindEntityByName(name)) == null)
            .WithMessage("Entity with such name already exists");

            this.RuleFor(e => e.Description).NotEmpty();
        }
コード例 #54
0
        public void ListPresentsCorrectPageOfEntities()
        {
            IEntitiesRepository repository = MockEntitiesRepository(
                new Entity {
                Name = "P1"
            },
                new Entity {
                Name = "P2"
            },
                new Entity {
                Name = "P3"
            },
                new Entity {
                Name = "P4"
            },
                new Entity {
                Name = "P5"
            }
                );

            EntitiesController controller = new EntitiesController(repository);

            controller.PageSize = 3;

            var result = controller.List(2);

            Assert.IsNotNull(result, "Didn't render view");

            var entities = result.Entities as IList <Entity>;

            Assert.AreEqual(2, entities.Count, "Got wrong number of products");
            Assert.AreEqual(2, result.CurrentPage, "Wrong page number");
            Assert.AreEqual(2, result.TotalPages, "Wrong page count");

            Assert.AreEqual("P4", entities[0].Name);
            Assert.AreEqual("P5", entities[1].Name);
        }
コード例 #55
0
 public GetEntitiesQueryHandler(IEntitiesRepository entitiesRepository)
 {
     _entitiesRepository = entitiesRepository;
 }
コード例 #56
0
 public EntityMashService(IEntitiesRepository entitiesRepository)
 {
     entitiesRepository_ = entitiesRepository;
 }
コード例 #57
0
 public EntitiesController(IEntitiesRepository repository, IConfiguration configuration)
 {
     _repository    = repository;
     _configuration = configuration;
 }
コード例 #58
0
 public EntitiesInitializer(IUserService userService, IEntitiesRepository entitiesRepository)
 {
     _userService        = userService;
     _entitiesRepository = entitiesRepository;
 }
コード例 #59
0
 public CreateStepTemplateCommandHandler(IEntitiesRepository entitiesRepository, IClusterRequestHandler node, ILogger <CreateStepTemplateCommandHandler> logger)
 {
     _entitiesRepository = entitiesRepository;
     _node  = node;
     Logger = logger;
 }
コード例 #60
0
 public DeleteEntityCommandHandler(IClusterRequestHandler node, IEntitiesRepository entitiesRepository)
 {
     _node = node;
     _entitiesRepository = entitiesRepository;
 }