Exemple #1
0
        /// <summary>
        /// Processes the summary pass counts request by passing the request to TRex and returning the result.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item"></param>
        /// <returns></returns>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <ExportGridCSV>(item);

                if (request.reportType == GriddedCSVReportType.Alignment)
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "TRex unsupported request"));
                }

                var overrides    = AutoMapperUtility.Automapper.Map <OverridingTargets>(request.liftBuildSettings);
                var liftSettings = AutoMapperUtility.Automapper.Map <LiftSettings>(request.liftBuildSettings);

                var compactionReportGridRequest = new CompactionReportGridTRexRequest
                                                  (
                    request.ProjectUid.Value,
                    request.filter,
                    request.reportElevation,
                    request.reportCMV,
                    request.reportMDP,
                    request.reportPassCount,
                    request.reportTemperature,
                    request.reportCutFill,
                    request.designFile?.FileUid,
                    request.designFile?.Offset,
                    request.interval,
                    request.reportOption,
                    request.startNorthing,
                    request.startEasting,
                    request.endNorthing,
                    request.endEasting,
                    request.direction,
                    overrides,
                    liftSettings
                                                  );

                log.LogInformation($"Calling TRex SendCompactionReportGridRequest for projectUid: {request.ProjectUid}");

                var responseData = await trexCompactionDataProxy.SendDataPostRequestWithStreamResponse(compactionReportGridRequest, "/report/grid", customHeaders);

                return(responseData.Length > 0
          ? ConvertTRexGridResult(responseData)
          : CreateNullGridReturnedResult());
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #2
0
        /// <summary>
        /// Processes the exports request by passing the request to Raptor and returning the result.
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <ExportReport>(item);
#if RAPTOR
                if (UseTRexGateway(configKeys[request.ExportType]))
                {
#endif
                var overrides    = AutoMapperUtility.Automapper.Map <OverridingTargets>(request.LiftBuildSettings);
                var liftSettings = AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings);
                switch (request.ExportType)
                {
                case ExportTypes.SurfaceExport:
                    var compactionSurfaceExportRequest =
                        new CompactionSurfaceExportRequest(request.ProjectUid.Value, request.Filter, request.Filename, request.Tolerance,
                                                           overrides, liftSettings);

                    log.LogInformation($"Calling TRex SendSurfaceExportRequest for projectUid: {request.ProjectUid}");
                    return(await trexCompactionDataProxy.SendDataPostRequest <CompactionExportResult, CompactionSurfaceExportRequest>(compactionSurfaceExportRequest, "/export/surface/ttm", customHeaders));

                case ExportTypes.VedaExport:
                default://to satisfy the compiler
                    var compactionVetaExportRequest =
                        new CompactionVetaExportRequest(request.ProjectUid.Value, request.Filter, request.Filename, request.CoordType,
                                                        request.OutputType, request.UserPrefs, request.MachineList.Select(m => m.MachineName).ToArray(), overrides, liftSettings);

                    log.LogInformation($"Calling TRex SendVetaExportRequest for projectUid: {request.ProjectUid}");
                    return(await trexCompactionDataProxy.SendDataPostRequest <CompactionExportResult, CompactionVetaExportRequest>(compactionVetaExportRequest, "/export/veta", customHeaders));

                case ExportTypes.PassCountExport:
                    var compactionPassCountExportRequest =
                        new CompactionPassCountExportRequest(request.ProjectUid.Value, request.Filter, request.Filename, request.CoordType,
                                                             request.OutputType, request.UserPrefs, request.RestrictSize, request.RawData, overrides, liftSettings);

                    log.LogInformation($"Calling TRex SendPassCountExportRequest for projectUid: {request.ProjectUid}");
                    return(await trexCompactionDataProxy.SendDataPostRequest <CompactionExportResult, CompactionPassCountExportRequest>(compactionPassCountExportRequest, "/export/passcount", customHeaders));
                }
#if RAPTOR
            }
            log.LogInformation($"Calling Raptor ProcessWithRaptor for projectUid: {request.ProjectUid}");
            return(ProcessWithRaptor(request));
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #3
0
        /// <summary>
        /// Processes the summary CMV request by passing the request to Raptor and returning the result.
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <CMVRequest>(item);
#if RAPTOR
                if (configStore.GetValueBool("ENABLE_TREX_GATEWAY_CMV") ?? false)
                {
#endif
                await PairUpAssetIdentifiers(request.ProjectUid.Value, request.Filter);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, filter1 : request.Filter);

                var cmvSummaryRequest = new CMVSummaryRequest(
                    request.ProjectUid.Value,
                    request.Filter,
                    request.CmvSettings.CmvTarget,
                    request.CmvSettings.OverrideTargetCMV,
                    request.CmvSettings.MaxCMVPercent,
                    request.CmvSettings.MinCMVPercent, AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));
                log.LogDebug($"{nameof(SummaryCMVExecutor)} trexRequest {JsonConvert.SerializeObject(cmvSummaryRequest)}");

                return(await trexCompactionDataProxy.SendDataPostRequest <CMVSummaryResult, CMVSummaryRequest>(cmvSummaryRequest, "/cmv/summary", customHeaders));

#if RAPTOR
            }

            var raptorFilter = RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient, request.OverrideStartUTC, request.OverrideEndUTC, request.OverrideAssetIds);

            var raptorResult = raptorClient.GetCMVSummary(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                          ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor(request.CallId ?? Guid.NewGuid(), 0, TASNodeCancellationDescriptorType.cdtCMVSummary),
                                                          ConvertSettings(request.CmvSettings),
                                                          raptorFilter,
                                                          RaptorConverters.ConvertLift(request.LiftBuildSettings, raptorFilter.LayerMethod),
                                                          out var cmvSummary);

            if (raptorResult == TASNodeErrorStatus.asneOK)
            {
                return(ConvertResult(cmvSummary));
            }

            throw CreateServiceException <SummaryCMVExecutor>((int)raptorResult);
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #4
0
        protected ServiceException CreateServiceException <T>(HttpStatusCode statusCode, int contractExecutionStatesEnum, RequestErrorStatus resultStatus = RequestErrorStatus.OK, string detailedMessage = null)
        {
            var errorMessage = string.Format(ERROR_MESSAGE, typeof(T).Name);

            if (resultStatus != RequestErrorStatus.OK)
            {
                errorMessage = string.Format(ERROR_MESSAGE_EX, errorMessage, ContractExecutionStates.FirstNameWithOffset((int)resultStatus));
            }

            if (!string.IsNullOrEmpty(detailedMessage))
            {
                errorMessage += $" ({detailedMessage})";
            }

            return(new ServiceException(statusCode, new ContractExecutionResult(contractExecutionStatesEnum, errorMessage)));
        }
Exemple #5
0
        /// <summary>
        /// Processes the detailed pass counts request by passing the request to Raptor and returning the result.
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <PassCounts>(item);
#if RAPTOR
                if (UseTRexGateway("ENABLE_TREX_GATEWAY_PASSCOUNT"))
                {
#endif
                await PairUpAssetIdentifiers(request.ProjectUid.Value, request.Filter);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, filter1 : request.Filter);

                var pcDetailsRequest = new PassCountDetailsRequest(
                    request.ProjectUid.Value,
                    request.Filter,
                    request.passCountSettings.passCounts,
                    AutoMapperUtility.Automapper.Map <OverridingTargets>(request.liftBuildSettings),
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.liftBuildSettings));
                log.LogDebug($"{nameof(DetailedPassCountExecutor)} trexRequest {JsonConvert.SerializeObject(pcDetailsRequest)}");

                return(await trexCompactionDataProxy.SendDataPostRequest <PassCountDetailedResult, PassCountDetailsRequest>(pcDetailsRequest, "/passcounts/details", customHeaders));

