Пример #1
0
        public async Task <PointsListResult> GetFilterPointsList(
            [FromServices] ISummaryDataHelper summaryDataHelper,
            [FromQuery] Guid projectUid,
            [FromQuery] Guid?filterUid,
            [FromQuery] Guid?baseUid,
            [FromQuery] Guid?topUid,
            [FromQuery] FilterBoundaryType boundaryType,
            [FromServices] IBoundingBoxService boundingBoxService)
        {
            Log.LogInformation($"{nameof(GetFilterPointsList)}: " + Request.QueryString);

            var projectTask = ((RaptorPrincipal)User).GetProject(projectUid);
            var filterTask  = GetCompactionFilter(projectUid, filterUid);
            //Base or top may be a design UID
            var baseFilterTask = summaryDataHelper.WithSwallowExceptionExecute(() => GetCompactionFilter(projectUid, baseUid));
            var topFilterTask  = summaryDataHelper.WithSwallowExceptionExecute(() => GetCompactionFilter(projectUid, topUid));

            var result = new PointsListResult();

            await Task.WhenAll(projectTask, filterTask, baseFilterTask, topFilterTask);

            var polygons = await boundingBoxService.GetFilterBoundaries(projectTask.Result, filterTask.Result, baseFilterTask.Result, topFilterTask.Result, boundaryType, CustomHeaders);

            result.PointsList = ConvertPoints(polygons);

            return(result);
        }
Пример #2
0
        ResolveDesignAndFilterReferences(ISummaryDataHelper summaryDataHelper, Guid projectUid, Guid baseUid, Guid topUid)
        {
            DesignDescriptor baseDesign = null;
            DesignDescriptor topDesign  = null;
            FilterResult     baseFilter = null;
            FilterResult     topFilter  = null;

            // Base filter...
            var baseFilterDescriptor = await summaryDataHelper.WithSwallowExceptionExecute(async() => await GetFilterDescriptor(projectUid, baseUid));

            if (baseFilterDescriptor == null)
            {
                baseDesign = await summaryDataHelper.WithSwallowExceptionExecute(async() => await GetAndValidateDesignDescriptor(projectUid, baseUid));
            }
            else
            {
                baseFilter = await summaryDataHelper.WithSwallowExceptionExecute(async() => await GetCompactionFilter(projectUid, baseUid));
            }

            // Top filter...
            var topFilterDescriptor = await summaryDataHelper.WithSwallowExceptionExecute(async() => await GetFilterDescriptor(projectUid, topUid));

            if (topFilterDescriptor == null)
            {
                topDesign = await summaryDataHelper.WithSwallowExceptionExecute(async() => await GetAndValidateDesignDescriptor(projectUid, topUid));
            }
            else
            {
                topFilter = await summaryDataHelper.WithSwallowExceptionExecute(async() => await GetCompactionFilter(projectUid, topUid));
            }

            return(baseDesign, topDesign, baseFilter, topFilter);
        }
Пример #3
0
        public async Task <ActionResult <ContractExecutionResult> > GetProgressiveSummaryVolumes(
            [FromServices] ISummaryDataHelper summaryDataHelper,
            [FromQuery] Guid projectUid,
            [FromQuery] Guid baseUid,
            [FromQuery] Guid topUid,
            [FromQuery] double?cutTolerance,
            [FromQuery] double?fillTolerance,
            [FromQuery] Guid additionalSpatialFilterUid,
            [FromQuery] DateTime startDateUtc,
            [FromQuery] DateTime endDateUtc,
            [FromQuery] int intervalSeconds)
        {
            Log.LogInformation($"{nameof(GetSummaryVolumes)}: " + Request.QueryString);

            if (baseUid == Guid.Empty || topUid == Guid.Empty)
            {
                return(BadRequest(new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Invalid surface parameter(s).")));
            }

            var(baseDesign, topDesign, baseFilter, topFilter) = await ResolveDesignAndFilterReferences(summaryDataHelper, projectUid, baseUid, topUid);

            if (baseFilter == null && baseDesign == null || topFilter == null && topDesign == null)
            {
                return(BadRequest(new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Can not resolve either baseSurface or topSurface")));
            }

            var volumeCalcType = summaryDataHelper.GetVolumesType(baseFilter, topFilter);

            if (volumeCalcType == VolumesType.None)
            {
                return(BadRequest(new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Missing volumes calculation type")));
            }

            var additionalSpatialFilter = await summaryDataHelper.WithSwallowExceptionExecute(async() => await GetCompactionFilter(projectUid, additionalSpatialFilterUid));

            var projectId = await GetLegacyProjectId(projectUid);

            var request = ProgressiveSummaryVolumesRequest.CreateAndValidate(projectId, projectUid, baseFilter ?? topFilter, baseDesign, topDesign, volumeCalcType, cutTolerance, fillTolerance, additionalSpatialFilter, startDateUtc, endDateUtc, intervalSeconds);

            CompactionProgressiveVolumesSummaryResult volumesSummaryResult;

            try
            {
                var result = await RequestExecutorContainerFactory
                             .Build <ProgressiveSummaryVolumesExecutor>(LoggerFactory,
                                                                        configStore : ConfigStore, trexCompactionDataProxy : TRexCompactionDataProxy, customHeaders : CustomHeaders)
                             .ProcessAsync(request) as ProgressiveSummaryVolumesResult;

                if (result == null)
                {
                    return(Ok(new CompactionProgressiveVolumesSummaryResult(0, "No production data found")));
                }

                volumesSummaryResult = CompactionProgressiveVolumesSummaryResult.Create(result, await GetProjectSettingsTargets(projectUid));
            }
            catch (ServiceException exception)
            {
                Log.LogError($"{nameof(GetProgressiveSummaryVolumes)}: {exception.GetResult.Message} ({exception.GetResult.Code})");
                return(BadRequest(new ContractExecutionResult(exception.GetResult.Code, exception.GetResult.Message)));
            }
            finally
            {
                Log.LogInformation($"{nameof(GetProgressiveSummaryVolumes)} returned: " + Response.StatusCode);
            }

            if (Log.IsTraceEnabled())
            {
                Log.LogTrace($"{nameof(GetProgressiveSummaryVolumes)} result: " + JsonConvert.SerializeObject(volumesSummaryResult));
            }

            return(Ok(volumesSummaryResult));
        }