Esempio n. 1
0
        public async void Add_FailWithNoProject()
        {
            AddApplicationRouting();

            var request  = new AddAlignmentRequest();
            var response = await request.ExecuteAsync(new AddAlignmentArgument
            {
                ProjectID        = Guid.NewGuid(),
                DesignDescriptor = new DesignDescriptor(Guid.NewGuid(), "folder", "filename"),
                Extents          = new TRex.Geometry.BoundingWorldExtent3D(0, 0, 1, 1)
            });

            response.Should().NotBeNull();
            response.AlignmentUid.Should().Be(Guid.Empty);
            response.RequestResult.Should().Be(DesignProfilerRequestResult.FailedToAddDesign);
        }
Esempio n. 2
0
        public async void Remove()
        {
            AddApplicationRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            // Add te design to be removed
            var alignmentID = Guid.NewGuid();
            var addRequest  = new AddAlignmentRequest();
            var addResponse = await addRequest.ExecuteAsync(new AddAlignmentArgument
            {
                ProjectID        = siteModel.ID,
                DesignDescriptor = new DesignDescriptor(alignmentID, "folder", "filename"),
                Extents          = new TRex.Geometry.BoundingWorldExtent3D(0, 0, 1, 1)
            });

            addResponse.Should().NotBeNull();
            addResponse.AlignmentUid.Should().Be(alignmentID);
            addResponse.RequestResult.Should().Be(DesignProfilerRequestResult.OK);

            // Re-request the sitemodel to reflect the change
            siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(siteModel.ID, false);
            siteModel.Alignments.Count.Should().Be(1);

            var removeRequest  = new RemoveAlignmentRequest();
            var removeResponse = await removeRequest.ExecuteAsync(new RemoveAlignmentArgument
            {
                ProjectID   = siteModel.ID,
                AlignmentID = alignmentID
            });

            removeResponse.Should().NotBeNull();
            removeResponse.AlignmentUid.Should().Be(alignmentID);
            removeResponse.RequestResult.Should().Be(DesignProfilerRequestResult.OK);

            // Re-request the sitemodel to reflect the change
            siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(siteModel.ID, false);
            siteModel.Alignments.Count.Should().Be(0);
        }
Esempio n. 3
0
        public async void Add()
        {
            AddApplicationRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            siteModel.SetStorageRepresentationToSupply(TRex.Storage.Models.StorageMutability.Mutable);
            siteModel.Alignments.Count.Should().Be(0);

            siteModel.SetStorageRepresentationToSupply(TRex.Storage.Models.StorageMutability.Immutable);
            siteModel.Alignments.Count.Should().Be(0);

            var alignmentID = Guid.NewGuid();
            var request     = new AddAlignmentRequest();
            var response    = await request.ExecuteAsync(new AddAlignmentArgument
            {
                ProjectID        = siteModel.ID,
                DesignDescriptor = new DesignDescriptor(alignmentID, "folder", "filename"),
                Extents          = new TRex.Geometry.BoundingWorldExtent3D(0, 0, 1, 1)
            });

            response.Should().NotBeNull();
            response.AlignmentUid.Should().Be(alignmentID);
            response.RequestResult.Should().Be(DesignProfilerRequestResult.OK);

            // Re-request the sitemodel to reflect the change
            siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(siteModel.ID, false);

            siteModel.SetStorageRepresentationToSupply(TRex.Storage.Models.StorageMutability.Mutable);
            siteModel.Alignments.Count.Should().Be(1);
            siteModel.Alignments[0].DesignDescriptor.Should().BeEquivalentTo(new DesignDescriptor(alignmentID, "folder", "filename"));

            siteModel.SetStorageRepresentationToSupply(TRex.Storage.Models.StorageMutability.Immutable);
            siteModel.Alignments.Count.Should().Be(1);
            siteModel.Alignments[0].DesignDescriptor.Should().BeEquivalentTo(new DesignDescriptor(alignmentID, "folder", "filename"));
        }
Esempio n. 4
0
        public void Creation()
        {
            var req = new AddAlignmentRequest();

            req.Should().NotBeNull();
        }