#if RAPTOR
            }

            var raptorFilter = RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient, request.OverrideStartUTC, request.OverrideEndUTC, request.OverrideAssetIds);
            var raptorResult = raptorClient.GetPassCountDetails(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                                ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor((request.CallId ?? Guid.NewGuid()), 0,
                                                                                                                      TASNodeCancellationDescriptorType.cdtPassCountDetailed),
                                                                request.passCountSettings != null ? ConvertSettings(request.passCountSettings) : new TPassCountSettings(),
                                                                raptorFilter,
                                                                RaptorConverters.ConvertLift(request.liftBuildSettings, raptorFilter.LayerMethod),
                                                                out var passCountDetails);

            if (raptorResult == TASNodeErrorStatus.asneOK)
            {
                return(ConvertResult(passCountDetails, request.liftBuildSettings));
            }

            throw CreateServiceException <DetailedPassCountExecutor>((int)raptorResult);
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #6
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <CMVChangeSummaryRequest>(item);
#if RAPTOR
                if (UseTRexGateway("ENABLE_TREX_GATEWAY_CMV"))
                {
#endif
                await PairUpAssetIdentifiers(request.ProjectUid.Value, request.Filter);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, filter1 : request.Filter);

                var cmvChangeDetailsRequest = new CMVChangeDetailsRequest(
                    request.ProjectUid.Value,
                    request.Filter,
                    request.CMVChangeSummaryValues,
                    AutoMapperUtility.Automapper.Map <OverridingTargets>(request.LiftBuildSettings),
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));
                return(await trexCompactionDataProxy.SendDataPostRequest <CMVChangeSummaryResult, CMVChangeDetailsRequest>(cmvChangeDetailsRequest, "/cmv/percentchange", customHeaders));

#if RAPTOR
            }
            new TASNodeCMVChangeResult();

            TASNodeCMVChangeSettings settings = new TASNodeCMVChangeSettings(request.CMVChangeSummaryValues);

            var raptorResult = raptorClient.GetCMVChangeSummary(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                                ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor(request.CallId ?? Guid.NewGuid(), 0,
                                                                                                                      TASNodeCancellationDescriptorType.cdtCMVChange),
                                                                settings,
                                                                RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient, overrideAssetIds: new List <long>()),
                                                                RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmAutomatic),
                                                                out var result);

            if (raptorResult == TASNodeErrorStatus.asneOK)
            {
                return(ConvertResult(result));
            }

            throw CreateServiceException <CMVChangeSummaryExecutor>((int)raptorResult);
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #7
0
        /// <summary>
        /// Coordinate conversion executor (Post).
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item">A Domain object.</param>
        /// <returns></returns>
        ///
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            if (item != null)
            {
                try
                {
                    var request = CastRequestObjectTo <CoordinateConversionRequest>(item);
#if RAPTOR
                    if (UseTRexGateway("ENABLE_TREX_GATEWAY_CS") || UseTRexGateway("ENABLE_TREX_GATEWAY_PROJECTSTATISTICS"))
                    {
#endif
                    return(await trexCompactionDataProxy.SendDataPostRequest <CoordinateConversionResult, CoordinateConversionRequest>(request, "/coordinateconversion", customHeaders));

#if RAPTOR
                }

                var latLongs = new TWGS84FenceContainer {
                    FencePoints = request.ConversionCoordinates.Select(cc => TWGS84Point.Point(cc.X, cc.Y)).ToArray()
                };

                var code = raptorClient.GetGridCoordinates
                           (
                    request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                    latLongs,
                    request.ConversionType == TwoDCoordinateConversionType.LatLonToNorthEast ? TCoordConversionType.ctLLHtoNEE : TCoordConversionType.ctNEEtoLLH,
                    out var pointList
                           );

                if (code == TCoordReturnCode.nercNoError)
                {
                    return(ExecutionResult(pointList.Points.Coords));
                }

                throw CreateServiceException <CoordinateConversionExecutor>((int)code);
#endif
                }
                finally
                {
                    ContractExecutionStates.ClearDynamic();
                }
            }

            throw new ServiceException(HttpStatusCode.BadRequest,
                                       new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
                                                                   "No  coordinate conversion request sent."));
        }
Exemple #8
0
        /// <summary>
        /// Processes the summary MDP request by passing the request to Raptor and returning the result.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item"></param>
        /// <returns>a CMVSummaryResult if successful</returns>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <MDPRequest>(item);
#if RAPTOR
                if (configStore.GetValueBool("ENABLE_TREX_GATEWAY_MDP") ?? false)
                {
#endif
                var mdpSummaryRequest = new MDPSummaryRequest(
                    request.ProjectUid.Value,
                    request.Filter,
                    request.MdpSettings.MdpTarget,
                    request.MdpSettings.OverrideTargetMDP,
                    request.MdpSettings.MaxMDPPercent,
                    request.MdpSettings.MinMDPPercent,
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));

                return(await trexCompactionDataProxy.SendDataPostRequest <MDPSummaryResult, MDPSummaryRequest>(mdpSummaryRequest, "/mdp/summary", customHeaders));

#if RAPTOR
            }

            string fileSpaceName = FileDescriptorExtensions.GetFileSpaceId(configStore, log);

            var raptorFilter = RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient, request.OverrideStartUtc, request.OverrideEndUtc, request.OverrideAssetIds, fileSpaceName);
            var raptorResult = raptorClient.GetMDPSummary(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                          ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor((request.CallId ?? Guid.NewGuid()), 0, TASNodeCancellationDescriptorType.cdtMDPSummary),
                                                          ConvertSettings(request.MdpSettings),
                                                          raptorFilter,
                                                          RaptorConverters.ConvertLift(request.LiftBuildSettings, raptorFilter.LayerMethod),
                                                          out var mdpSummary);

            if (raptorResult == TASNodeErrorStatus.asneOK)
            {
                return(ConvertResult(mdpSummary));
            }

            throw CreateServiceException <SummaryMDPExecutor>((int)raptorResult);
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #9
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <SummaryVolumesRequest>(item);

                var baseFilter = request.BaseFilter;
                var topFilter  = request.TopFilter;
                await PairUpAssetIdentifiers(request.ProjectUid.Value, baseFilter, topFilter);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, filter1 : baseFilter, filter2 : topFilter);

                var designDescriptors = new List <DesignDescriptor>();
                designDescriptors.Add(request.BaseDesignDescriptor);
                designDescriptors.Add(request.TopDesignDescriptor);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, designDescriptors);

                if (request.VolumeCalcType == VolumesType.Between2Filters)
                {
                    if (!request.ExplicitFilters)
                    {
                        (baseFilter, topFilter) = FilterUtilities.AdjustFilterToFilter(request.BaseFilter, request.TopFilter);
                    }
                }
                else
                {
                    (baseFilter, topFilter) = FilterUtilities.ReconcileTopFilterAndVolumeComputationMode(baseFilter, topFilter, request.VolumeCalcType);
                }

                var summaryVolumesRequest = new SummaryVolumesDataRequest(
                    request.ProjectUid,
                    baseFilter,
                    topFilter,
                    request.BaseDesignDescriptor.FileUid,
                    request.BaseDesignDescriptor.Offset,
                    request.TopDesignDescriptor.FileUid,
                    request.TopDesignDescriptor.Offset,
                    request.VolumeCalcType);
                log.LogDebug($"{nameof(SummaryVolumesExecutor)} trexRequest {JsonConvert.SerializeObject(summaryVolumesRequest)}");
                return(await trexCompactionDataProxy.SendDataPostRequest <SummaryVolumesResult, SummaryVolumesDataRequest>(summaryVolumesRequest, "/volumes/summary", customHeaders));
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #10
0
        /// <summary>
        /// Processes the summary CCA request by passing the request to Raptor and returning the result.
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <CCARequest>(item);
#if RAPTOR
                if (configStore.GetValueBool("ENABLE_TREX_GATEWAY_CCA") ?? false)
                {
#endif
                await PairUpAssetIdentifiers(request.ProjectUid.Value, request.Filter);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, filter1 : request.Filter);

                var ccaSummaryRequest = new CCASummaryRequest(
                    request.ProjectUid.Value,
                    request.Filter,
                    AutoMapperUtility.Automapper.Map <OverridingTargets>(request.LiftBuildSettings),
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));

                return(await trexCompactionDataProxy.SendDataPostRequest <CCASummaryResult, CCASummaryRequest>(ccaSummaryRequest, "/cca/summary", customHeaders));

