示例#1
0
        public void Initialise(ILoggerFactory loggerFactory, ILogger logger,
#if RAPTOR
                               IASNodeClient raptorClient,
                               ITagProcessor tagProcessor,
#endif
                               IConfigurationStore configStore, List <FileData> fileList, ICompactionProfileResultHelper profileResultHelper,
                               ITRexTagFileProxy tRexTagFileProxy, ITRexCompactionDataProxy trexCompactionDataProxy, IFileImportProxy fileImportProxy,
                               IHeaderDictionary customHeaders, string customerUid, string userId)
        {
            this.loggerFactory = loggerFactory;
            this.log           = logger;
#if RAPTOR
            this.raptorClient = raptorClient;
            this.tagProcessor = tagProcessor;
#endif
            this.configStore             = configStore;
            this.fileList                = fileList;
            this.profileResultHelper     = profileResultHelper;
            this.tRexTagFileProxy        = tRexTagFileProxy;
            this.trexCompactionDataProxy = trexCompactionDataProxy;
            this.fileImportProxy         = fileImportProxy;
            this.customHeaders           = customHeaders;
            this.customerUid             = customerUid;
            this.userId = userId;
        }
示例#2
0
        public LineworkExecutorTests()
        {
            serviceProvider = new ServiceCollection()
                              .AddLogging()
                              .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")))
                              .BuildServiceProvider();

            logger         = serviceProvider.GetRequiredService <ILoggerFactory>();
            _customHeaders = new HeaderDictionary();

            var configStoreMock = new Mock <IConfigurationStore>();

            configStoreMock.Setup(x => x.GetValueBool("TREX_IS_AVAILABLE")).Returns(true);
            configStoreMock.Setup(x => x.GetValueBool("ENABLE_TREX_GATEWAY_LINEWORKFILE")).Returns(true);

            configStore = configStoreMock.Object;

            var mockTrexCompactionDataProxy = new Mock <ITRexCompactionDataProxy>();

            mockTrexCompactionDataProxy.Setup(x =>
                                              x.SendDataPostRequest <DXFBoundaryResult, DXFBoundariesRequest>(It.IsAny <DXFBoundariesRequest>(), It.IsAny <string>(), It.IsAny <IHeaderDictionary>(), It.IsAny <bool>()))
            .Returns((DXFBoundariesRequest req, string route, IHeaderDictionary customHeaders, bool mutableGateway) =>
            {
                return(Task.FromResult(new DXFBoundaryResult(ContractExecutionStatesEnum.ExecutedSuccessfully, "Success", TestResultBoundary())));
            });
            trexCompactionDataProxy = mockTrexCompactionDataProxy.Object;
        }
示例#3
0
 /// <summary>
 /// Constructor with dependency injection
 /// </summary>
 public CoordinateSystemController(ILoggerFactory logger, IConfigurationStore configStore, ITRexCompactionDataProxy trexCompactionDataProxy)
 {
     this.logger                  = logger;
     _log                         = logger.CreateLogger <CoordinateSystemController>();
     this.configStore             = configStore;
     this.trexCompactionDataProxy = trexCompactionDataProxy;
 }
示例#4
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public ConfigController(ILoggerFactory logger, IConfigurationStore configStore, ITRexCompactionDataProxy tRexCompactionDataProxy)
 {
     _logger                  = logger;
     _log                     = logger.CreateLogger <ConfigController>();
     _configStore             = configStore;
     _tRexCompactionDataProxy = tRexCompactionDataProxy;
 }
示例#5
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public CompactionReportController(
     IConfigurationStore configStore,
     IFileImportProxy fileImportProxy, ICompactionSettingsManager settingsManager,
     IProductionDataRequestFactory requestFactory, IPreferenceProxy prefProxy,
     ITRexCompactionDataProxy tRexCompactionDataProxy) :
     base(configStore, fileImportProxy, settingsManager)
 {
     this.requestFactory = requestFactory;
     this.prefProxy      = prefProxy;
 }
