Пример #1
0
        public async Task <ContractExecutionResult> GetDesignBoundaries([FromQuery] Guid projectUid, [FromQuery] double?tolerance)
        {
            Log.LogInformation($"{nameof(GetDesignBoundaries)}: " + Request.QueryString);

            var projectId = await((RaptorPrincipal)User).GetLegacyProjectId(projectUid);

            tolerance ??= DesignBoundariesRequest.BOUNDARY_POINTS_INTERVAL;

            var request = new DesignBoundariesRequest(projectId, projectUid, tolerance.Value);

            request.Validate();

            var fileList = await FileImportProxy.GetFiles(projectUid.ToString(), GetUserId(), Request.Headers.GetCustomHeaders());

            fileList = fileList?.Where(f => f.ImportedFileType == ImportedFileType.DesignSurface && f.IsActivated).ToList();

            return(await RequestExecutorContainerFactory.Build <DesignExecutor>(
                       LoggerFactory,
                       configStore : ConfigStore,
                       fileList : fileList,
                       trexCompactionDataProxy : TRexCompactionDataProxy,
                       userId : GetUserId(),
                       fileImportProxy : FileImportProxy)
                   .ProcessAsync(request));
        }
Пример #2
0
        /// <summary>
        /// Gets the imported files of the specified type in a project
        /// </summary>
        /// <param name="projectUid">The project UID</param>
        /// <param name="fileType">The type of files to retrieve</param>
        /// <returns>List of active imported files of specified type</returns>
        private async Task <List <FileData> > GetFilesOfType(Guid projectUid, ImportedFileType fileType)
        {
            var fileList = await FileImportProxy.GetFiles(projectUid.ToString(), GetUserId(), CustomHeaders);

            if (fileList == null || fileList.Count == 0)
            {
                return(new List <FileData>());
            }

            return(fileList.Where(f => f.ImportedFileType == fileType && f.IsActivated).ToList());
        }
Пример #3
0
        public async Task <IActionResult> GetAlignmentGeometriesForRendering(
            [FromQuery] Guid projectUid,
            [FromQuery] bool convertArcsToChords,
            [FromQuery] double arcChordTolerance)
        {
            Log.LogInformation($"{nameof(GetAlignmentGeometriesForRendering)}: " + Request.QueryString);

            var fileList = await FileImportProxy.GetFiles(projectUid.ToString(), GetUserId(), Request.Headers.GetCustomHeaders());

            fileList = fileList?.Where(f => f.ImportedFileType == ImportedFileType.Alignment && f.IsActivated).ToList();

            if (fileList.Count > 0)
            {
                var alignmentGeometries = new List <AlignmentGeometry>();

                var tasks = new List <Task <ContractExecutionResult> >();

                foreach (var file in fileList)
                {
                    if (Guid.TryParse(file.ImportedFileUid, out var designUid))
                    {
                        Log.LogInformation($"Processing alignment data. File UID: {designUid}, File Name: {file.Name}");

                        var request = new AlignmentGeometryRequest(projectUid, designUid, convertArcsToChords, arcChordTolerance, file.Name);
                        request.Validate();

                        var result = RequestExecutorContainerFactory.Build <AlignmentGeometryExecutor>(LoggerFactory,
                                                                                                       configStore: ConfigStore, trexCompactionDataProxy: TRexCompactionDataProxy,
                                                                                                       userId: GetUserId(), fileImportProxy: FileImportProxy).ProcessAsync(request);

                        tasks.Add(result);
                    }
                    else
                    {
                        Log.LogInformation($"Invalid alignment data file UID: {designUid}. File Name: {file.Name}");
                    }
                }

                Task.WaitAll(tasks.ToArray());

                foreach (var task in tasks)
                {
                    alignmentGeometries.Add((task.Result as AlignmentGeometryResult).AlignmentGeometry);
                }

                return(StatusCode((int)HttpStatusCode.OK, alignmentGeometries.ToArray()));
            }

            Log.LogInformation($"Project {projectUid} does not have any alignment data.");

            return(NoContent());
        }
Пример #4
0
        /// <summary>
        /// Validates the file type for DXF tile request and gets the imported file data for it
        /// </summary>
        /// <param name="projectUid">The project UID where the files were imported</param>
        /// <param name="fileType">The file type of the imported files</param>
        /// <returns>The imported file data for the requested files</returns>
        private async Task <List <FileData> > ValidateFileType(Guid projectUid, string fileType)
        {
            //Check file type specified
            if (string.IsNullOrEmpty(fileType))
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "Missing file type"));
            }

            //Check file type is valid
            if (Enum.TryParse(fileType, true, out ImportedFileType importedFileType))
            {
                if (importedFileType != ImportedFileType.Linework &&
                    importedFileType != ImportedFileType.Alignment &&
                    importedFileType != ImportedFileType.DesignSurface)
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                           "Unsupported file type " + fileType));
                }
            }
            else
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "Invalid file type " + fileType));
            }

            //Get all the imported files for the project
            var fileList = await FileImportProxy.GetFiles(projectUid.ToString(), GetUserId(), Request.Headers.GetCustomHeaders()) ?? new List <FileData>();

            //Select the required ones from the list
            var filesOfType = fileList.Where(f => f.ImportedFileType == importedFileType && f.IsActivated).ToList();

            Log.LogInformation("Found {0} files of type {1} from a total of {2}", filesOfType.Count, fileType, fileList.Count);

            return(filesOfType);
        }