Beispiel #1
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);
        }
Beispiel #2
0
 public SendEmailJob(IJobRunner jobRunner, ITPaaSApplicationAuthentication authn, ITpaasEmailProxy emailProxy, ILoggerFactory logger)
 {
     _log        = logger.CreateLogger <SendEmailJob>();
     _jobRunner  = jobRunner;
     _authn      = authn;
     _tpaasEmail = emailProxy;
 }
Beispiel #3
0
 public TagFileDispatchSvc(ITPaaSApplicationAuthentication authn, ILoggerFactory logFactory, IConfigurationStore config, ITRexTagFileProxy serviceProxy)
 {
     _log          = logFactory.CreateLogger <TagFileDispatchSvc>();
     _authn        = authn;
     _config       = config;
     _serviceProxy = serviceProxy;
     _path         = Path.Combine(_config.GetValueString("InstallFolder"), TagConstants.TAGFILE_FOLDER);
 }
Beispiel #4
0
 public TileGenerationJob(IConfigurationStore configurationStore, IPegasusClient pegasusClient, ITPaaSApplicationAuthentication authn, INotificationHubClient notificationHubClient, ILoggerFactory logger)
 {
     configStore                = configurationStore;
     this.pegasusClient         = pegasusClient;
     authentication             = authn;
     this.notificationHubClient = notificationHubClient;
     log = logger.CreateLogger <DxfTileGenerationJob>();
 }
Beispiel #5
0
 public ImportFile(ILoggerFactory loggerFactory, ITPaaSApplicationAuthentication authentication, IRestClient restClient, ILiteDbAgent databaseAgent, IEnvironmentHelper environmentHelper)
 {
     _log         = loggerFactory.CreateLogger <ImportFile>();
     _bearerToken = "Bearer " + authentication.GetApplicationBearerToken();
     _jwtToken    = environmentHelper.GetVariable("JWT_TOKEN", 1);
     _restClient  = restClient;
     _database    = databaseAgent;
     _maxFileSize = int.Parse(environmentHelper.GetVariable("MAX_FILE_SIZE", 1));
 }
Beispiel #6
0
        public RestClient(ILoggerFactory loggerFactory, ITPaaSApplicationAuthentication authentication, IEnvironmentHelper environmentHelper)
        {
            _log = loggerFactory.CreateLogger <HttpClient>();
            _log.LogInformation(Method.In());

            _bearerToken = authentication.GetApplicationBearerToken();
            _jwtToken    = environmentHelper.GetVariable("JWT_TOKEN", 1);

            _httpClient = new HttpClient();
            _httpClient.DefaultRequestHeaders.Add("pragma", "no-cache");
        }
Beispiel #7
0
        /// <summary>
        /// Writes the importedFile to DataOcean as a create or update,
        ///       if it already exists, old version will be deleted first.
        /// </summary>
        public static async Task WriteFileToDataOcean(
            Stream fileContents, string rootFolder, string customerUid, string projectUid, string dataOceanFileName,
            ILogger log, IServiceExceptionHandler serviceExceptionHandler, IDataOceanClient dataOceanClient,
            ITPaaSApplicationAuthentication authn, Guid fileUid, IConfigurationStore configStore)
        {
            var dataOceanEnabled = configStore.GetValueBool("ENABLE_DATA_OCEAN", false);

            if (dataOceanEnabled)
            {
                if (!dataOceanFileName.StartsWith(fileUid.ToString()))
                {
                    throw new ServiceException(HttpStatusCode.InternalServerError,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
                                                                           $"Invalid DataOcean file name {dataOceanFileName}"));
                }

                var customHeaders = authn.CustomHeaders();
                var dataOceanPath = DataOceanFileUtil.DataOceanPath(rootFolder, customerUid, projectUid);

                var ccPutFileResult     = false;
                var folderAlreadyExists = false;

                try
                {
                    log.LogInformation($"{nameof(WriteFileToDataOcean)}: dataOceanPath: '{dataOceanPath}', dataOceanFileName: '{dataOceanFileName}'");

                    folderAlreadyExists = await dataOceanClient.FolderExists(dataOceanPath, customHeaders);

                    if (!folderAlreadyExists)
                    {
                        await dataOceanClient.MakeFolder(dataOceanPath, customHeaders);
                    }

                    ccPutFileResult = await dataOceanClient.PutFile(dataOceanPath, dataOceanFileName, fileContents, customHeaders);
                }
                catch (Exception e)
                {
                    serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 57, "dataOceanClient.PutFile",
                                                                  e.Message);
                }

                if (!ccPutFileResult)
                {
                    serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 116);
                }

                log.LogInformation($"{nameof(WriteFileToDataOcean)}: dataOceanFileName '{dataOceanFileName}' written to DataOcean, folderAlreadyExists: {folderAlreadyExists}");
            }
            else
            {
                log.LogInformation($"{nameof(WriteFileToDataOcean)}: File not saved. DataOcean disabled");
            }
        }