示例#6
0
 /// <summary>
 /// Constructor with dependency injection
 /// </summary>
 public EditDataController(
     ILoggerFactory logger,
     IConfigurationStore configStore,
     IFileImportProxy fileImportProxy,
     ITRexCompactionDataProxy tRexCompactionDataProxy,
     ICompactionSettingsManager settingsManager)
     : base(configStore, fileImportProxy, settingsManager)
 {
     this._tRexCompactionDataProxy = tRexCompactionDataProxy;
 }
示例#7
0
        /// <summary>
        /// Constructor with injection
        /// </summary>
        /// <param name="logger">LoggerFactory</param>
        /// <param name="configStore">Configuration Store</param>
        /// <param name="trexCompactionDataProxy">Trex Gateway production data proxy</param>
        public ProjectExtentsController(
#if RAPTOR
            IASNodeClient raptorClient,
#endif
            ILoggerFactory logger, IConfigurationStore configStore, ITRexCompactionDataProxy trexCompactionDataProxy)
        {
#if RAPTOR
            this.raptorClient = raptorClient;
#endif
            this.logger                  = logger;
            this.configStore             = configStore;
            this.trexCompactionDataProxy = trexCompactionDataProxy;
        }
示例#8
0
        /// <summary>
        /// Constructor with injection
        /// </summary>
        /// <param name="logger">LoggerFactory</param>
        /// <param name="configStore">Configuration Store</param>
        /// <param name="trexCompactionDataProxy">Trex Gateway production data proxy</param>
        public TileController(
#if RAPTOR
            IASNodeClient raptorClient,
#endif
            ILoggerFactory logger, IConfigurationStore configStore, ICompactionSettingsManager settingsManager, ITRexCompactionDataProxy trexCompactionDataProxy, IFileImportProxy fileImportProxy)
            : base(configStore, fileImportProxy, settingsManager)
        {
#if RAPTOR
            this.raptorClient = raptorClient;
#endif
            this.logger             = logger;
            ConfigStore             = configStore;
            TRexCompactionDataProxy = trexCompactionDataProxy;
        }
示例#9
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public ProfileProductionDataController(
#if RAPTOR
            IASNodeClient raptorClient,
#endif
            ILoggerFactory logger, IConfigurationStore configStore, ITRexCompactionDataProxy trexCompactionDataProxy, IFileImportProxy fileImportProxy)
        {
#if RAPTOR
            this.raptorClient = raptorClient;
#endif
            this.logger             = logger;
            ConfigStore             = configStore;
            TRexCompactionDataProxy = trexCompactionDataProxy;
            FileImportProxy         = fileImportProxy;
        }
示例#10
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);
            }
        }
示例#11
0
        /// <summary>
        /// Constructor with dependency injection
        /// </summary>
        /// <param name="logger">LoggerFactory</param>
        /// <param name="configStore">Configuration Store</param>
        /// <param name="trexCompactionDataProxy">Trex Gateway production data proxy</param>
        public CCATileController(ILoggerFactory logger,
#if RAPTOR
                                 IASNodeClient raptorClient,
#endif
                                 IConfigurationStore configStore, ITRexCompactionDataProxy trexCompactionDataProxy, IFileImportProxy fileImportProxy)
        {
            this.logger = logger;
            log         = logger.CreateLogger <CCATileController>();
#if RAPTOR
            this.raptorClient = raptorClient;
#endif
            ConfigStore             = configStore;
            TRexCompactionDataProxy = trexCompactionDataProxy;
            FileImportProxy         = fileImportProxy;
        }
示例#12
0
        /// <summary>
        /// Constructor with injection
        /// </summary>
        /// <param name="logger">Logger</param>
        /// <param name="configStore">Configuration store</param>
        /// <param name="tRexCompactionDataProxy"></param>
        public ReportController(
#if RAPTOR
            IASNodeClient raptorClient,
#endif
            ILoggerFactory logger, IConfigurationStore configStore, ICompactionSettingsManager settingsManager, ITRexCompactionDataProxy tRexCompactionDataProxy, IFileImportProxy fileImportProxy)
            : base(configStore, fileImportProxy, settingsManager)
        {
#if RAPTOR
            this.raptorClient = raptorClient;
#endif
            this._logger                 = logger;
            _log                         = logger.CreateLogger <ReportController>();
            this.configStore             = configStore;
            this.tRexCompactionDataProxy = tRexCompactionDataProxy;
        }