Esempio n. 5
0
        /// <summary>
        /// Add a design or surveyed surface or alignment file to TRex
        /// </summary>
        protected async Task AddDesign(DesignRequest request, string executorName)
        {
            // load core file from s3 to local
            var localPath            = FilePathHelper.GetTempFolderForProject(request.ProjectUid);
            var localPathAndFileName = Path.Combine(new[] { localPath, request.FileName });

            DesignBase design;

            if (request.FileType == ImportedFileType.Alignment)
            {
                design = new SVLAlignmentDesign();
            }
            else
            {
                design = new TTMDesign(SubGridTreeConsts.DefaultCellSize);
            }
            var designLoadResult = design.LoadFromStorage(request.ProjectUid, request.FileName, localPath);

            if (designLoadResult != DesignLoadResult.Success)
            {
                log.LogError($"#Out# {executorName}. Addition of design failed :{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}, designLoadResult: {designLoadResult}");
                throw CreateServiceException <TExecutor>
                          (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError,
                          RequestErrorStatus.DesignImportUnableToRetrieveFromS3, designLoadResult.ToString());
            }

            if (request.FileType != ImportedFileType.Alignment)
            {
                // This generates the 2 index files
                designLoadResult = design.LoadFromFile(localPathAndFileName);
                if (designLoadResult != DesignLoadResult.Success)
                {
                    log.LogError($"#Out# {executorName}. Addition of design failed :{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}, designLoadResult: {designLoadResult}");
                    throw CreateServiceException <TExecutor>
                              (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError,
                              RequestErrorStatus.DesignImportUnableToCreateDesign, designLoadResult.ToString());
                }
            }

            var extents = new BoundingWorldExtent3D();

            design.GetExtents(out extents.MinX, out extents.MinY, out extents.MaxX, out extents.MaxY);
            design.GetHeightRange(out extents.MinZ, out extents.MaxZ);

            if (request.FileType == ImportedFileType.DesignSurface)
            {
                // Create the new designSurface in our site
                var tRexRequest      = new AddTTMDesignRequest();
                var designSurfaceUid = await tRexRequest.ExecuteAsync(new AddTTMDesignArgument
                {
                    ProjectID        = request.ProjectUid,
                    DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName),
                    Extents          = extents,
                    ExistenceMap     = design.SubGridOverlayIndex()
                });
            }

            if (request.FileType == ImportedFileType.SurveyedSurface)
            {
                // Create the new SurveyedSurface in our site model
                var tRexRequest        = new AddSurveyedSurfaceRequest();
                var surveyedSurfaceUid = await tRexRequest.ExecuteAsync(new AddSurveyedSurfaceArgument
                {
                    ProjectID        = request.ProjectUid,
                    DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName),
                    AsAtDate         = request.SurveyedUtc ?? TRex.Common.Consts.MIN_DATETIME_AS_UTC, // validation will have ensured this exists
                    Extents          = extents,
                    ExistenceMap     = design.SubGridOverlayIndex()
                });
            }

            if (request.FileType == ImportedFileType.Alignment)
            {
                // Create the new alignment in our site model
                var tRexRequest  = new AddAlignmentRequest();
                var alignmentUid = await tRexRequest.ExecuteAsync(new AddAlignmentArgument
                {
                    ProjectID        = request.ProjectUid,
                    DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName),
                    Extents          = extents
                });
            }

            if (request.FileType != ImportedFileType.Alignment)
            {
                //  TTM.LoadFromFile() will have created these 3 files. We need to store them on S3 to reload cache when required
                var s3FileTransfer = new S3FileTransfer(TransferProxyType.DesignImport);
                s3FileTransfer.WriteFile(localPath, request.ProjectUid, SubGridIndexFileName(request.FileName));
                s3FileTransfer.WriteFile(localPath, request.ProjectUid, SpatialIndexFileName(request.FileName));
                s3FileTransfer.WriteFile(localPath, request.ProjectUid, BoundaryFileName(request.FileName));
            }
        }