Example #1
0
 public GetPersonsQueryHandler(
     IPersonApiService personApiService,
     IPlantProvider plantProvider)
 {
     _plantProvider    = plantProvider;
     _personApiService = personApiService;
 }
        public void SetupBase()
        {
            _plantProviderMock = new Mock <IPlantProvider>();
            _plantProviderMock.SetupGet(x => x.Plant).Returns(TestPlant);
            _plantProvider = _plantProviderMock.Object;

            var currentUserProviderMock = new Mock <ICurrentUserProvider>();

            currentUserProviderMock.Setup(x => x.GetCurrentUserOid()).Returns(_currentUserOid);
            _currentUserProvider = currentUserProviderMock.Object;

            var eventDispatcher = new Mock <IEventDispatcher>();

            _eventDispatcher = eventDispatcher.Object;

            _timeProvider = new ManualTimeProvider(new DateTime(2020, 2, 1, 0, 0, 0, DateTimeKind.Utc));
            TimeService.SetProvider(_timeProvider);

            _dbContextOptions = new DbContextOptionsBuilder <POContext>()
                                .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                .Options;

            // ensure current user exists in db
            using (var context = new POContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                if (context.Persons.SingleOrDefault(p => p.Oid == _currentUserOid) == null)
                {
                    AddPerson(context, _currentUserOid, "Ole", "Lukkøye");
                }
            }

            SetupNewDatabase(_dbContextOptions);
        }
Example #3
0
 public GetMcPkgsUnderCommPkgInProjectQueryHandler(
     IMcPkgApiService mcPkgApiService,
     IPlantProvider plantProvider)
 {
     _plantProvider   = plantProvider;
     _mcPkgApiService = mcPkgApiService;
 }
Example #4
0
 public GetProjectsInPlantQueryHandler(
     IProjectApiService projectApiService,
     IPlantProvider plantProvider)
 {
     _plantProvider     = plantProvider;
     _projectApiService = projectApiService;
 }
Example #5
0
 public GetInvitationsForExportQueryHandler(IReadOnlyContext context, IPlantProvider plantProvider, IPersonRepository personRepository)
 {
     _context          = context;
     _plantProvider    = plantProvider;
     _personRepository = personRepository;
     _utcNow           = TimeService.UtcNow;
 }
 public GetCommPkgsInProjectQueryHandler(
     ICommPkgApiService commPkgApiService,
     IPlantProvider plantProvider)
 {
     _plantProvider     = plantProvider;
     _commPkgApiService = commPkgApiService;
 }
 public GetFunctionalRolesForIpoQueryHandler(
     IFunctionalRoleApiService functionalRoleApiService,
     IPlantProvider plantProvider)
 {
     _plantProvider            = plantProvider;
     _functionalRoleApiService = functionalRoleApiService;
 }
 public CreateInvitationCommandHandler(
     IPlantProvider plantProvider,
     IFusionMeetingClient meetingClient,
     IInvitationRepository invitationRepository,
     IUnitOfWork unitOfWork,
     ICommPkgApiService commPkgApiService,
     IMcPkgApiService mcPkgApiService,
     IPersonApiService personApiService,
     IFunctionalRoleApiService functionalRoleApiService,
     IOptionsMonitor <MeetingOptions> meetingOptions,
     IPersonRepository personRepository,
     ICurrentUserProvider currentUserProvider,
     ILogger <CreateInvitationCommandHandler> logger)
 {
     _plantProvider            = plantProvider;
     _meetingClient            = meetingClient;
     _invitationRepository     = invitationRepository;
     _unitOfWork               = unitOfWork;
     _commPkgApiService        = commPkgApiService;
     _mcPkgApiService          = mcPkgApiService;
     _personApiService         = personApiService;
     _functionalRoleApiService = functionalRoleApiService;
     _meetingOptions           = meetingOptions;
     _personRepository         = personRepository;
     _currentUserProvider      = currentUserProvider;
     _logger = logger;
 }
Example #9
0
 public ProjectChecker(IPlantProvider plantProvider,
                       ICurrentUserProvider currentUserProvider,
                       IPermissionCache permissionCache)
 {
     _plantProvider       = plantProvider;
     _currentUserProvider = currentUserProvider;
     _permissionCache     = permissionCache;
 }
 public PreservationContext(
     DbContextOptions <PreservationContext> options,
     IEventDispatcher eventDispatcher,
     IPlantProvider plantProvider)
     : base(options)
 {
     this.eventDispatcher = eventDispatcher;
     this.plantProvider   = plantProvider;
 }
 public AddCommentCommandHandler(
     IPlantProvider plantProvider,
     IInvitationRepository invitationRepository,
     IUnitOfWork unitOfWork)
 {
     _plantProvider        = plantProvider;
     _invitationRepository = invitationRepository;
     _unitOfWork           = unitOfWork;
 }
 public LibraryContext(
     DbContextOptions <LibraryContext> options,
     IEventDispatcher eventDispatcher,
     IPlantProvider plantProvider)
     : base(options)
 {
     _eventDispatcher = eventDispatcher;
     _plantProvider   = plantProvider;
 }
 public UpdateRequirementDefinitionCommandHandler(
     IRequirementTypeRepository requirementTypeRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider)
 {
     _requirementTypeRepository = requirementTypeRepository;
     _unitOfWork    = unitOfWork;
     _plantProvider = plantProvider;
 }