示例#13
0
        public ProjectStatisticsHelper(ILoggerFactory loggerFactory, IConfigurationStore configStore,
                                       IFileImportProxy fileImportProxy, ITRexCompactionDataProxy tRexCompactionDataProxy, ILogger log
#if RAPTOR
                                       , IASNodeClient raptorClient
#endif
                                       )
        {
            _loggerFactory           = loggerFactory;
            _configStore             = configStore;
            _fileImportProxy         = fileImportProxy;
            _tRexCompactionDataProxy = tRexCompactionDataProxy;
            _designUtilities         = new DesignUtilities(log, configStore, fileImportProxy);
#if RAPTOR
            _raptorClient = raptorClient;
#endif
        }
示例#14
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public MachinesController(
#if RAPTOR
            IASNodeClient raptorClient,
#endif
            ILoggerFactory logger, IConfigurationStore configStore, ITRexCompactionDataProxy trexCompactionDataProxy, IFileImportProxy fileImportProxy
            )
        {
#if RAPTOR
            _raptorClient = raptorClient;
#endif
            _logger                  = logger;
            _log                     = logger.CreateLogger <MachinesController>();
            _configStore             = configStore;
            _trexCompactionDataProxy = trexCompactionDataProxy;
            FileImportProxy          = fileImportProxy;
        }
示例#15
0
        public ProductionDataTileService(IProductionDataRequestFactory prodDataFactory, ILoggerFactory logger, IElevationExtentsProxy extentsProxy,
#if RAPTOR
                                         IASNodeClient raptor,
#endif
                                         IConfigurationStore configStore, ITRexCompactionDataProxy trexCompactionDataProxy, IFileImportProxy fileImportProxy)
        {
            requestFactory = prodDataFactory;
            log            = logger.CreateLogger <ProductionDataTileService>();
            this.logger    = logger;
#if RAPTOR
            raptorClient = raptor;
#endif
            elevProxy               = extentsProxy;
            ConfigStore             = configStore;
            TRexCompactionDataProxy = trexCompactionDataProxy;
            FileImportProxy         = fileImportProxy;
        }
示例#16
0
        /// <summary>
        /// Constructor with injection
        /// </summary>
        /// <param name="raptorClient">Raptor client</param>
        /// <param name="logger">Logger</param>
        /// <param name="cache">Elevation extents cache</param>
        /// <param name="settingsManager">Compaction settings manager</param>
        /// <param name="configStore">Configuration store</param>
        /// <param name="trexCompactionDataProxy">Trex Gateway production data proxy</param>
        public ElevationExtentsProxy(
#if RAPTOR
            IASNodeClient raptorClient,
#endif
            ILoggerFactory logger, IDataCache cache, ICompactionSettingsManager settingsManager, IConfigurationStore configStore,
            ITRexCompactionDataProxy trexCompactionDataProxy, IFileImportProxy fileImportProxy)
        {
#if RAPTOR
            this.raptorClient = raptorClient;
#endif
            this.logger                  = logger;
            this.log                     = logger.CreateLogger <ElevationExtentsProxy>();
            elevationExtentsCache        = cache;
            this.settingsManager         = settingsManager;
            this.configStore             = configStore;
            this.trexCompactionDataProxy = trexCompactionDataProxy;
            this.fileImportProxy         = fileImportProxy;
        }
示例#17
0
        public BoundingBoxService(ILoggerFactory logger,
#if RAPTOR
                                  IASNodeClient raptor,
#endif
                                  IConfigurationStore configStore,
                                  ITRexCompactionDataProxy tRexCompactionDataProxy,
                                  IFileImportProxy fileImportProxy
                                  )
        {
            log         = logger.CreateLogger <BoundingBoxService>();
            this.logger = logger;
#if RAPTOR
            raptorClient = raptor;
#endif
            this.configStore             = configStore;
            this.tRexCompactionDataProxy = tRexCompactionDataProxy;
            this.fileImportProxy         = fileImportProxy;
        }
