Esempio n. 1
0
        public ExecutorTestFixture()
        {
            var loggerFactory     = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("IntegrationTests.ExecutorTests.log", null));
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging()
            .AddSingleton(loggerFactory)
            .AddHttpClient()
            .AddSingleton <IConfigurationStore, GenericConfiguration>()
            .AddTransient <IRepository <IProjectEvent>, ProjectRepository>()
            .AddTransient <ICwsProjectClient, CwsProjectClient>()
            .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>()

            // for serviceDiscovery
            .AddServiceDiscovery()
            .AddTransient <IWebRequest, GracefulWebRequest>()
            .AddMemoryCache()
            .AddSingleton <IDataCache, InMemoryDataCache>()

            .AddTransient <IProductivity3dV1ProxyCoord, Productivity3dV1ProxyCoord>()
            .AddTransient <IProductivity3dV2ProxyNotification, Productivity3dV2ProxyNotification>()
            .AddTransient <IProductivity3dV2ProxyCompaction, Productivity3dV2ProxyCompaction>()
            .AddTransient <IErrorCodesProvider, ProjectErrorCodesProvider>();


            _serviceProvider                = serviceCollection.BuildServiceProvider();
            ConfigStore                     = _serviceProvider.GetRequiredService <IConfigurationStore>();
            Logger                          = _serviceProvider.GetRequiredService <ILoggerFactory>();
            ServiceExceptionHandler         = _serviceProvider.GetRequiredService <IServiceExceptionHandler>();
            ProjectRepo                     = _serviceProvider.GetRequiredService <IRepository <IProjectEvent> >() as ProjectRepository;
            CwsProjectClient                = _serviceProvider.GetRequiredService <ICwsProjectClient>();
            Productivity3dV2ProxyCompaction = _serviceProvider.GetRequiredService <IProductivity3dV2ProxyCompaction>();
        }
Esempio n. 2
0
        /// <summary>
        /// Builds this instance for specified executor type.
        /// </summary>
        /// <typeparam name="TExecutor">The type of the executor.</typeparam>
        public static TExecutor Build <TExecutor>(
            ILoggerFactory logger, IConfigurationStore configStore, IServiceExceptionHandler serviceExceptionHandler,
            string customerUid = null, string userId = null, string userEmailAddress = null, IHeaderDictionary headers = null,
            IProductivity3dV1ProxyCoord productivity3dV1ProxyCoord = null, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction = null,
            ITransferProxyFactory persistantTransferProxyFactory   = null, IFilterServiceProxy filterServiceProxy = null, ITRexImportFileProxy tRexImportFileProxy = null,
            IProjectRepository projectRepo        = null, IHttpContextAccessor httpContextAccessor = null, IDataOceanClient dataOceanClient = null,
            ITPaaSApplicationAuthentication authn = null, ISchedulerProxy schedulerProxy           = null, IPegasusClient pegasusClient     = null,
            ICwsProjectClient cwsProjectClient    = null, ICwsDeviceClient cwsDeviceClient         = null,
            ICwsProfileSettingsClient cwsProfileSettingsClient = null,
            IWebRequest gracefulClient = null, INotificationHubClient notificationHubClient = null
            )
            where TExecutor : RequestExecutorContainer, new()
        {
            ILogger log = null;

            if (logger != null)
            {
                log = logger.CreateLogger <RequestExecutorContainer>();
            }

            var executor = new TExecutor();

            executor.Initialise(
                log, configStore, serviceExceptionHandler, customerUid, userId, userEmailAddress, headers,
                productivity3dV1ProxyCoord, productivity3dV2ProxyCompaction,
                persistantTransferProxyFactory, filterServiceProxy, tRexImportFileProxy, projectRepo,
                httpContextAccessor, dataOceanClient, authn, schedulerProxy, pegasusClient, cwsProjectClient, cwsDeviceClient,
                cwsProfileSettingsClient, gracefulClient, notificationHubClient
                );

            return(executor);
        }