Example #14
0
        public static async Task <bool> HasIpoAdminPrivilege(
            IPermissionCache permissionCache,
            IPlantProvider plantProvider,
            ICurrentUserProvider currentUserProvider)
        {
            var permissions = await permissionCache.GetPermissionsForUserAsync(plantProvider.Plant, currentUserProvider.GetCurrentUserOid());

            return(permissions != null && permissions.Contains("IPO/ADMIN"));
        }
 public GetOutstandingIposForCurrentPersonQueryHandler(
     IReadOnlyContext context,
     ICurrentUserProvider currentUserProvider,
     IMeApiService meApiService,
     IPlantProvider plantProvider)
 {
     _context             = context;
     _currentUserProvider = currentUserProvider;
     _meApiService        = meApiService;
     _plantProvider       = plantProvider;
 }
 public PreservationContext(
     DbContextOptions <PreservationContext> options,
     IPlantProvider plantProvider,
     IEventDispatcher eventDispatcher,
     ICurrentUserProvider currentUserProvider)
     : base(options)
 {
     _plantProvider       = plantProvider;
     _eventDispatcher     = eventDispatcher;
     _currentUserProvider = currentUserProvider;
 }
 public ClaimsTransformation(
     IPlantProvider plantProvider,
     IPlantCache plantCache,
     IPermissionCache permissionCache,
     ILogger <ClaimsTransformation> logger)
 {
     _plantProvider   = plantProvider;
     _plantCache      = plantCache;
     _permissionCache = permissionCache;
     _logger          = logger;
 }
Example #18
0
 public InvitationValidator(IReadOnlyContext context,
                            ICurrentUserProvider currentUserProvider,
                            IPersonApiService personApiService,
                            IPlantProvider plantProvider,
                            IPermissionCache permissionCache)
 {
     _context             = context;
     _currentUserProvider = currentUserProvider;
     _personApiService    = personApiService;
     _plantProvider       = plantProvider;
     _permissionCache     = permissionCache;
 }
Example #19
0
 public UploadTagAttachmentCommandHandler(
     IProjectRepository projectRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider,
     IBlobStorage blobStorage, IOptionsMonitor <AttachmentOptions> attachmentOptions)
 {
     _projectRepository = projectRepository;
     _unitOfWork        = unitOfWork;
     _plantProvider     = plantProvider;
     _blobStorage       = blobStorage;
     _attachmentOptions = attachmentOptions;
 }
 public UnAcceptPunchOutCommandHandler(IInvitationRepository invitationRepository,
                                       IUnitOfWork unitOfWork,
                                       ICurrentUserProvider currentUserProvider,
                                       IPlantProvider plantProvider,
                                       IPermissionCache permissionCache)
 {
     _invitationRepository = invitationRepository;
     _unitOfWork           = unitOfWork;
     _currentUserProvider  = currentUserProvider;
     _plantProvider        = plantProvider;
     _permissionCache      = permissionCache;
 }
 public UpdateRequirementsCommandHandler(
     ITagFunctionRepository tagFunctionRepository,
     IRequirementTypeRepository requirementTypeRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider,
     ITagFunctionApiService tagFunctionApiService)
 {
     _tagFunctionRepository     = tagFunctionRepository;
     _requirementTypeRepository = requirementTypeRepository;
     _unitOfWork            = unitOfWork;
     _plantProvider         = plantProvider;
     _tagFunctionApiService = tagFunctionApiService;
 }
Example #22
0
 public UploadAttachmentCommandHandler(
     IInvitationRepository invitationRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider,
     IBlobStorage blobStorage,
     IOptionsMonitor <BlobStorageOptions> blobStorageOptions)
 {
     _invitationRepository = invitationRepository;
     _unitOfWork           = unitOfWork;
     _plantProvider        = plantProvider;
     _blobStorage          = blobStorage;
     _blobStorageOptions   = blobStorageOptions;
 }
