Esempio n. 1
0
        public async Task <CMVChangeSummaryResult> PostExportSummaryCmvChangeTbc([FromBody] CMVChangeSummaryRequest request)
        {
            _log.LogDebug($"{nameof(PostExportSummaryCmvChangeTbc)}: {JsonConvert.SerializeObject(request)}");

            request.Validate();
            return(await RequestExecutorContainerFactory.Build <CMVChangeSummaryExecutor>(_logger,
#if RAPTOR
                                                                                          raptorClient,
#endif
                                                                                          configStore : configStore, trexCompactionDataProxy : tRexCompactionDataProxy,
                                                                                          fileImportProxy : FileImportProxy, customHeaders : CustomHeaders, userId : GetUserId())
                   .ProcessAsync(request) as CMVChangeSummaryResult);
        }
Esempio n. 2
0
        public async Task <CompactionCmvPercentChangeResult> GetCmvPercentChange(
            [FromQuery] Guid projectUid,
            [FromQuery] Guid?filterUid)
        {
            Log.LogInformation("GetCmvPercentChange: " + Request.QueryString);

            var validationResult = await ValidateFilterAgainstProjectExtents(projectUid, filterUid);

            if (!validationResult.isValidFilterForProjectExtents)
            {
                return(new CompactionCmvPercentChangeResult());
            }

            var filter = validationResult.filterResult == null?GetCompactionFilter(projectUid, filterUid) : Task.FromResult(validationResult.filterResult);

            var projectId       = GetLegacyProjectId(projectUid);
            var projectSettings = GetProjectSettingsTargets(projectUid);

            await Task.WhenAll(projectId, projectSettings, filter);

            var liftSettings = SettingsManager.CompactionLiftBuildSettings(projectSettings.Result);

            double[] cmvChangeSummarySettings = SettingsManager.CompactionCmvPercentChangeSettings(projectSettings.Result);

            var request = new CMVChangeSummaryRequest(projectId.Result, projectUid, null, liftSettings, filter.Result, -1, cmvChangeSummarySettings);

            request.Validate();

            try
            {
                var result = await RequestExecutorContainerFactory.Build <CMVChangeSummaryExecutor>(LoggerFactory,
#if RAPTOR
                                                                                                    RaptorClient,
#endif
                                                                                                    configStore : ConfigStore, trexCompactionDataProxy : TRexCompactionDataProxy, customHeaders : CustomHeaders,
                                                                                                    userId : GetUserId(), fileImportProxy : FileImportProxy)
                             .ProcessAsync(request) as CMVChangeSummaryResult;

                var returnResult = new CompactionCmvPercentChangeResult(result);
                Log.LogInformation("GetCmvPercentChange result: " + JsonConvert.SerializeObject(returnResult));

                await SetCacheControlPolicy(projectUid);

                return(returnResult);
            }
            catch (ServiceException exception)
            {
#if RAPTOR
                var statusCode = (TASNodeErrorStatus)exception.GetResult.Code == TASNodeErrorStatus.asneFailedToRequestDatamodelStatistics ? HttpStatusCode.NoContent : HttpStatusCode.BadRequest;

                throw new ServiceException(statusCode,
                                           new ContractExecutionResult(exception.GetResult.Code, exception.GetResult.Message));
#else
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, exception.Message));
#endif
            }
            finally
            {
                Log.LogInformation("GetCmvPercentChange returned: " + Response.StatusCode);
            }
        }