Esempio n. 3
0
 private ValidateProjectExecutor CreateExecutor(
     IProductivity3dV1ProxyCoord productivity3dV1ProxyCoord = null,
     ICwsProjectClient cwsProjectClient = null,
     IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction = null) =>
 RequestExecutorContainerFactory.Build <ValidateProjectExecutor>
     (_loggerFactory, _configStore, ServiceExceptionHandler,
     _customerUid.ToString(), _userUid.ToString(), null, _customHeaders,
     productivity3dV1ProxyCoord, cwsProjectClient: cwsProjectClient,
     productivity3dV2ProxyCompaction: productivity3dV2ProxyCompaction);
Esempio n. 4
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        protected BaseController(IConfigurationStore configStore, ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler,
                                 IProjectProxy projectProxy, IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, string eventType)
        {
            Logger = logger;
            Log    = logger.CreateLogger <BaseController>();

            ConfigStore                       = configStore;
            ServiceExceptionHandler           = serviceExceptionHandler;
            ProjectProxy                      = projectProxy;
            Productivity3dV2ProxyNotification = productivity3dV2ProxyNotification;
            Productivity3dV2ProxyCompaction   = productivity3dV2ProxyCompaction;
        }
Esempio n. 5
0
 public ReportController(ILoggerFactory loggerFactory,
                         IServiceExceptionHandler serviceExceptionHandler,
                         IProjectProxy projectProxy,
                         IFileImportProxy fileImportProxy,
                         IFilterServiceProxy filterServiceProxy,
                         IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction)
     : base(loggerFactory, serviceExceptionHandler)
 {
     _projectProxy       = projectProxy;
     _fileImportProxy    = fileImportProxy;
     _filterServiceProxy = filterServiceProxy;
     _productivity3dV2ProxyCompaction = productivity3dV2ProxyCompaction;
 }
Esempio n. 6
0
        //protected IGeofenceProxy GeofenceProxy;
        //protected IUnifiedProductivityProxy UnifiedProductivityProxy;

        public void SetupDI()
        {
            ServiceProvider = new ServiceCollection()
                              .AddLogging()
                              .AddHttpClient()
                              .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Filter.ExecutorTests.log")))
                              .AddSingleton <IConfigurationStore, GenericConfiguration>()
                              .AddTransient <IRepository <IFilterEvent>, FilterRepository>()
                              .AddTransient <IRepository <IProjectEvent>, ProjectRepository>()
                              .AddTransient <IRepository <IGeofenceEvent>, GeofenceRepository>()
                              .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>()

                              // for serviceDiscovery
                              .AddServiceDiscovery()
                              .AddTransient <IWebRequest, GracefulWebRequest>()
                              .AddMemoryCache()
                              .AddSingleton <IDataCache, InMemoryDataCache>()

                              .AddTransient <IAssetResolverProxy, AssetResolverProxy>()
                              .AddTransient <IWebRequest, GracefulWebRequest>()
                              .AddTransient <IProductivity3dV2ProxyNotification, Productivity3dV2ProxyNotification>()
                              .AddTransient <IProductivity3dV2ProxyCompaction, Productivity3dV2ProxyCompaction>()
                              .AddTransient <IErrorCodesProvider, FilterErrorCodesProvider>()
                              .AddSingleton <IDataCache, InMemoryDataCache>()
                              //.AddSingleton<IGeofenceProxy, GeofenceProxy>()
                              //.AddSingleton<IUnifiedProductivityProxy, UnifiedProductivityProxy>()
                              .AddSingleton <IProjectProxy, ProjectV6Proxy>()
                              .AddSingleton <IFileImportProxy, FileImportV6Proxy>()
                              .BuildServiceProvider();

            ConfigStore                       = ServiceProvider.GetRequiredService <IConfigurationStore>();
            Logger                            = ServiceProvider.GetRequiredService <ILoggerFactory>();
            ServiceExceptionHandler           = ServiceProvider.GetRequiredService <IServiceExceptionHandler>();
            FilterRepo                        = ServiceProvider.GetRequiredService <IRepository <IFilterEvent> >() as FilterRepository;
            ProjectRepo                       = ServiceProvider.GetRequiredService <IRepository <IProjectEvent> >() as ProjectRepository;
            GeofenceRepo                      = ServiceProvider.GetRequiredService <IRepository <IGeofenceEvent> >() as GeofenceRepository;
            ProjectProxy                      = ServiceProvider.GetRequiredService <IProjectProxy>();
            FileImportProxy                   = ServiceProvider.GetRequiredService <IFileImportProxy>();
            Productivity3dV2ProxyNotification = ServiceProvider.GetRequiredService <IProductivity3dV2ProxyNotification>();
            Productivity3dV2ProxyCompaction   = ServiceProvider.GetRequiredService <IProductivity3dV2ProxyCompaction>();
            //GeofenceProxy = ServiceProvider.GetRequiredService<IGeofenceProxy>();
            //UnifiedProductivityProxy = ServiceProvider.GetRequiredService<IUnifiedProductivityProxy>();

            Assert.IsNotNull(ServiceProvider.GetService <ILoggerFactory>());
        }