#if RAPTOR
            }

            var raptorFilter = RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient);

            bool success = raptorClient.GetCCASummary(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                      ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor(request.CallId ?? Guid.NewGuid(), 0, TASNodeCancellationDescriptorType.cdtCCASummary),
                                                      raptorFilter,
                                                      RaptorConverters.ConvertLift(request.LiftBuildSettings, raptorFilter.LayerMethod),
                                                      out var ccaSummary);

            if (success)
            {
                return(ConvertResult(ccaSummary));
            }

            throw CreateServiceException <SummaryCCAExecutor>(ccaSummary.ReturnCode);
#endif
            }

            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #11
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <AlignmentLineworkRequest>(item);

                if (UseTRexGateway("ENABLE_TREX_GATEWAY_DESIGN_BOUNDARY"))
                {
                    return(await ProcessWithTRex(request));
                }

                return(ProcessWithRaptor(request));
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #12
0
        /// <summary>
        ///  CCA data colour palettes executor.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item">A Domain object.</param>
        /// <returns>An instance of the ContractExecutionResult class with CCA data colour palettes.</returns>}
        ///
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            if (item != null)
            {
                try
                {
                    var request = CastRequestObjectTo <CCAColorPaletteRequest>(item);
#if RAPTOR
                    if (configStore.GetValueBool("ENABLE_TREX_GATEWAY_CCA_PALETTE") ?? false)
                    {
#endif
                    var filter = FilterResult.CreateFilterForCCATileRequest
                                 (
                        request.startUtc,
                        request.endUtc,
                        new List <long> {
                        request.assetId
                    },
                        null,
                        request.liftId.HasValue ? FilterLayerMethod.TagfileLayerNumber : FilterLayerMethod.None,
                        request.liftId,
                        new List <MachineDetails> {
                        new MachineDetails(request.assetId, null, false, request.assetUid)
                    }
                                 );
                    var trexRequest = new CCAColorPaletteTrexRequest(request.ProjectUid.Value, filter);
                    return(await trexCompactionDataProxy.SendDataPostRequest <CCAColorPaletteResult, CCAColorPaletteTrexRequest>(trexRequest, "/ccacolors", customHeaders));

#if RAPTOR
                }

                return(ProcessWithRaptor(request));
#endif
                }
                finally
                {
                    ContractExecutionStates.ClearDynamic();
                }
            }

            throw new ServiceException(HttpStatusCode.BadRequest,
                                       new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
                                                                   "No CCA data colour palettes request sent."));
        }
Exemple #13
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <SummarySpeedRequest>(item);
#if RAPTOR
                if (configStore.GetValueBool("ENABLE_TREX_GATEWAY_SPEED") ?? false)
                {
#endif
                await PairUpAssetIdentifiers(request.ProjectUid.Value, request.Filter);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, filter1 : request.Filter);

                var speedSummaryRequest = new SpeedSummaryRequest(
                    request.ProjectUid.Value,
                    request.Filter,
                    request.LiftBuildSettings.MachineSpeedTarget,
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));

                return(await trexCompactionDataProxy.SendDataPostRequest <SpeedSummaryResult, SpeedSummaryRequest>(speedSummaryRequest, "/speed/summary", customHeaders));

#if RAPTOR
            }

            var raptorResult = raptorClient.GetSummarySpeed(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                            ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor((request.CallId ?? Guid.NewGuid()), 0,
                                                                                                                  TASNodeCancellationDescriptorType.cdtVolumeSummary),
                                                            RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient, overrideAssetIds: new List <long>()),
                                                            RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmNone),
                                                            out var result);

            if (raptorResult == TASNodeErrorStatus.asneOK)
            {
                return(ConvertResult(result));
            }

            throw CreateServiceException <SummarySpeedExecutor>((int)raptorResult);
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #14
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <GetEditDataRequest>(item);
#if RAPTOR
                if (UseTRexGateway("ENABLE_TREX_GATEWAY_EDIT_DATA"))
                {
#endif
                var projectIds = new ProjectIDs(request.ProjectId.Value, request.ProjectUid.Value);
                projectIds.Validate();
                var assetUid = await GetAssetUid(projectIds, request.assetId);

                var parameters = new Dictionary <string, string>
                {
                    { "projectUid", request.ProjectUid.Value.ToString() }
                }
                ;
                if (assetUid.HasValue)
                {
                    parameters.Add("assetUid", assetUid.ToString());
                }
                var queryParams = $"?{new System.Net.Http.FormUrlEncodedContent(parameters).ReadAsStringAsync().Result}";
                var results     = await trexCompactionDataProxy.SendDataGetRequest <TRexEditDataResult>(request.ProjectUid.Value.ToString(), $"/productiondataedit{queryParams}", customHeaders);

                var assetMatches = await GetAssetIds(projectIds, results.DataEdits.Select(d => d.AssetUid).ToList());

                var convertedResults = from d in results.DataEdits select ProductionDataEdit.CreateProductionDataEdit(assetMatches[d.AssetUid], d.StartUtc, d.EndUtc, d.MachineDesignName, d.LiftNumber);

                return(EditDataResult.CreateEditDataResult(convertedResults.ToList()));

#if RAPTOR
            }

            return(ProcessWithRaptor(request));
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #15
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <PatchRequest>(item);

                var filter1 = request.Filter1;
                var filter2 = request.Filter2;
                if (request.ComputeVolType == VolumesType.Between2Filters)
                {
                    (filter1, filter2) = FilterUtilities.AdjustFilterToFilter(request.Filter1, request.Filter2);
                }
                else
                {
                    (filter1, filter2) = FilterUtilities.ReconcileTopFilterAndVolumeComputationMode(filter1, filter2, request.Mode, request.ComputeVolType);
                }

                await PairUpAssetIdentifiers(request.ProjectUid.Value, filter1, filter2);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, request.DesignDescriptor, filter1, filter2);

                var patchDataRequest = new PatchDataRequest(
                    request.ProjectUid.Value,
                    filter1,
                    filter2,
                    request.Mode,
                    request.PatchNumber,
                    request.PatchSize,
                    AutoMapperUtility.Automapper.Map <OverridingTargets>(request.LiftBuildSettings),
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));
                log.LogDebug($"{nameof(PatchExecutor)} patchDataRequest {JsonConvert.SerializeObject(patchDataRequest)}");

                var fileResult = await trexCompactionDataProxy.SendDataPostRequestWithStreamResponse(patchDataRequest, "/patches", customHeaders);

                return(fileResult.Length > 0
          ? ConvertPatchResult(fileResult, request)
          : new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError, "Null patch returned"));
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #16
0
        /// <summary>
        /// Calls raptor to get project extents
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var  request = CastRequestObjectTo <ExtentRequest>(item);
                bool success;
                BoundingBox3DGrid bbExtents = null;