示例#18
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Compaction3DMapController(ILoggerFactory loggerFactory,
                                         IServiceExceptionHandler serviceExceptionHandler,
                                         IConfigurationStore configStore,
                                         IFileImportProxy fileImportProxy,
                                         IProjectSettingsProxy projectSettingsProxy,
                                         IFilterServiceProxy filterServiceProxy,
                                         ICompactionSettingsManager settingsManager,
                                         IProductionDataTileService tileService,
#if RAPTOR
                                         IASNodeClient raptorClient,
#endif
                                         IBoundingBoxHelper boundingBoxHelper,
                                         ITRexCompactionDataProxy trexCompactionDataProxy,
                                         ITransferProxyFactory transferProxyFactory) : base(configStore, fileImportProxy, settingsManager)
        {
            this.tileService             = tileService;
            this.boundingBoxHelper       = boundingBoxHelper;
            this.trexCompactionDataProxy = trexCompactionDataProxy;
            this.transferProxyFactory    = transferProxyFactory;
        }
示例#19
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);
        }
示例#20
0
        public async Task <FileResult> GetMapTileDataTtm(
            [FromQuery] Guid projectUid,
            [FromQuery] Guid?filterUid,
            [FromQuery] Guid?designUid,
            [FromQuery] DisplayMode mode,
            [FromServices] IPreferenceProxy prefProxy,
            [FromServices] ITRexCompactionDataProxy tRexCompactionDataProxy,
#if RAPTOR
            [FromServices] IASNodeClient raptorClient,
#endif
            [FromServices] IProductionDataRequestFactory requestFactory)
        {
            const double SURFACE_EXPORT_TOLERANCE = 0.05;
            const byte   COORDS_ARRAY_LENGTH      = 3;

            var tins = new List <TrimbleTINModel>();

            var projectTask     = ((RaptorPrincipal)User).GetProject(projectUid);
            var projectSettings = GetProjectSettingsTargets(projectUid);
            var userPreferences = prefProxy.GetUserPreferences(GetUserId(), CustomHeaders);
            var filter          = GetCompactionFilter(projectUid, filterUid);
            var designTask      = GetAndValidateDesignDescriptor(projectUid, designUid);

            if (userPreferences == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults,
                                                                       "Failed to retrieve preferences for current user"));
            }

            await Task.WhenAll(projectTask, projectSettings, userPreferences, designTask);

            var project = projectTask.Result;
            var design  = designTask.Result;

            // Get the terrain mesh
            var exportRequest = requestFactory.Create <ExportRequestHelper>(r => r
                                                                            .ProjectUid(projectUid)
                                                                            .ProjectId(project.ShortRaptorProjectId)
                                                                            .Headers(CustomHeaders)
                                                                            .ProjectSettings(projectSettings.Result)
                                                                            .Filter(filter.Result))
                                .SetUserPreferences(userPreferences.Result)
#if RAPTOR
                                .SetRaptorClient(raptorClient)