Beispiel #8
0
 public void Initialise(ILogger logger, IConfigurationStore configStore,
                        IHeaderDictionary customHeaders, IDataOceanClient dataOceanClient,
                        ITPaaSApplicationAuthentication authn, IProductivity3dV2ProxyCompactionTile productivity3DProxyCompactionTile, IBoundingBoxHelper bboxHelper)
 {
     log = logger;
     this.configStore     = configStore;
     this.customHeaders   = customHeaders;
     this.dataOceanClient = dataOceanClient;
     this.authn           = authn;
     this.productivity3DProxyCompactionTile = productivity3DProxyCompactionTile;
     this.bboxHelper = bboxHelper;
 }
Beispiel #9
0
 public MachinePassesExport(IProjectProxy projectyProxy, IFilterServiceProxy filterProxy,
                            IJobRunner jobRunner, ITPaaSApplicationAuthentication authn,
                            ILoggerFactory logger, IServiceResolution serviceResolution, IExportEmailGenerator emailGenerator)
 {
     log                    = logger.CreateLogger <MachinePassesExport>();
     projects               = projectyProxy;
     filters                = filterProxy;
     this.jobRunner         = jobRunner;
     this.authn             = authn;
     this.serviceResolution = serviceResolution;
     exportEmailGenerator   = emailGenerator;
 }
Beispiel #10
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 protected BaseController(IProductivity3dV2ProxyCompactionTile productivity3DProxyCompactionTile, IPreferenceProxy prefProxy, IFileImportProxy fileImportProxy,
                          IMapTileGenerator tileGenerator, IMemoryCache cache, IConfigurationStore configurationStore,
                          IBoundingBoxHelper boundingBoxHelper, ITPaaSApplicationAuthentication authn)
 {
     this.productivity3DProxyCompactionTile = productivity3DProxyCompactionTile;
     this.prefProxy         = prefProxy;
     this.fileImportProxy   = fileImportProxy;
     this.tileGenerator     = tileGenerator;
     tileCache              = cache;
     tileCacheExpiration    = GetCacheExpiration(configurationStore);
     configStore            = configurationStore;
     this.boundingBoxHelper = boundingBoxHelper;
     this.authn             = authn;
 }
Beispiel #11
0
        public DataRepository(ILogger log, ITPaaSApplicationAuthentication authorization,
                              IProjectInternalProxy projectProxy, IDeviceInternalProxy deviceProxy, ITRexCompactionDataProxy tRexCompactionDataProxy,
                              IHeaderDictionary requestCustomHeaders)
        {
            _log                     = log;
            _projectProxy            = projectProxy;
            _deviceProxy             = deviceProxy;
            _tRexCompactionDataProxy = tRexCompactionDataProxy;
            _mergedCustomHeaders     = requestCustomHeaders;

            foreach (var header in authorization.CustomHeaders())
            {
                _mergedCustomHeaders.Add(header);
            }
        }
Beispiel #12
0
        public DxfTileService(IConfigurationStore configuration, IDataOceanClient dataOceanClient, ILoggerFactory logger, ITPaaSApplicationAuthentication authn)
        {
            config = configuration;
            this.dataOceanClient = dataOceanClient;
            log        = logger.CreateLogger <DxfTileService>();
            this.authn = authn;

            const string DATA_OCEAN_ROOT_FOLDER_ID_KEY = "DATA_OCEAN_ROOT_FOLDER_ID";

            dataOceanRootFolder = configuration.GetValueString(DATA_OCEAN_ROOT_FOLDER_ID_KEY);
            if (string.IsNullOrEmpty(dataOceanRootFolder))
            {
                throw new ArgumentException($"Missing environment variable {DATA_OCEAN_ROOT_FOLDER_ID_KEY}");
            }
        }
Beispiel #13
0
        /// <summary>
        /// Builds this instance for specified executor type.
        /// </summary>
        /// <typeparam name="TExecutor">The type of the executor.</typeparam>
        /// <typeparam name="TLog">The type of the logger.</typeparam>
        public static TExecutor Build <TExecutor, TLog>(ILogger <TLog> logger, IConfigurationStore configStore = null,
                                                        IHeaderDictionary customHeaders       = null, IDataOceanClient dataOceanClient = null,
                                                        ITPaaSApplicationAuthentication authn = null, IProductivity3dV2ProxyCompactionTile productivity3DProxyCompactionTile = null, IBoundingBoxHelper bboxHelper = null)
            where TExecutor : RequestExecutorContainer, new()
        {
            ILogger log      = logger;
            var     executor = new TExecutor();

            executor.Initialise(
                log,
                configStore,
                customHeaders,
                dataOceanClient,
                authn,
                productivity3DProxyCompactionTile,
                bboxHelper);

            return(executor);
        }