#if RAPTOR
                if (UseTRexGateway("ENABLE_TREX_GATEWAY_TILES"))
                {
#endif
                var siteModelId = request.ProjectUid.ToString();

                bbExtents = await trexCompactionDataProxy.SendDataGetRequest <BoundingBox3DGrid>(siteModelId, $"/sitemodels/{siteModelId}/extents", customHeaders);

                success = bbExtents != null;
#if RAPTOR
            }
            else
            {
                success = raptorClient.GetDataModelExtents(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                           RaptorConverters.convertSurveyedSurfaceExlusionList(request.excludedSurveyedSurfaceIds),
                                                           out var extents);

                bbExtents = RaptorConverters.ConvertExtents(extents);
            }
#endif
                if (success)
                {
                    if (bbExtents.ValidExtents)
                    {
                        return(ProjectExtentsResult.CreateProjectExtentsResult(bbExtents));
                    }
                }

                throw CreateServiceException <ProjectExtentsSubmitter>();
            }
            finally
            {
                ContractExecutionStates.ClearDynamic(); // clear memory
            }
        }
Exemple #17
0
        private CompactionProfileResult <CompactionProfileVertex> PerformProductionDataProfilePost(CompactionProfileDesignRequest request)
        {
            CompactionProfileResult <CompactionProfileVertex> result;

            try
            {
                ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out TWGS84Point startPt, out TWGS84Point endPt, out bool positionsAreGrid);

                var designProfile = DesignProfiler.ComputeProfile.RPC.__Global.Construct_CalculateDesignProfile_Args(
                    request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                    false,
                    startPt,
                    endPt,
                    ValidationConstants3D.MIN_STATION,
                    ValidationConstants3D.MAX_STATION,
                    RaptorConverters.DesignDescriptor(request.DesignDescriptor),
                    RaptorConverters.EmptyDesignDescriptor,
                    RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient),
                    positionsAreGrid);

                var memoryStream = raptorClient.GetDesignProfile(designProfile);

                if (memoryStream != null)
                {
                    result = ConvertProfileResult(memoryStream);
                    memoryStream.Close();
                }
                else
                {
                    //For convenience return empty list rather than null for easier manipulation
                    result = new CompactionProfileResult <CompactionProfileVertex> {
                        results = new List <CompactionProfileVertex>()
                    };
                }
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }

            return(result);
        }
Exemple #18
0
        /// <summary>
        /// Processes the summary Temperature request by passing the request to Raptor and returning the result.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item"></param>
        /// <returns>a TemperatureSummaryResult if successful</returns>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <TemperatureRequest>(item);
#if RAPTOR
                if (configStore.GetValueBool("ENABLE_TREX_GATEWAY_TEMPERATURE") ?? false)
                {
#endif
                var temperatureSummaryRequest = new TemperatureSummaryRequest(
                    request.ProjectUid.Value,
                    request.Filter,
                    request.TemperatureSettings,
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));

                return(await trexCompactionDataProxy.SendDataPostRequest <TemperatureSummaryResult, TemperatureSummaryRequest>(temperatureSummaryRequest, "/temperature/summary", customHeaders));

#if RAPTOR
            }

            var raptorFilter = RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient, request.OverrideStartUTC, request.OverrideEndUTC, request.OverrideAssetIds);

            var raptorResult = raptorClient.GetTemperatureSummary(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                                  ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor((request.CallId ?? Guid.NewGuid()), 0, TASNodeCancellationDescriptorType.cdtTemperature),
                                                                  ConvertSettings(request.TemperatureSettings),
                                                                  raptorFilter,
                                                                  RaptorConverters.ConvertLift(request.LiftBuildSettings, raptorFilter.LayerMethod),
                                                                  out var temperatureSummary);

            if (raptorResult == TASNodeErrorStatus.asneOK)
            {
                return(ConvertResult(temperatureSummary));
            }

            throw CreateServiceException <SummaryTemperatureExecutor>((int)raptorResult);
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #19
0
        /// <summary>
        /// Processes the request for type of T.
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <TileRequest>(item);

                var filter1 = request.Filter1;
                var filter2 = request.Filter2;
                if (request.ComputeVolumesType == VolumesType.Between2Filters && !request.ExplicitFilters)
                {
                    (filter1, filter2) = FilterUtilities.AdjustFilterToFilter(request.Filter1, request.Filter2);
                }

                var trexRequest = new TRexTileRequest(
                    request.ProjectUid.Value,
                    request.Mode,
                    request.Palettes,
                    request.DesignDescriptor,
                    filter1,
                    filter2,
                    request.BoundBoxLatLon,
                    request.BoundBoxGrid,
                    request.Width,
                    request.Height,
                    AutoMapperUtility.Automapper.Map <OverridingTargets>(request.LiftBuildSettings),
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings),
                    request.ComputeVolumesType
                    );
                var fileResult = await trexCompactionDataProxy.SendDataPostRequestWithStreamResponse(trexRequest, "/tile", customHeaders);

                using (var ms = new MemoryStream())
                {
                    fileResult.CopyTo(ms);
                    return(new TileResult(ms.ToArray()));
                }
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #20
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <EditDataRequest>(item);
                //Note: request.dataEdit should only be null for a global undo. This is checked in request model validation
                //so the following should never happen. But just in case...
                if (request.dataEdit == null && !request.undo)
                {
                    return(new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError, "No data edit to perform"));
                }

#if RAPTOR
                if (UseTRexGateway("ENABLE_TREX_GATEWAY_EDIT_DATA"))
                {
#endif
                var projectIds = new ProjectIDs(request.ProjectId.Value, request.ProjectUid.Value);
                projectIds.Validate();
                var assetUid = await GetAssetUid(projectIds, request.dataEdit.assetId);

                var trexRequest = new TRexEditData(assetUid ?? Guid.Empty, request.dataEdit.startUTC, request.dataEdit.endUTC, request.dataEdit.onMachineDesignName, request.dataEdit.liftNumber);
                var trexResult  = await trexCompactionDataProxy.SendDataDeleteRequest <ContractExecutionResult, TRexEditData>(trexRequest, "/productiondataedit", customHeaders, true);

                if (trexResult.Code != ContractExecutionStatesEnum.ExecutedSuccessfully)
                {
                    throw new ServiceException(HttpStatusCode.BadRequest, trexResult);
                }

                return(trexResult);

#if RAPTOR
            }

            return(ProcessWithRaptor(request));
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #21
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            // Note: The numPatches out parameter is ignored in favor of the same value returned in the PatchResult proper. This will be removed
            // in due course once the breaking modifications process is agreed with BC.
            try
            {
                var request = CastRequestObjectTo <PatchRequest>(item);

                var filter1 = request.Filter1;
                var filter2 = request.Filter2;
                if (request.ComputeVolType == VolumesType.Between2Filters)
                {
                    (filter1, filter2) = FilterUtilities.AdjustFilterToFilter(request.Filter1, request.Filter2);
                }
                else
                {
                    (filter1, filter2) = FilterUtilities.ReconcileTopFilterAndVolumeComputationMode(filter1, filter2, request.Mode, request.ComputeVolType);
                }

                var patchDataRequest = new PatchDataRequest(
                    request.ProjectUid.Value,
                    filter1,
                    filter2,
                    request.Mode,
                    request.PatchNumber,
                    request.PatchSize,
                    AutoMapperUtility.Automapper.Map <OverridingTargets>(request.LiftBuildSettings),
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));

                var fileResult = await trexCompactionDataProxy.SendDataPostRequestWithStreamResponse(patchDataRequest, "/patches", customHeaders);

                return(fileResult.Length > 0
            ? ConvertPatchResult(fileResult, true)
            : CreateNullPatchReturnedResult());
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #22
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <SummaryVolumesRequest>(item);

                var baseFilter = request.BaseFilter;
                var topFilter  = request.TopFilter;
                if (request.VolumeCalcType == VolumesType.Between2Filters)
                {
                    if (!request.ExplicitFilters)
                    {
                        (baseFilter, topFilter) = FilterUtilities.AdjustFilterToFilter(request.BaseFilter, request.TopFilter);
                    }
                }
                else
                {
                    // Note: The use of the ReconcileTopFilterAndVolumeComputationMode() here breaks with the pattern of all the other V2
                    // end points which explicitly do not perform this step. It has been copied from the Raptor implementation of this end point
                    (baseFilter, topFilter) = FilterUtilities.ReconcileTopFilterAndVolumeComputationMode(baseFilter, topFilter, request.VolumeCalcType);
                }

                var summaryVolumesRequest = new SummaryVolumesDataRequest(
                    request.ProjectUid,
                    baseFilter,
                    topFilter,
                    request.BaseDesignDescriptor?.FileUid,
                    request.BaseDesignDescriptor?.Offset,
                    request.TopDesignDescriptor?.FileUid,
                    request.TopDesignDescriptor?.Offset,
                    request.VolumeCalcType);

                return(await trexCompactionDataProxy.SendDataPostRequest <SummaryVolumesResult, SummaryVolumesDataRequest>(summaryVolumesRequest, "/volumes/summary", customHeaders));
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #23
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
#if RAPTOR
                throw new ServiceException("Master alignment geometry request is not support for Raptor");
