Beispiel #1
0
        public async void Remove_FailWithNoProject()
        {
            AddApplicationRouting();

            var request  = new RemoveTTMDesignRequest();
            var response = await request.ExecuteAsync(new RemoveTTMDesignArgument
            {
                ProjectID = Guid.NewGuid(),
                DesignID  = Guid.NewGuid()
            });

            response.Should().NotBeNull();
            response.RequestResult.Should().Be(DesignProfilerRequestResult.NoSelectedSiteModel);
        }
Beispiel #2
0
        public async void Remove()
        {
            AddApplicationRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            // Add te design to be removed
            var designID     = Guid.NewGuid();
            var existenceMap = new TRex.SubGridTrees.SubGridTreeSubGridExistenceBitMask();

            existenceMap[0, 0] = true;

            var addRequest  = new AddTTMDesignRequest();
            var addResponse = await addRequest.ExecuteAsync(new AddTTMDesignArgument
            {
                ProjectID        = siteModel.ID,
                DesignDescriptor = new DesignDescriptor(designID, "folder", "filename"),
                Extents          = new TRex.Geometry.BoundingWorldExtent3D(0, 0, 1, 1),
                ExistenceMap     = existenceMap
            });

            addResponse.Should().NotBeNull();
            addResponse.DesignUid.Should().Be(designID);
            addResponse.RequestResult.Should().Be(DesignProfilerRequestResult.OK);

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

            var removeRequest  = new RemoveTTMDesignRequest();
            var removeResponse = await removeRequest.ExecuteAsync(new RemoveTTMDesignArgument
            {
                ProjectID = siteModel.ID,
                DesignID  = designID
            });

            removeResponse.Should().NotBeNull();
            removeResponse.DesignUid.Should().Be(designID);
            removeResponse.RequestResult.Should().Be(DesignProfilerRequestResult.OK);

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

            var readExistenceMap = DIContext.Obtain <IExistenceMapServer>().GetExistenceMap(new NonSpatialAffinityKey(siteModel.ID,
                                                                                                                      BaseExistenceMapRequest.CacheKeyString(TRex.ExistenceMaps.Interfaces.Consts.EXISTENCE_MAP_DESIGN_DESCRIPTOR, designID)));

            readExistenceMap.Should().BeNull();
        }
Beispiel #3
0
        public async void Remove_FailWithNoDesign()
        {
            AddApplicationRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            var request  = new RemoveTTMDesignRequest();
            var response = await request.ExecuteAsync(new RemoveTTMDesignArgument
            {
                ProjectID = siteModel.ID,
                DesignID  = Guid.NewGuid()
            });

            response.Should().NotBeNull();
            response.RequestResult.Should().Be(DesignProfilerRequestResult.DesignDoesNotExist);
        }
Beispiel #4
0
        public void Creation()
        {
            var req = new RemoveTTMDesignRequest();

            req.Should().NotBeNull();
        }
Beispiel #5
0
        /// <summary>
        /// Delete a design or surveyed surface or alignment file from TRex
        /// </summary>
        protected async Task RemoveDesign(DesignRequest request, string executorName)
        {
            bool removedOk = false;

            if (request.FileType == ImportedFileType.DesignSurface)
            {
                // Remove the designSurface
                var tRexRequest    = new RemoveTTMDesignRequest();
                var removeResponse = await tRexRequest.ExecuteAsync(new RemoveTTMDesignArgument
                {
                    ProjectID = request.ProjectUid,
                    DesignID  = request.DesignUid
                });

                removedOk = removeResponse.RequestResult == DesignProfilerRequestResult.OK;
            }

            if (request.FileType == ImportedFileType.SurveyedSurface)
            {
                // Remove the new surveyedSurface
                var tRexRequest    = new RemoveSurveyedSurfaceRequest();
                var removeResponse = await tRexRequest.ExecuteAsync(new RemoveSurveyedSurfaceArgument
                {
                    ProjectID = request.ProjectUid,
                    DesignID  = request.DesignUid
                });

                removedOk = removeResponse.RequestResult == DesignProfilerRequestResult.OK;
            }

            if (request.FileType == ImportedFileType.Alignment)
            {
                // Remove the alignment
                var tRexRequest    = new RemoveAlignmentRequest();
                var removeResponse = await tRexRequest.ExecuteAsync(new RemoveAlignmentArgument
                {
                    ProjectID   = request.ProjectUid,
                    AlignmentID = request.DesignUid
                });

                removedOk = removeResponse.RequestResult == DesignProfilerRequestResult.OK;
            }

            if (!removedOk)
            {
                log.LogError($"#Out# {executorName}. Deletion failed, of design:{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}");
                throw CreateServiceException <TExecutor>
                          (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError,
                          RequestErrorStatus.DesignImportUnableToDeleteDesign);
            }

            //Remove local copies of files
            var localPath            = FilePathHelper.GetTempFolderForProject(request.ProjectUid);
            var localPathAndFileName = Path.Combine(new[] { localPath, request.FileName });

            if (File.Exists(localPathAndFileName))
            {
                try
                {
                    File.Delete(localPathAndFileName);

                    if (request.FileType != ImportedFileType.Alignment)
                    {
                        //Delete index files
                        var indexFileName = SubGridIndexFileName(localPathAndFileName);
                        if (File.Exists(indexFileName))
                        {
                            File.Delete(indexFileName);
                        }
                        indexFileName = SpatialIndexFileName(localPathAndFileName);
                        if (File.Exists(indexFileName))
                        {
                            File.Delete(indexFileName);
                        }
                        indexFileName = BoundaryFileName(localPathAndFileName);
                        if (File.Exists(indexFileName))
                        {
                            File.Delete(indexFileName);
                        }
                    }
                }
                catch (Exception e)
                {
                    log.LogError(e, $"Failed to delete files related to design/surveyed surface {request.DesignUid} in project {request.ProjectUid}");
                }
            }

            if (request.FileType != ImportedFileType.Alignment)
            {
                //Remove the index files from s3 (project service removes the actual file from s3 as it put it there originally)
                var s3FileTransfer = new S3FileTransfer(TransferProxyType.DesignImport);
                s3FileTransfer.RemoveFileFromBucket(request.ProjectUid, SubGridIndexFileName(request.FileName));
                s3FileTransfer.RemoveFileFromBucket(request.ProjectUid, SpatialIndexFileName(request.FileName));
                s3FileTransfer.RemoveFileFromBucket(request.ProjectUid, BoundaryFileName(request.FileName));
            }
        }