示例#1
0
        public void Success()
        {
            var projectUid = Guid.NewGuid();
            var designUid  = Guid.NewGuid();

            var request        = new AlignmentGeometryRequest(projectUid, designUid, false, 0.0);
            var expectedResult = new AlignmentGeometryResult
                                 (
                0,
                new AlignmentGeometry
                (
                    designUid,
                    "",
                    new[] { new[] { new double[] { 1, 2, 3 } } },
                    new[] { new AlignmentGeometryResultArc(0, 1, 2, 3, 4, 5, 6, 7, 8, true) },
                    new[] { new AlignmentGeometryResultLabel(0, 1, 2, 3), }
                )
                                 );

            var tRexProxy = new Mock <ITRexCompactionDataProxy>();

            tRexProxy.Setup(x => x.SendDataGetRequest <AlignmentGeometryResult>(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <IHeaderDictionary>(), It.IsAny <List <KeyValuePair <string, string> > >()))
            .ReturnsAsync(expectedResult);

            var executor = RequestExecutorContainerFactory
                           .Build <AlignmentGeometryExecutor>(logger, trexCompactionDataProxy: tRexProxy.Object, customHeaders: _customHeaders);

            var result = executor.ProcessAsync(request).Result as AlignmentGeometryResult;

            result.Should().NotBeNull();
            result.Should().BeEquivalentTo(expectedResult);
        }
示例#2
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());
        }
示例#3
0
        public async Task <ContractExecutionResult> GetAlignmentGeometryForRendering(
            [FromQuery] Guid projectUid,
            [FromQuery] Guid designUid,
            [FromQuery] string fileName,
            [FromQuery] bool convertArcsToChords,
            [FromQuery] double arcChordTolerance)
        {
            Log.LogInformation($"{nameof(GetAlignmentGeometryForRendering)}: " + Request.QueryString);

            var request = new AlignmentGeometryRequest(projectUid, designUid, convertArcsToChords, arcChordTolerance, fileName);

            request.Validate();

            return(await RequestExecutorContainerFactory.Build <AlignmentGeometryExecutor>(LoggerFactory,
                                                                                           configStore : ConfigStore, trexCompactionDataProxy : TRexCompactionDataProxy,
                                                                                           userId : GetUserId(), fileImportProxy : FileImportProxy).ProcessAsync(request));
        }
示例#4
0
        public void Failure()
        {
            var projectUid = Guid.NewGuid();
            var designUid  = Guid.NewGuid();

            var request = new AlignmentGeometryRequest(projectUid, designUid, false, 0.0);
            AlignmentGeometryResult expectedResult = null;

            var tRexProxy = new Mock <ITRexCompactionDataProxy>();

            tRexProxy.Setup(x => x.SendDataGetRequest <AlignmentGeometryResult>(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <IHeaderDictionary>(), It.IsAny <List <KeyValuePair <string, string> > >()))
            .ReturnsAsync(expectedResult);

            var executor = RequestExecutorContainerFactory
                           .Build <AlignmentGeometryExecutor>(logger, trexCompactionDataProxy: tRexProxy.Object, customHeaders: _customHeaders);

            Action act = () => _ = executor.ProcessAsync(request).Result as AlignmentGeometryResult;

            act.Should().Throw <ServiceException>().WithMessage($"Failed to get alignment center line geometry for alignment: {designUid}");
        }