#endif
                log.LogDebug("Getting master alignment geometry from TRex");

                var request = CastRequestObjectTo <AlignmentGeometryRequest>(item);

                var siteModelId         = request.ProjectUid.ToString();
                var convertArcsToChords = request.ConvertArcsToChords.ToString();
                var arcChordTolerance   = request.ArcChordTolerance.ToString(CultureInfo.InvariantCulture);

                log.LogDebug($"Getting an alignment geometry for file ID: {request.DesignUid}");

                return(await ProcessRequest(siteModelId, request.DesignUid.ToString(), convertArcsToChords, arcChordTolerance, request.FileName));
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #24
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request    = CastRequestObjectTo <ProjectFileDescriptor>(item);
                var zoomResult = new ZoomRangeResult();
                var fileType   = request.FileType;
                log.LogDebug($"FileType is: {fileType}");

                //Tell Raptor to update its cache.
                //Note: surveyed surface file names are the TCC one including the surveyed UTC in the file name
                if (fileType == ImportedFileType.Alignment ||
                    fileType == ImportedFileType.DesignSurface ||
                    fileType == ImportedFileType.SurveyedSurface)
                {
                    log.LogDebug("Updating Raptor design cache");

                    var result1 = raptorClient.UpdateCacheWithDesign(request.ProjectId.Value, request.File.FileName, 0, false);
                    if (result1 != TDesignProfilerRequestResult.dppiOK)
                    {
                        throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(
                                                       ContractExecutionStatesEnum.FailedToGetResults,
                                                       $"Failed to update Raptor design cache with error: {ContractExecutionStates.FirstNameWithOffset((int) result1)}"));
                    }
                }

                switch (fileType)
                {
                case ImportedFileType.Linework:
                //case ImportedFileType.DesignSurface:
                case ImportedFileType.Alignment:

                    var suffix = FileUtils.GeneratedFileSuffix(fileType);
                    //Get PRJ file contents from Raptor
                    log.LogDebug($"Getting projection file from Raptor for file {request.File.FileName}");
                    var dxfUnitsType = fileType == ImportedFileType.Linework
              ? (TVLPDDistanceUnits)request.DXFUnitsType
              : TVLPDDistanceUnits.vduMeters; //always metric for design surface and alignment as we generate the DXF file.
                    log.LogDebug($"Units selected {dxfUnitsType}");

                    var result2 = raptorClient.GetCoordinateSystemProjectionFile(request.ProjectId.Value,
                                                                                 dxfUnitsType, out string prjFile);
                    if (result2 != TASNodeErrorStatus.asneOK)
                    {
                        //We need gracefully fail here as the file may be imported to an empty datamodel
                        log.LogWarning("Failed to get requested " + FileUtils.PROJECTION_FILE_EXTENSION + " file with error: {0}.",
                                       ContractExecutionStates.FirstNameWithOffset((int)result2));

                        return(new AddFileResult(ContractExecutionStatesEnum.ExecutedSuccessfully, "Add file notification partially successful - no tiles can be generated")
                        {
                            MinZoomLevel = 0,
                            MaxZoomLevel = 0,
                            FileUid = request.FileUid,
                            FileDescriptor = request.File,
                            UserEmailAddress = request.UserEmailAddress
                        });

                        /*throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(
                         * ContractExecutionStatesEnum.FailedToGetResults,
                         * string.Format("Failed to get requested " + FileUtils.PROJECTION_FILE_EXTENSION + " file with error: {0}.",
                         * ContractExecutionStates.FirstNameWithOffset((int)result2))));*/
                    }
                    //Note: Cannot have async void therefore bool result from method. However, failure handled inside method so ignore return value here.
                    await CreateTransformFile(request.ProjectId.Value, request.File, prjFile, suffix, FileUtils.PROJECTION_FILE_EXTENSION);

                    //Get GM_XFORM file contents from Raptor
                    log.LogDebug("Getting horizontal adjustment file from Raptor");

                    var result3 = raptorClient.GetCoordinateSystemHorizontalAdjustmentFile(request.CoordSystemFileName,
                                                                                           request.ProjectId.Value, dxfUnitsType, out string haFile);
                    if (result3 != TASNodeErrorStatus.asneOK)
                    {
                        log.LogWarning("Failed to get requested " + FileUtils.HORIZONTAL_ADJUSTMENT_FILE_EXTENSION + $" file with error: {ContractExecutionStates.FirstNameWithOffset((int) result2)}.");
                        return(new AddFileResult(ContractExecutionStatesEnum.ExecutedSuccessfully, "Add file notification partially successful. Can not create horizontal adjustment - no tiles can be generated")
                        {
                            MinZoomLevel = 0,
                            MaxZoomLevel = 0,
                            FileUid = request.FileUid,
                            FileDescriptor = request.File,
                            UserEmailAddress = request.UserEmailAddress
                        });

                        /* throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(
                         * ContractExecutionStatesEnum.FailedToGetResults,
                         * string.Format(
                         * "Failed to get requested " + FileUtils.HORIZONTAL_ADJUSTMENT_FILE_EXTENSION + " file with error: {0}.",
                         * ContractExecutionStates.FirstNameWithOffset((int)result2))));*/
                    }
                    //An empty string means there is no horizontal adjustment in coordinate system so no file to create
                    if (haFile != string.Empty)
                    {
                        await CreateTransformFile(request.ProjectId.Value, request.File, haFile, suffix,
                                                  FileUtils.HORIZONTAL_ADJUSTMENT_FILE_EXTENSION);
                    }

                    if (fileType != ImportedFileType.Linework)
                    {
                        log.LogDebug($"Creating DXF file with Units selected {request.DXFUnitsType}");
                        //Get alignment or surface boundary as DXF file from Raptor
                        if (!await CreateDxfFile(request.ProjectId.Value, request.File, suffix, request.DXFUnitsType))
                        {
                            //We need gracefully fail here as the file may be imported to an empty datamodel
                            log.LogWarning("Failed to get requested " + FileUtils.DXF_FILE_EXTENSION);

                            return(new AddFileResult(ContractExecutionStatesEnum.ExecutedSuccessfully, "Add file notification partially successful. Can not create DXF - no tiles can be generated")
                            {
                                MinZoomLevel = 0,
                                MaxZoomLevel = 0,
                                FileUid = request.FileUid,
                                FileDescriptor = request.File,
                                UserEmailAddress = request.UserEmailAddress
                            });
                        }
                    }
                    //Calculate the zoom range
                    string generatedName     = FileUtils.GeneratedFileName(request.File.FileName, suffix, FileUtils.DXF_FILE_EXTENSION);
                    var    fullGeneratedName = $"{request.File.Path}/{generatedName}";
                    zoomResult = await tileGenerator.CalculateTileZoomRange(request.File.FilespaceId, fullGeneratedName).ConfigureAwait(false);

                    //Generate DXF tiles
                    await tileGenerator.CreateDxfTiles(request.ProjectId.Value, request.File, suffix, zoomResult, false).ConfigureAwait(false);

                    break;

                case ImportedFileType.SurveyedSurface:
                    log.LogDebug("Storing ground surface file in Raptor");
                    var dd   = new DesignDescriptor(request.FileId, request.File, 0.0);
                    var args = ASNode.GroundSurface.RPC.__Global
                               .Construct_GroundSurface_Args(
                        request.ProjectId.Value,
                        request.FileId,
                        FileUtils.SurveyedSurfaceUtc(request.File.FileName).Value,
                        RaptorConverters.DesignDescriptor(dd)
                        );

                    if (!raptorClient.StoreGroundSurfaceFile(args))
                    {
                        throw new ServiceException(HttpStatusCode.BadRequest,
                                                   new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
                                                                               "Failed to store ground surface file"));
                    }

                    break;
                }

                return(new AddFileResult(ContractExecutionStatesEnum.ExecutedSuccessfully, "Add file notification successful")
                {
                    MinZoomLevel = zoomResult.minZoom,
                    MaxZoomLevel = zoomResult.maxZoom,
                    FileUid = request.FileUid,
                    FileDescriptor = request.File,
                    UserEmailAddress = request.UserEmailAddress
                });
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #25
0
 protected sealed override void ProcessErrorCodes()
 {
     ContractExecutionStates.DynamicAddwithOffset("OnSubmissionResult. ConnectionFailure.", -10);
     ContractExecutionStates.DynamicAddwithOffset("The TAG file was found to be corrupted on its pre-processing scan.", 15);
     ContractExecutionStates.DynamicAddwithOffset("A second list of dynamic errors", 15);
 }