Beispiel #14
0
        /// <summary>
        /// Deletes the importedFile from DataOcean
        /// </summary>
        public static async Task <ImportedFileInternalResult> DeleteFileFromDataOcean(
            string fileName, string rootFolder, string customerUid, Guid projectUid, Guid importedFileUid,
            ILogger log, IDataOceanClient dataOceanClient, ITPaaSApplicationAuthentication authn, IConfigurationStore configStore)
        {
            var dataOceanEnabled = configStore.GetValueBool("ENABLE_DATA_OCEAN", false);

            if (dataOceanEnabled)
            {
                var dataOceanPath = DataOceanFileUtil.DataOceanPath(rootFolder, customerUid, projectUid.ToString());
                var fullFileName  = $"{dataOceanPath}{Path.DirectorySeparatorChar}{fileName}";
                log.LogInformation($"{nameof(DeleteFileFromDataOcean)}: fullFileName {JsonConvert.SerializeObject(fullFileName)}");

                var  customHeaders = authn.CustomHeaders();
                bool ccDeleteFileResult;

                try
                {
                    ccDeleteFileResult = await dataOceanClient.DeleteFile(fullFileName, customHeaders);
                }
                catch (Exception e)
                {
                    log.LogError(e, $"{nameof(DeleteFileFromDataOcean)}: failed for {fileName} (importedFileUid:{importedFileUid}) with exception {e.Message}");
                    return(ImportedFileInternalResult.CreateImportedFileInternalResult(HttpStatusCode.InternalServerError, 57, "dataOceanClient.DeleteFile", e.Message));
                }

                if (!ccDeleteFileResult)
                {
                    log.LogWarning(
                        $"{nameof(DeleteFileFromDataOcean)}: failed to delete {fileName} (importedFileUid:{importedFileUid}).");
                    //Not an error if it doesn't delete the file?
                    //return ImportedFileInternalResult.CreateImportedFileInternalResult(HttpStatusCode.InternalServerError, 117);
                }
            }
            else
            {
                log.LogInformation($"{nameof(DeleteFileFromDataOcean)}: File not deleted. DataOcean disabled");
            }

            return(null);
        }
Beispiel #15
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;
 }
Beispiel #16
0
 public static IHeaderDictionary CustomHeaders(ITPaaSApplicationAuthentication authn) => new HeaderDictionary
 {
     { "Content-Type", ContentTypeConstants.ApplicationJson },
     { "Authorization", $"Bearer {authn.GetApplicationBearerToken()}" },
     { "Accept", "*/*" }
 };
Beispiel #17
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public ReportTileController(IProductivity3dV2ProxyCompactionTile productivity3DProxyCompactionTile, IPreferenceProxy prefProxy, IFileImportProxy fileImportProxy,
                             IMapTileGenerator tileGenerator, IMemoryCache cache, IConfigurationStore configStore,
                             IBoundingBoxHelper boundingBoxHelper, ITPaaSApplicationAuthentication authn)
     : base(productivity3DProxyCompactionTile, prefProxy, fileImportProxy, tileGenerator, cache, configStore, boundingBoxHelper, authn)
 {
 }
Beispiel #18
0
        /// <summary>
        ///   Builds this instance for specified executor type.
        /// </summary>
        public static TExecutor Build <TExecutor>(ILogger logger, IConfigurationStore configStore, ITPaaSApplicationAuthentication authorization,
                                                  IProjectInternalProxy projectProxy, IDeviceInternalProxy deviceProxy, ITRexCompactionDataProxy tRexCompactionDataProxy,
                                                  IHeaderDictionary requestCustomHeaders)
            where TExecutor : RequestExecutorContainer, new()
        {
            var executor = new TExecutor()
            {
                log = logger, configStore = configStore, authorization = authorization, projectProxy = projectProxy, deviceProxy = deviceProxy, tRexCompactionDataProxy = tRexCompactionDataProxy, requestCustomHeaders = requestCustomHeaders
            };

            dataRepository = new DataRepository(logger, authorization, projectProxy, deviceProxy, tRexCompactionDataProxy, requestCustomHeaders);
            return(executor);
        }
Beispiel #19
0
 public GeoTiffTileGenerationJob(IConfigurationStore configurationStore, IPegasusClient pegasusClient, ITPaaSApplicationAuthentication authn, INotificationHubClient notificationHubClient, ILoggerFactory logger)
     : base(configurationStore, pegasusClient, authn, notificationHubClient, logger)
 {
 }