#endif
                                .SetProjectDescriptor(project)
                                .CreateExportRequest(
                null, //startUtc,
                null, //endUtc,
                CoordType.LatLon,
                ExportTypes.SurfaceExport,
                "test.zip",
                true,
                false,
                OutputTypes.VedaAllPasses,
                string.Empty,
                SURFACE_EXPORT_TOLERANCE);

            exportRequest.Validate();

            // First get the export of production data from Raptor
            // comes in a zip file
            var result = await WithServiceExceptionTryExecuteAsync(() => RequestExecutorContainerFactory.Build <CompactionExportExecutor>(LoggerFactory,
#if RAPTOR
                                                                                                                                          raptorClient,
#endif
                                                                                                                                          configStore : ConfigStore,
                                                                                                                                          trexCompactionDataProxy : tRexCompactionDataProxy,
                                                                                                                                          customHeaders : CustomHeaders,
                                                                                                                                          userId : GetUserId(),
                                                                                                                                          fileImportProxy : FileImportProxy)
                                                                   .ProcessAsync(exportRequest)) as CompactionExportResult;

            if (result != null)
            {
                var zipStream = (await transferProxyFactory.NewProxy(TransferProxyType.Temporary).Download(result.DownloadLink)).FileStream;
                // If we didn't get a valid file, then we failed to read the ttm from raptor
                if (zipStream == null)
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults,
                                                                           "Failed to retrieve data"));
                }

                using (var archive = new ZipArchive(zipStream))
                {
                    // The zip file will have exactly one file in it
                    if (archive.Entries.Count == 1)
                    {
                        try
                        {
                            var tin = new TrimbleTINModel();
                            using (var stream = archive.Entries[0].Open() as DeflateStream)
                                using (var ms = new MemoryStream())
                                {
                                    // Unzip the file, copy to memory as the TIN file needs the byte array, and stream
                                    stream.CopyTo(ms);
                                    ms.Seek(0, SeekOrigin.Begin);

                                    tin.LoadFromStream(ms, ms.GetBuffer());

                                    tins.Add(tin);
                                }
                        }
                        catch (TTMFileReadException e)
                        {
                            // Not valid, continue
                            Log.LogWarning(e, "Failed to parse ttm in zip file");
                        }
                    }
                }
            }

            // If we didn't get a valid file, then we failed to read the ttm from raptor
            if (tins.Count == 0)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults,
                                                                       "Failed to retrieve data"));
            }

            // If we have a design request, get the ttm and add it for parsing
            if (design != null)
            {
                //TODO: This used to get the file from TCC. This code to get from s3 needs testing.
                //Leave for now as this end point is not currently supported.
                // Retrieve the stored file from AWS
                var s3FullPath    = $"{projectUid}/{design.File.FileName}";
                var transferProxy = transferProxyFactory.NewProxy(TransferProxyType.Temporary);
                var fileResult    = await transferProxy.Download(s3FullPath);

                if (fileResult?.FileStream != null)
                {
                    using (var ms = new MemoryStream())
                    {
                        fileResult.FileStream.CopyTo(ms);
                        ms.Seek(0, SeekOrigin.Begin);
                        var tin = new TrimbleTINModel();
                        tin.LoadFromStream(ms, ms.GetBuffer());
                        tins.Add(tin);
                    }
                }
            }

            // Calculating the bounding box for the model (including design if supplied)
            var minEasting     = tins.Select(t => t.Header.MinimumEasting).Min();
            var maxEasting     = tins.Select(t => t.Header.MaximumEasting).Max();
            var minNorthing    = tins.Select(t => t.Header.MinimumNorthing).Min();
            var maxNorthing    = tins.Select(t => t.Header.MaximumNorthing).Max();
            var centerEasting  = (maxEasting + minEasting) / 2.0;
            var centerNorthing = (maxNorthing + minNorthing) / 2.0;

            TwoDConversionCoordinate[] convertedCoordinates;

#if RAPTOR
            if (UseTRexGateway("ENABLE_TREX_GATEWAY_TILES"))
            {
#endif
            var conversionCoordinates = new []
            {
                new TwoDConversionCoordinate(minEasting, minNorthing),
                new TwoDConversionCoordinate(maxEasting, maxNorthing),
                new TwoDConversionCoordinate(centerEasting, centerNorthing)
            }
            ;

            var conversionRequest = new CoordinateConversionRequest(projectUid, TwoDCoordinateConversionType.NorthEastToLatLon, conversionCoordinates);
            var conversionResult  = await trexCompactionDataProxy.SendDataPostRequest <CoordinateConversionResult, CoordinateConversionRequest>(conversionRequest, "/coordinateconversion", CustomHeaders);

            if (conversionResult.Code != 0 || conversionResult.ConversionCoordinates.Length != COORDS_ARRAY_LENGTH)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults,
                                                                       "Failed to retrieve long lat for boundary"));
            }

            convertedCoordinates = conversionResult.ConversionCoordinates;