Exemple #26
0
 protected override ContractExecutionResult ProcessEx <T>(T item)
 {
     ContractExecutionStates.ClearDynamic();
     return(new ContractExecutionResult(1, "test result"));
 }
Exemple #27
0
 protected sealed override void ProcessErrorCodes()
 {
     ContractExecutionStates.DynamicAddwithOffset("OK", (int)RequestErrorStatus.OK);
     ContractExecutionStates.DynamicAddwithOffset("Unknown error", (int)RequestErrorStatus.Unknown);
     ContractExecutionStates.DynamicAddwithOffset("Exception occurred", (int)RequestErrorStatus.Exception);
     ContractExecutionStates.DynamicAddwithOffset("Unsupported coordinate system definition file type",
                                                  (int)RequestErrorStatus.UnsupportedCSDFileType);
     ContractExecutionStates.DynamicAddwithOffset("Could not convert coordinate system definition file",
                                                  (int)RequestErrorStatus.CouldNotConvertCSDFile);
     ContractExecutionStates.DynamicAddwithOffset("CToolBox failed to complete",
                                                  (int)RequestErrorStatus.CToolBoxFailedToComplete);
     ContractExecutionStates.DynamicAddwithOffset("Failed to write coordinate system definition stream",
                                                  (int)RequestErrorStatus.FailedToWriteCSDStream);
     ContractExecutionStates.DynamicAddwithOffset("Failed on profile request",
                                                  (int)RequestErrorStatus.FailedOnRequestProfile);
     ContractExecutionStates.DynamicAddwithOffset("No such data model",
                                                  (int)RequestErrorStatus.NoSuchDataModel);
     ContractExecutionStates.DynamicAddwithOffset("Unsupported display type",
                                                  (int)RequestErrorStatus.UnsupportedDisplayType);
     ContractExecutionStates.DynamicAddwithOffset("Failed on request of colour graduated profile",
                                                  (int)RequestErrorStatus.FailedOnRequestColourGraduatedProfile);
     ContractExecutionStates.DynamicAddwithOffset("Failed to convert client WGS84 coordinates",
                                                  (int)RequestErrorStatus.FailedToConvertClientWGSCoords);
     ContractExecutionStates.DynamicAddwithOffset("Failed to request sub-grid existence map",
                                                  (int)RequestErrorStatus.FailedToRequestSubgridExistenceMap);
     ContractExecutionStates.DynamicAddwithOffset("Invalid coordinate range",
                                                  (int)RequestErrorStatus.InvalidCoordinateRange);
     ContractExecutionStates.DynamicAddwithOffset("Failed to request data model statistics",
                                                  (int)RequestErrorStatus.FailedToRequestDatamodelStatistics);
     ContractExecutionStates.DynamicAddwithOffset("Failed to request coordinate system projection file",
                                                  (int)RequestErrorStatus.FailedOnRequestCoordinateSystemProjectionFile);
     ContractExecutionStates.DynamicAddwithOffset("Coordinate system is empty",
                                                  (int)RequestErrorStatus.EmptyCoordinateSystem);
     ContractExecutionStates.DynamicAddwithOffset("Request has been aborted due to pipeline timeout",
                                                  (int)RequestErrorStatus.AbortedDueToPipelineTimeout);
     ContractExecutionStates.DynamicAddwithOffset("Unsupported filter attribute",
                                                  (int)RequestErrorStatus.UnsupportedFilterAttribute);
     ContractExecutionStates.DynamicAddwithOffset("Service stopped", (int)RequestErrorStatus.ServiceStopped);
     ContractExecutionStates.DynamicAddwithOffset("Schedule load is too high",
                                                  (int)RequestErrorStatus.RequestScheduleLoadTooHigh);
     ContractExecutionStates.DynamicAddwithOffset("Schedule failure",
                                                  (int)RequestErrorStatus.RequestScheduleFailure);
     ContractExecutionStates.DynamicAddwithOffset("Schedule timeout",
                                                  (int)RequestErrorStatus.RequestScheduleTimeout);
     ContractExecutionStates.DynamicAddwithOffset("Request has been cancelled",
                                                  (int)RequestErrorStatus.RequestHasBeenCancelled);
     ContractExecutionStates.DynamicAddwithOffset("Failed to obtain coordinate system interlock",
                                                  (int)RequestErrorStatus.FailedToObtainCoordinateSystemInterlock);
     ContractExecutionStates.DynamicAddwithOffset(
         "Failed to request coordinate system horizontal adjustment file",
         (int)RequestErrorStatus.FailedOnRequestCoordinateSystemHorizontalAdjustmentFile);
     ContractExecutionStates.DynamicAddwithOffset("No connection to server",
                                                  (int)RequestErrorStatus.NoConnectionToServer);
     ContractExecutionStates.DynamicAddwithOffset("Invalid response code",
                                                  (int)RequestErrorStatus.InvalidResponseCode);
     ContractExecutionStates.DynamicAddwithOffset("No result has been returned",
                                                  (int)RequestErrorStatus.NoResultReturned);
     ContractExecutionStates.DynamicAddwithOffset("Failed to notify that coordinate system was changed",
                                                  (int)RequestErrorStatus.FailedToNotifyCSChange);
     ContractExecutionStates.DynamicAddwithOffset("Failed to create DCtoIRecord converter",
                                                  (int)RequestErrorStatus.FailedToCreateDCToIRecordConverter);
     ContractExecutionStates.DynamicAddwithOffset("Failed to get coordinate systems settings",
                                                  (int)RequestErrorStatus.FailedToGetCSSettings);
     ContractExecutionStates.DynamicAddwithOffset("Coordinate system is incomplete",
                                                  (int)RequestErrorStatus.DCToIRecIncompleteCS);
     ContractExecutionStates.DynamicAddwithOffset("Failed to create CSIB",
                                                  (int)RequestErrorStatus.DCToIRecFailedCreateCSIB);
     ContractExecutionStates.DynamicAddwithOffset("Failed to get geoid information",
                                                  (int)RequestErrorStatus.DCToIRecFailedToGetGeoidInfo);
     ContractExecutionStates.DynamicAddwithOffset("Unable to retrieve zone parameters",
                                                  (int)RequestErrorStatus.DCToIRecFailedToGetZoneParams);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB constant separation geoid",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateConstGeoid);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB datum grid file",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateDatumGrid);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB ellipsoid",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateEllipsoid);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB Grid Geoid",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateGridGeoid);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB Molodensky datum",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateMolodenskyDatum);
     ContractExecutionStates.DynamicAddwithOffset(
         "Failed to instantiate CSIB Multiple Regression Parameter datum",
         (int)RequestErrorStatus.DCToIRecFailedToCreateMultiRegressionDatum);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB Seven Parameter datum",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateSevenParamsDatum);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB WGS84 datum",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateWGS84Datum);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB Zone Group",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateZoneGroup);
     ContractExecutionStates.DynamicAddwithOffset("Failed to instantiate CSIB Zone Based Site",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateZoneBasedSite);
     ContractExecutionStates.DynamicAddwithOffset("Failed to create an IAZIParameters object",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateAZIParamsObject);
     ContractExecutionStates.DynamicAddwithOffset("Unable to create an ICSIB object",
                                                  (int)RequestErrorStatus.DCToIRecFailedToCreateCSIBObject);
     ContractExecutionStates.DynamicAddwithOffset("Failed to open Calibration reader",
                                                  (int)RequestErrorStatus.DCToIRecFailedToOpenCalibrationReader);
     ContractExecutionStates.DynamicAddwithOffset("Unable to set zone parameters",
                                                  (int)RequestErrorStatus.DCToIRecFailedToSetZoneParams);
     ContractExecutionStates.DynamicAddwithOffset("Failed to read CSIB",
                                                  (int)RequestErrorStatus.DCToIRecFailedToReadCSIB);
     ContractExecutionStates.DynamicAddwithOffset("Failed to read in CSIB",
                                                  (int)RequestErrorStatus.DCToIRecFailedToReadInCSIB);
     ContractExecutionStates.DynamicAddwithOffset("Failed to read the ZoneBased site",
                                                  (int)RequestErrorStatus.DCToIRecFailedToReadZoneBasedSite);
     ContractExecutionStates.DynamicAddwithOffset("Failed to read the zone",
                                                  (int)RequestErrorStatus.DCToIRecFailedToReadZone);
     ContractExecutionStates.DynamicAddwithOffset("Failed to write datum",
                                                  (int)RequestErrorStatus.DCToIRecFailedToWriteDatum);
     ContractExecutionStates.DynamicAddwithOffset("Failed to write geoid",
                                                  (int)RequestErrorStatus.DCToIRecFailedToWriteGeoid);
     ContractExecutionStates.DynamicAddwithOffset("Failed to write CSIB",
                                                  (int)RequestErrorStatus.DCToIRecFailedToWriteCSIB);
     ContractExecutionStates.DynamicAddwithOffset("Failed to set zone info",
                                                  (int)RequestErrorStatus.DCToIRecFailedToSetZoneInfo);
     ContractExecutionStates.DynamicAddwithOffset("Infinite adjustment slope value",
                                                  (int)RequestErrorStatus.DCToIRecInfiniteAdjustmentSlopeValue);
     ContractExecutionStates.DynamicAddwithOffset("Invalid ellipsoid",
                                                  (int)RequestErrorStatus.DCToIRecInvalidEllipsoid);
     ContractExecutionStates.DynamicAddwithOffset("The datum CSIB failed to load",
                                                  (int)RequestErrorStatus.DCToIRecDatumFailedToLoad);
     ContractExecutionStates.DynamicAddwithOffset("Failed to load CSIB",
                                                  (int)RequestErrorStatus.DCToIRecFailedToLoadCSIB);
     ContractExecutionStates.DynamicAddwithOffset("Not WGS84 ellipsoid",
                                                  (int)RequestErrorStatus.DCToIRecNotWGS84Ellipsoid);
     ContractExecutionStates.DynamicAddwithOffset("Not WGS84 ellipsoid in datum record",
                                                  (int)RequestErrorStatus.DCToIRecNotWGS84EllipsoidSameAsProj);
     ContractExecutionStates.DynamicAddwithOffset("Current projection should be scaled",
                                                  (int)RequestErrorStatus.DCToIRecScaleOnlyProj);
     ContractExecutionStates.DynamicAddwithOffset("Unknown coordinate system type",
                                                  (int)RequestErrorStatus.DCToIRecUnknownCSType);
     ContractExecutionStates.DynamicAddwithOffset("Unknown datum adjustment was encountered and ignored",
                                                  (int)RequestErrorStatus.DCToIRecUnknownDatumModel);
     ContractExecutionStates.DynamicAddwithOffset("Unknown geoid model was encountered and ignored",
                                                  (int)RequestErrorStatus.DCToIRecUnknownGeoidModel);
     ContractExecutionStates.DynamicAddwithOffset("Unknown projection type",
                                                  (int)RequestErrorStatus.DCToIRecUnknownProjType);
     ContractExecutionStates.DynamicAddwithOffset("Unsupported datum",
                                                  (int)RequestErrorStatus.DCToIRecUnsupportedDatum);
     ContractExecutionStates.DynamicAddwithOffset("Unsupported geoid",
                                                  (int)RequestErrorStatus.DCToIRecUnsupportedGeoid);
     ContractExecutionStates.DynamicAddwithOffset("Unsupported zone orientation",
                                                  (int)RequestErrorStatus.DCToIRecUnsupportedZoneOrientation);
     ContractExecutionStates.DynamicAddwithOffset("Failed to request file from TCC",
                                                  (int)RequestErrorStatus.FailedToRequestFileFromTCC);
     ContractExecutionStates.DynamicAddwithOffset("Failed to read linework boundary file",
                                                  (int)RequestErrorStatus.FailedToReadLineworkBoundaryFile);
     ContractExecutionStates.DynamicAddwithOffset("No boundaries in linework file",
                                                  (int)RequestErrorStatus.NoBoundariesInLineworkFile);
     ContractExecutionStates.DynamicAddwithOffset("Failed to perform coordinate conversion",
                                                  (int)RequestErrorStatus.FailedToPerformCoordinateConversion);
     ContractExecutionStates.DynamicAddwithOffset("No production data found",
                                                  (int)RequestErrorStatus.NoProductionDataFound);
     ContractExecutionStates.DynamicAddwithOffset("Invalid plan extents",
                                                  (int)RequestErrorStatus.InvalidPlanExtents);
     ContractExecutionStates.DynamicAddwithOffset("No design provided",
                                                  (int)RequestErrorStatus.NoDesignProvided);
     ContractExecutionStates.DynamicAddwithOffset("Unable to load CSIB for LatLong conversion",
                                                  (int)RequestErrorStatus.ExportInvalidCSIB);
     ContractExecutionStates.DynamicAddwithOffset("Unable to convert NEE to LLH",
                                                  (int)RequestErrorStatus.ExportCoordConversionError);
     ContractExecutionStates.DynamicAddwithOffset("No Production data was found",
                                                  (int)RequestErrorStatus.ExportNoDataFound);
     ContractExecutionStates.DynamicAddwithOffset("Exceeded the row count limit for export",
                                                  (int)RequestErrorStatus.ExportExceededRowLimit);
     ContractExecutionStates.DynamicAddwithOffset("Unable to load zip file to s3",
                                                  (int)RequestErrorStatus.ExportUnableToLoadFileToS3);
     ContractExecutionStates.DynamicAddwithOffset(
         "Invalid page size or number for patch request. Try reducing the area being requested.",
         (int)RequestErrorStatus.InvalidArgument);
     ContractExecutionStates.DynamicAddwithOffset("Failed to configure internal pipeline.",
                                                  (int)RequestErrorStatus.FailedToConfigureInternalPipeline);
     ContractExecutionStates.DynamicAddwithOffset("Failed to retrieve design file from storage.",
                                                  (int)RequestErrorStatus.DesignImportUnableToRetrieveFromS3);
     ContractExecutionStates.DynamicAddwithOffset("Failed to add design to project.",
                                                  (int)RequestErrorStatus.DesignImportUnableToCreateDesign);
     ContractExecutionStates.DynamicAddwithOffset("Failed to update design in project.",
                                                  (int)RequestErrorStatus.DesignImportUnableToUpdateDesign);
     ContractExecutionStates.DynamicAddwithOffset("Failed to delete design from project.",
                                                  (int)RequestErrorStatus.DesignImportUnableToDeleteDesign);
     ContractExecutionStates.DynamicAddwithOffset("Failed to prepare filter.",
                                                  (int)RequestErrorStatus.FailedToPrepareFilter);
     ContractExecutionStates.DynamicAddwithOffset("Failed to get CCA minimum passes value.",
                                                  (int)RequestErrorStatus.FailedToGetCCAMinimumPassesValue);
 }
