Example #1
0
 /// <summary>
 /// Constructor with dependency injection
 /// </summary>
 public ExportJob(IApiClient apiClient, ITransferProxyFactory transferProxyfactory, ILoggerFactory logger)
 {
     _log                  = logger.CreateLogger <ExportJob>();
     _apiClient            = apiClient;
     _transferProxyFactory = transferProxyfactory;
     _transferProxy        = _transferProxyFactory.NewProxy(TransferProxyType.Temporary);
 }
Example #2
0
        /// <summary>
        /// Deletes the imported file from S3.
        /// </summary>
        public static void DeleteFileFromS3Repository(string projectUid, string filename,
                                                      bool isSurveyedSurface, DateTime?surveyedUtc,
                                                      ILogger log, IServiceExceptionHandler serviceExceptionHandler,
                                                      ITransferProxy persistantTransferProxy)
        {
            var s3FullPath = GetS3FullPath(projectUid, filename, isSurveyedSurface, surveyedUtc);

            try
            {
                persistantTransferProxy.RemoveFromBucket(s3FullPath);
            }
            catch (Exception e)
            {
                serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 57, "transferProxy.RemoveFromBucket()",
                                                              e.Message);
            }

            log.LogInformation($"DeleteFileFromS3Repository. Process delete design :{s3FullPath}, for Project:{projectUid}");
        }
Example #3
0
        /// <summary>
        /// Writes the importedFile to S3
        ///   if file exists, it will be overwritten
        ///   returns FileDescriptor for backwards compatability
        /// </summary>
        /// <returns></returns>
        public static FileDescriptor WriteFileToS3Repository(
            Stream fileContents, string projectUid, string filename,
            bool isSurveyedSurface, DateTime?surveyedUtc,
            ILogger log, IServiceExceptionHandler serviceExceptionHandler,
            ITransferProxy persistantTransferProxy)
        {
            var s3FullPath = GetS3FullPath(projectUid, filename, isSurveyedSurface, surveyedUtc);

            try
            {
                persistantTransferProxy.Upload(fileContents, s3FullPath);
            }
            catch (Exception e)
            {
                serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 57, "transferProxy.Upload()",
                                                              e.Message);
            }

            log.LogInformation($"WriteFileToS3Repository. Process add design :{s3FullPath}, for Project:{projectUid}");
            var finalFilename = s3FullPath.Split("/")[1];

            return(FileDescriptor.CreateFileDescriptor(string.Empty, string.Empty, finalFilename));
        }
Example #4
0
 public S3FileTransfer(TransferProxyType type)
 {
     _type = type;
     Proxy = DIContext.ObtainRequired <ITransferProxyFactory>().NewProxy(_type);
 }