#if RAPTOR
        }

        else
        {
            var points = new TWGS84FenceContainer
            {
                FencePoints = new[]
                {
                    TWGS84Point.Point(minEasting, minNorthing),
                    TWGS84Point.Point(maxEasting, maxNorthing),
                    TWGS84Point.Point(centerEasting, centerNorthing),
                }
            };

            // Convert the northing easting values to long lat values
            var res = raptorClient.GetGridCoordinates(project.LegacyProjectId, points, TCoordConversionType.ctNEEtoLLH, out var coordPointList);
            if (res != TCoordReturnCode.nercNoError)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults,
                                                                       "Failed to retrieve long lat for boundary"));
            }

            convertedCoordinates = coordPointList.Points.Coords.Select(c => new TwoDConversionCoordinate(c.X, c.Y)).ToArray();
        }
#endif

            // The values returned from Raptor/TRex are in rads, where we need degrees for the bbox
            var minLat    = convertedCoordinates[0].Y * Coordinates.RADIANS_TO_DEGREES;
            var minLng    = convertedCoordinates[0].X * Coordinates.RADIANS_TO_DEGREES;
            var maxLat    = convertedCoordinates[1].Y * Coordinates.RADIANS_TO_DEGREES;
            var maxLng    = convertedCoordinates[1].X * Coordinates.RADIANS_TO_DEGREES;
            var centerLat = convertedCoordinates[2].Y * Coordinates.RADIANS_TO_DEGREES;
            var centerLng = convertedCoordinates[2].X * Coordinates.RADIANS_TO_DEGREES;
            var bbox      = $"{minLat},{minLng},{maxLat},{maxLng}";

            var outputStream = new MemoryStream();
            using (var zipArchive = new ZipArchive(outputStream, ZipArchiveMode.Create, true))
            {
                var textureZipEntry = zipArchive.CreateEntry("texture.png");
                using (var stream = textureZipEntry.Open())
                {
                    // Write the texture to the zip
                    var textureFileStream = await GetTexture(projectUid, designUid, projectSettings.Result, filter.Result, mode, bbox);

                    textureFileStream.FileStream.CopyTo(stream);
                }

                // Write the model to the zip
                var modelZipEntry = zipArchive.CreateEntry("model.obj");
                using (var stream = modelZipEntry.Open())
                {
                    var modelFileStream = ConvertMultipleToObj(tins, centerEasting, centerNorthing);
                    modelFileStream.FileStream.CopyTo(stream);
                }

                // Add some metadata to help with positioning of the model
                var metaDataEntry = zipArchive.CreateEntry("metadata.json");
                using (var stream = metaDataEntry.Open())
                {
                    var metaData = new
                    {
                        Minimum = new
                        {
                            Lat = minLat,
                            Lng = minLng
                        },
                        Maximum = new
                        {
                            Lat = maxLat,
                            Lng = maxLng
                        },
                        Center = new
                        {
                            Lat = centerLat,
                            Lng = centerLng
                        },
                        HasDesign = design != null
                    };
                    var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(metaData));
                    stream.Write(bytes, 0, bytes.Length);
                }
            }

            // Don't forget to seek back, or else the content length will be 0
            outputStream.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(outputStream, ContentTypeConstants.ApplicationZip));
        }
示例#21
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,
#if RAPTOR
                                                  IASNodeClient raptorClient = null,
                                                  ITagProcessor tagProcessor = null,
#endif
                                                  IConfigurationStore configStore    = null,
                                                  List <FileData> fileList           = null, ICompactionProfileResultHelper profileResultHelper = null,
                                                  ITRexTagFileProxy tRexTagFileProxy = null, ITRexCompactionDataProxy trexCompactionDataProxy   = null,
                                                  IFileImportProxy fileImportProxy   = null,
                                                  IHeaderDictionary customHeaders    = null, string customerUid = null, string userId = null)
            where TExecutor : RequestExecutorContainer, new()
        {
            ILogger log = null;

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

            var executor = new TExecutor();

            executor.Initialise(
                logger,
                log,
#if RAPTOR
                raptorClient,
                tagProcessor,
#endif
                configStore,
                fileList,
                profileResultHelper,
                tRexTagFileProxy,
                trexCompactionDataProxy,
                fileImportProxy,
                customHeaders,
                customerUid,
                userId);

            return(executor);
        }