Exemple #28
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request  = CastRequestObjectTo <ProjectFileDescriptor>(item);
                var fileType = request.FileType;

                log.LogDebug($"FileType is: {fileType}");

                if (fileType == ImportedFileType.DesignSurface ||
                    fileType == ImportedFileType.Alignment ||
                    fileType == ImportedFileType.Linework)
                {
                    var suffix = FileUtils.GeneratedFileSuffix(fileType);
                    //Delete generated files
                    var deletePRJFile = DeleteGeneratedFile(request.ProjectId.Value, request.File, suffix, FileUtils.PROJECTION_FILE_EXTENSION);
                    var deleteHAFile  = DeleteGeneratedFile(request.ProjectId.Value, request.File, suffix, FileUtils.HORIZONTAL_ADJUSTMENT_FILE_EXTENSION);

                    await Task.WhenAll(deletePRJFile, deleteHAFile);

                    bool success = deletePRJFile.Result && deleteHAFile.Result;

                    if (fileType != ImportedFileType.Linework)
                    {
                        success = success && await DeleteGeneratedFile(request.ProjectId.Value, request.File, suffix, FileUtils.DXF_FILE_EXTENSION);
                    }

                    if (!success)
                    {
                        throw new ServiceException(HttpStatusCode.BadRequest,
                                                   new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
                                                                               "Failed to delete generated files"));
                    }
                    //Delete tiles
                    var generatedName = FileUtils.GeneratedFileName(request.File.FileName, suffix, FileUtils.DXF_FILE_EXTENSION);
                    await tileGenerator.DeleteDxfTiles(request.ProjectId.Value, generatedName, request.File).ConfigureAwait(false);
                }


                //If surveyed surface, delete it in Raptor
                if (fileType == ImportedFileType.SurveyedSurface)
                {
                    log.LogDebug("Discarding ground surface file in Raptor");
                    bool importedFileDiscardByNextGenFileIdResult =
                        raptorClient.DiscardGroundSurfaceFileDetails(request.ProjectId.Value, request.FileId);
                    bool importedFileDiscardByLegacyFileIdResult = true;

                    if (request.LegacyFileId.HasValue)
                    {
                        importedFileDiscardByLegacyFileIdResult =
                            raptorClient.DiscardGroundSurfaceFileDetails(request.ProjectId.Value, request.LegacyFileId.Value);
                    }

                    // one or the other should be deleted
                    if (!importedFileDiscardByNextGenFileIdResult && !importedFileDiscardByLegacyFileIdResult)
                    {
                        var whichOneFailed = importedFileDiscardByNextGenFileIdResult
              ? $"LegacyFileId {request.LegacyFileId}"  :  $"nextGenId {request.FileId}";
                        throw new ServiceException(HttpStatusCode.BadRequest,
                                                   new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
                                                                               $"Failed to discard ground surface file by {whichOneFailed}"));
                    }
                }

                return(new ContractExecutionResult(ContractExecutionStatesEnum.ExecutedSuccessfully, "Delete file notification successful"));
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }
Exemple #29
0
        /// <summary>
        /// Processes the detailed CMV request by passing the request to Raptor and returning the result.
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            try
            {
                var request = CastRequestObjectTo <CMVRequest>(item);
#if RAPTOR
                if (request.IsCustomCMVTargets && (configStore.GetValueBool("ENABLE_TREX_GATEWAY_CMV") ?? false))
                {
#endif
                var settings = new CMVSettingsEx(request.CmvSettings.CmvTarget, request.CmvSettings.MaxCMV, request.CmvSettings.MaxCMVPercent,
                                                 request.CmvSettings.MinCMV, request.CmvSettings.MinCMVPercent, request.CmvSettings.OverrideTargetCMV,
                                                 (CompactionProjectSettings.DefaultSettings.customCMVTargets.ToArray()));

                await PairUpAssetIdentifiers(request.ProjectUid.Value, request.Filter);
                await PairUpImportedFileIdentifiers(request.ProjectUid.Value, filter1 : request.Filter);

                var cmvDetailsRequest = new CMVDetailsRequest(
                    request.ProjectUid.Value,
                    request.Filter,
                    settings.CustomCMVDetailTargets,
                    AutoMapperUtility.Automapper.Map <OverridingTargets>(request.LiftBuildSettings),
                    AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings));
                log.LogDebug($"{nameof(DetailedCMVExecutor)} trexRequest {JsonConvert.SerializeObject(cmvDetailsRequest)}");

                return(await trexCompactionDataProxy.SendDataPostRequest <CMVDetailedResult, CMVDetailsRequest>(cmvDetailsRequest, "/cmv/details", customHeaders));

#if RAPTOR
            }

            var raptorFilter = RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient, request.OverrideStartUTC, request.OverrideEndUTC, request.OverrideAssetIds);

            var externalRequestDescriptor = ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor(
                request.CallId ?? Guid.NewGuid(), 0,
                TASNodeCancellationDescriptorType.cdtCMVDetailed);

            var liftBuildSettings = RaptorConverters.ConvertLift(request.LiftBuildSettings, raptorFilter.LayerMethod);

            TCMVDetails        cmvDetails;
            TASNodeErrorStatus raptorResult;

            if (!request.IsCustomCMVTargets)
            {
                raptorResult = raptorClient.GetCMVDetails(
                    request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                    externalRequestDescriptor,
                    ConvertSettings(request.CmvSettings),
                    raptorFilter,
                    liftBuildSettings,
                    out cmvDetails);
            }
            else
            {
                raptorResult = raptorClient.GetCMVDetailsExt(
                    request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                    externalRequestDescriptor,
                    ConvertSettingsExt((CMVSettingsEx)request.CmvSettings),
                    raptorFilter,
                    liftBuildSettings,
                    out cmvDetails);
            }

            if (raptorResult == TASNodeErrorStatus.asneOK)
            {
                return(ConvertResult(cmvDetails));
            }

            throw CreateServiceException <DetailedCMVExecutor>((int)raptorResult);
#endif
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }
        }