Example #23
0
 public DuplicateJourneyCommandHandler(
     IJourneyRepository journeyRepository,
     IModeRepository modeRepository,
     IResponsibleRepository responsibleRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider)
 {
     _journeyRepository     = journeyRepository;
     _modeRepository        = modeRepository;
     _responsibleRepository = responsibleRepository;
     _unitOfWork            = unitOfWork;
     _plantProvider         = plantProvider;
 }
 public UpdateTagStepAndRequirementsCommandHandler(
     IProjectRepository projectRepository,
     IJourneyRepository journeyRepository,
     IRequirementTypeRepository requirementTypeRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider)
 {
     _projectRepository         = projectRepository;
     _journeyRepository         = journeyRepository;
     _requirementTypeRepository = requirementTypeRepository;
     _unitOfWork    = unitOfWork;
     _plantProvider = plantProvider;
 }
 public UpdateAttendedStatusAndNotesOnParticipantsCommandHandler(
     IPlantProvider plantProvider,
     IInvitationRepository invitationRepository,
     IUnitOfWork unitOfWork,
     ICurrentUserProvider currentUserProvider,
     IPersonApiService personApiService)
 {
     _plantProvider        = plantProvider;
     _invitationRepository = invitationRepository;
     _unitOfWork           = unitOfWork;
     _currentUserProvider  = currentUserProvider;
     _personApiService     = personApiService;
 }
 public CreateSavedFilterCommandHandler(
     IPersonRepository personRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider,
     ICurrentUserProvider currentUserProvider,
     IProjectRepository projectRepository)
 {
     _personRepository    = personRepository;
     _unitOfWork          = unitOfWork;
     _plantProvider       = plantProvider;
     _currentUserProvider = currentUserProvider;
     _projectRepository   = projectRepository;
 }
 public GetInvitationByIdQueryHandler(IReadOnlyContext context,
                                      IFusionMeetingClient meetingClient,
                                      ICurrentUserProvider currentUserProvider,
                                      IFunctionalRoleApiService functionalRoleApiService,
                                      IPlantProvider plantProvider,
                                      ILogger <GetInvitationByIdQueryHandler> logger)
 {
     _context                  = context;
     _meetingClient            = meetingClient;
     _currentUserProvider      = currentUserProvider;
     _functionalRoleApiService = functionalRoleApiService;
     _plantProvider            = plantProvider;
     _logger = logger;
 }
Example #28
0
 public UploadFieldValueAttachmentCommandHandler(
     IProjectRepository projectRepository,
     IRequirementTypeRepository requirementTypeRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider,
     IBlobStorage blobStorage,
     IOptionsMonitor <AttachmentOptions> attachmentOptions)
 {
     _projectRepository         = projectRepository;
     _unitOfWork                = unitOfWork;
     _plantProvider             = plantProvider;
     _blobStorage               = blobStorage;
     _attachmentOptions         = attachmentOptions;
     _requirementTypeRepository = requirementTypeRepository;
 }
Example #29
0
 public UnCompletePunchOutCommandHandler(
     IPlantProvider plantProvider,
     IInvitationRepository invitationRepository,
     IUnitOfWork unitOfWork,
     ICurrentUserProvider currentUserProvider,
     IMcPkgApiService mcPkgApiService,
     IPermissionCache permissionCache)
 {
     _plantProvider        = plantProvider;
     _invitationRepository = invitationRepository;
     _unitOfWork           = unitOfWork;
     _currentUserProvider  = currentUserProvider;
     _mcPkgApiService      = mcPkgApiService;
     _permissionCache      = permissionCache;
 }
Example #30
0
 public CreateStepCommandHandler(
     IJourneyRepository journeyRepository,
     IModeRepository modeRepository,
     IResponsibleRepository responsibleRepository,
     IUnitOfWork unitOfWork,
     IPlantProvider plantProvider,
     IResponsibleApiService responsibleApiService)
 {
     _journeyRepository     = journeyRepository;
     _modeRepository        = modeRepository;
     _responsibleRepository = responsibleRepository;
     _unitOfWork            = unitOfWork;
     _plantProvider         = plantProvider;
     _responsibleApiService = responsibleApiService;
 }
Example #31
0
        /// <summary>
        /// Creates a new <see cref="Web"/> object using a given provider and listen address.
        /// </summary>
        /// <param name="blockProvider">Provider for blocks to use.</param>
        /// <param name="url">Address that the server listens on.</param>
        public WebServer(IBlockProvider blockProvider, IAnimalProvider animalProvider, IPlantProvider plantProvider, string url, string webRoot)
        {
            if (blockProvider == null)
                throw new ArgumentNullException(nameof(blockProvider));
            if (animalProvider == null)
                throw new ArgumentNullException(nameof(animalProvider));
            if (plantProvider == null)
                throw new ArgumentNullException(nameof(plantProvider));

            if (Instance != null)
                throw new InvalidOperationException(nameof(WebServer) + " is a singleton class and may not be instantiated multiple times.");

            Instance = this;

            // Set the providers
            BlockProvider = blockProvider;
            AnimalProvider = animalProvider;
            PlantProvider = plantProvider;

            try
            {
                // Start the server (/Katana/OWIN pipeline)
                var options = new StartOptions();
                options.Urls.Add(url);
                _webServer = WebApp.Start(url, (app) => new Web.Startup(webRoot).Configuration(app));
            }
            catch (System.Reflection.TargetInvocationException ex)
            {
                // Because those exceptions usually are not helpful ("an invocation target has something something"), we'll rather throw the inner exception
                if (ex.InnerException == null)
                    throw;

                System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
            }

            // Get the hub contexts
            _mapHubContext = GlobalHost.ConnectionManager.GetHubContext<Web.MapHub>();
        }