Esempio n. 7
0
        // It is likely we have a combination of filters stored for a project.
        // Older ones will have legacyAssetId (assetUid = null) and more recent ones will have AssetUid (legacyAssetID == -1)
        private static async Task PairUpAssetIdentifiers(string projectUid, List <MachineDetails> machines,
                                                         IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, IHeaderDictionary customHeaders)
        {
            if (machines == null || !machines.Any())
            {
                return;
            }

            var route     = $"/projects/{projectUid}/machines";
            var assetList = await productivity3dV2ProxyCompaction.ExecuteGenericV2Request <MachineExecutionResult>(route, HttpMethod.Get, null, customHeaders);

            foreach (var assetMatch in assetList.MachineStatuses)
            {
                foreach (var assetOnDesignPeriod in machines.FindAll(a => a.AssetUid == assetMatch.AssetUid))
                {
                    assetOnDesignPeriod.AssetId = assetMatch.AssetId;
                }
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Injected constructor for mocking Raptor client.
 /// </summary>
 protected RequestExecutorContainer(IConfigurationStore configStore,
                                    ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler,
                                    IProjectProxy projectProxy,
                                    IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction,
                                    IFileImportProxy fileImportProxy, RepositoryBase repository,
                                    RepositoryBase auxRepository /*, IGeofenceProxy geofenceProxy, IUnifiedProductivityProxy unifiedProductivityProxy */) : this()
 {
     this.configStore = configStore;
     if (logger != null)
     {
         log = logger.CreateLogger <RequestExecutorContainer>();
     }
     this.serviceExceptionHandler      = serviceExceptionHandler;
     this.projectProxy                 = projectProxy;
     Productivity3dV2ProxyNotification = productivity3dV2ProxyNotification;
     Productivity3dV2ProxyCompaction   = productivity3dV2ProxyCompaction;
     Repository           = repository;
     this.auxRepository   = auxRepository;
     this.fileImportProxy = fileImportProxy;
     //GeofenceProxy = geofenceProxy;
     //UnifiedProductivityProxy = unifiedProductivityProxy;
 }
Esempio n. 9
0
 public void Initialise(ILogger logger, IConfigurationStore configStore,
                        IServiceExceptionHandler serviceExceptionHandler,
                        string customerUid, string userId = null, string userEmailAddress = null,
                        IHeaderDictionary headers         = null,
                        IProductivity3dV1ProxyCoord productivity3dV1ProxyCoord           = null,
                        IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction = null,
                        ITransferProxyFactory persistantTransferProxyFactory             = null, IFilterServiceProxy filterServiceProxy = null,
                        ITRexImportFileProxy tRexImportFileProxy           = null, IProjectRepository projectRepo = null,
                        IHttpContextAccessor httpContextAccessor           = null,
                        IDataOceanClient dataOceanClient                   = null, ITPaaSApplicationAuthentication authn = null,
                        ISchedulerProxy schedulerProxy                     = null, IPegasusClient pegasusClient          = null,
                        ICwsProjectClient cwsProjectClient                 = null, ICwsDeviceClient cwsDeviceClient      = null,
                        ICwsProfileSettingsClient cwsProfileSettingsClient = null,
                        IWebRequest gracefulClient = null, INotificationHubClient notificationHubClient = null)
 {
     log = logger;
     this.configStore             = configStore;
     this.serviceExceptionHandler = serviceExceptionHandler;
     this.customerUid             = customerUid;
     this.userId                          = userId;
     this.userEmailAddress                = userEmailAddress;
     this.customHeaders                   = headers;
     this.productivity3dV1ProxyCoord      = productivity3dV1ProxyCoord;
     this.productivity3dV2ProxyCompaction = productivity3dV2ProxyCompaction;
     this.persistantTransferProxyFactory  = persistantTransferProxyFactory;
     this.filterServiceProxy              = filterServiceProxy;
     this.tRexImportFileProxy             = tRexImportFileProxy;
     this.projectRepo                     = projectRepo;
     this.httpContextAccessor             = httpContextAccessor;
     this.dataOceanClient                 = dataOceanClient;
     this.authn                    = authn;
     this.schedulerProxy           = schedulerProxy;
     this.pegasusClient            = pegasusClient;
     this.cwsProjectClient         = cwsProjectClient;
     this.cwsDeviceClient          = cwsDeviceClient;
     this.cwsProfileSettingsClient = cwsProfileSettingsClient;
     this.gracefulClient           = gracefulClient;
     this.notificationHubClient    = notificationHubClient;
 }
Esempio n. 10
0
        public static async Task ParseFilterJson(ProjectData project, IEnumerable <DbFilter> filters, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, IHeaderDictionary customHeaders)
        {
            if (filters == null)
            {
                return;
            }

            foreach (var filter in filters)
            {
                await FixupFilterValues(project, filter, productivity3dV2ProxyCompaction, customHeaders);
            }
        }
Esempio n. 11
0
        public static async Task ParseFilterJson(ProjectData project, FilterDescriptor filter, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, IHeaderDictionary customHeaders)
        {
            if (filter == null)
            {
                return;
            }

            var processFilterJson = await ProcessFilterJson(project, filter.FilterJson, productivity3dV2ProxyCompaction, customHeaders);

            filter.FilterJson       = processFilterJson.filterJson;
            filter.ContainsBoundary = processFilterJson.containsBoundary;
        }
Esempio n. 12
0
        Build <TExecutor>(IConfigurationStore configStore,
                          ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler,
                          RepositoryBase repository, RepositoryBase auxRepository,
                          IProjectProxy projectProxy = null,
                          IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification = null, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction = null,
                          IFileImportProxy fileImportProxy = null /*, IGeofenceProxy geofenceProxy = null,
                                                                   * IUnifiedProductivityProxy unifiedProductivityProxy = null  */
                          )
            where TExecutor : RequestExecutorContainer, new()
        {
            var executor = new TExecutor
            {
                configStore                       = configStore,
                log                               = logger.CreateLogger <TExecutor>(),
                serviceExceptionHandler           = serviceExceptionHandler,
                projectProxy                      = projectProxy,
                Productivity3dV2ProxyNotification = productivity3dV2ProxyNotification,
                Productivity3dV2ProxyCompaction   = productivity3dV2ProxyCompaction,
                fileImportProxy                   = fileImportProxy,
                Repository                        = repository,
                auxRepository                     = auxRepository,
                //GeofenceProxy = geofenceProxy,
                //UnifiedProductivityProxy = unifiedProductivityProxy
            };

            return(executor);
        }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterController"/> class.
 /// </summary>
 public FilterController(IConfigurationStore configStore, ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler,
                         IProjectProxy projectProxy,
                         IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction,
                         IRepository <IFilterEvent> filterRepo, IRepository <IGeofenceEvent> geofenceRepo)
     : base(configStore, logger, serviceExceptionHandler, projectProxy, productivity3dV2ProxyNotification, productivity3dV2ProxyCompaction, "IFilterEvent")
 {
     Log                = logger.CreateLogger <FilterController>();
     this.filterRepo    = filterRepo as FilterRepository;
     geofenceRepository = geofenceRepo as GeofenceRepository;
 }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BoundaryController"/> class.
 /// </summary>
 public BoundaryController(IConfigurationStore configStore, ILoggerFactory logger,
                           IServiceExceptionHandler serviceExceptionHandler, IProjectProxy projectProxy,
                           IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction,
                           IRepository <IGeofenceEvent> geofenceRepo,
                           IRepository <IProjectEvent> projectRepo)
     : base(configStore, logger, serviceExceptionHandler, projectProxy, productivity3dV2ProxyNotification, productivity3dV2ProxyCompaction, "IBoundaryEvent")
 {
     Log = logger.CreateLogger <BoundaryController>();
     _geofenceRepository = geofenceRepo as GeofenceRepository;
     _projectRepository  = projectRepo as ProjectRepository;
 }
Esempio n. 15
0
 /// <summary>
 /// This constructor allows us to mock raptorClient
 /// </summary>
 public GetFiltersExecutor(IConfigurationStore configStore, ILoggerFactory logger,
                           IServiceExceptionHandler serviceExceptionHandler,
                           IProjectProxy projectProxy,
                           IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction,
                           IFileImportProxy fileImportProxy,
                           RepositoryBase repository)
     : base(configStore, logger, serviceExceptionHandler, projectProxy, productivity3dV2ProxyNotification, productivity3dV2ProxyCompaction, fileImportProxy, repository, null /*, null, null*/)
 {
 }
Esempio n. 16
0
 /// <summary>
 /// This constructor allows us to mock raptorClient
 /// </summary>
 public UpsertFilterExecutor(IConfigurationStore configStore, ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler,
                             IProjectProxy projectProxy,
                             IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction,
                             IFileImportProxy fileImportProxy,
                             RepositoryBase repository, RepositoryBase auxRepository /*, IGeofenceProxy geofenceProxy */)
     : base(configStore, logger, serviceExceptionHandler, projectProxy, productivity3dV2ProxyNotification, productivity3dV2ProxyCompaction, fileImportProxy, repository, auxRepository /*, geofenceProxy, null*/)
 {
 }
Esempio n. 17
0
        public static async Task ParseFilterJson(ProjectData project, DbFilter filter, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, IHeaderDictionary customHeaders)
        {
            if (filter == null)
            {
                return;
            }

            await FixupFilterValues(project, filter, productivity3dV2ProxyCompaction, customHeaders);
        }
Esempio n. 18
0
        private static async Task FixupFilterValues(ProjectData project, DbFilter filter, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, IHeaderDictionary customHeaders)
        {
            var processFilterJson = await ProcessFilterJson(project, filter.FilterJson, productivity3dV2ProxyCompaction, customHeaders);

            filter.FilterJson = processFilterJson.filterJson;
        }
Esempio n. 19
0
        private static async Task <(string filterJson, bool containsBoundary)> ProcessFilterJson(ProjectData project, string filterJson,
                                                                                                 IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, IHeaderDictionary customHeaders)
        {
            var filterObj = JsonConvert.DeserializeObject <Abstractions.Models.Filter>(filterJson);

            // date timezone changes
            filterObj.ApplyDateRange(project?.IanaTimeZone);

            if (filterObj.DateRangeType == DateRangeType.ProjectExtents)
            {
                // get project productionData data extents from 3dpm
                var statistics = productivity3dV2ProxyCompaction?.GetProjectStatistics(Guid.Parse(project?.ProjectUID), customHeaders).Result;
                filterObj.StartUtc = statistics?.startTime;
                filterObj.EndUtc   = statistics?.endTime;
            }

            // The UI needs to know the start date for specified ranges, this is actually the range data will be returned for
            if (filterObj.AsAtDate == true)
            {
                var statistics = productivity3dV2ProxyCompaction?.GetProjectStatistics(Guid.Parse(project?.ProjectUID), customHeaders).Result;
                filterObj.StartUtc      = statistics?.startTime;
                filterObj.DateRangeType = DateRangeType.Custom;
            }

            // pair up AssetUids and legacyAssetIds in contributingMachines
            await PairUpAssetIdentifiers(project?.ProjectUID, filterObj.ContributingMachines, productivity3dV2ProxyCompaction, customHeaders);

            return(JsonConvert.SerializeObject(filterObj), filterObj.ContainsBoundary);
        }