public void Test_StationOffsetReportRequestArgument_ApplicationService_Empty() { var request = new StationOffsetReportRequestArgument_ApplicationService() { }; SimpleBinarizableInstanceTester.TestClass(request, "Empty StationOffsetReportRequestArgument_ApplicationService not same after round trip serialisation"); }
public void Test_StationOffsetReportRequestArgument_ApplicationService_WithContent() { var request = new StationOffsetReportRequestArgument_ApplicationService() { ProjectID = Guid.NewGuid(), Filters = new FilterSet(new CombinedFilter()), ReportElevation = true, ReportCmv = true, ReportMdp = true, ReportPassCount = true, ReportTemperature = true, ReportCutFill = false, AlignmentDesignUid = Guid.NewGuid(), CrossSectionInterval = 100, StartStation = 3500, EndStation = 5500, Offsets = new double[] { 3, 4, 5 }, Overrides = new OverrideParameters { OverrideTargetPassCount = true, OverridingTargetPassCountRange = new PassCountRangeRecord(3, 7) } }; SimpleBinarizableInstanceTester.TestClass(request, "Empty StationOffsetReportRequestArgument_ApplicationService not same after round trip serialisation"); }
/// <summary> /// Executes the profiler /// </summary> public async Task <StationOffsetReportRequestResponse_ApplicationService> ExecuteAsync(StationOffsetReportRequestArgument_ApplicationService arg) { _log.LogInformation($"Start {nameof(ComputeStationOffsetReportExecutor_ApplicationService)}"); try { if (arg.Filters?.Filters != null && arg.Filters.Filters.Length > 0) { // Prepare the filters for use in stationOffset operations. Failure to prepare any filter results in this request terminating if (!(arg.Filters.Filters.Select(x => FilterUtilities.PrepareFilterForUse(x, arg.ProjectID)).All(x => x == RequestErrorStatus.OK))) { return(new StationOffsetReportRequestResponse_ApplicationService { ResultStatus = RequestErrorStatus.FailedToPrepareFilter }); } } // keep alignment design knowledge here and pass points var argClusterCompute = new StationOffsetReportRequestArgument_ClusterCompute { ProjectID = arg.ProjectID, Filters = arg.Filters, ReferenceDesign = arg.ReferenceDesign, TRexNodeID = arg.TRexNodeID, ReportElevation = arg.ReportElevation, ReportCmv = arg.ReportCmv, ReportMdp = arg.ReportMdp, ReportPassCount = arg.ReportPassCount, ReportTemperature = arg.ReportTemperature, ReportCutFill = arg.ReportCutFill, Points = new List <StationOffsetPoint>(), Overrides = arg.Overrides, LiftParams = arg.LiftParams }; var siteModel = DIContext.ObtainRequired <ISiteModels>().GetSiteModel(arg.ProjectID); var designFiles = DIContext.ObtainRequired <IDesignFiles>(); // alignment will convert interval/offsets into northing/eastings for the project var alignmentDesign = designFiles.Lock(arg.AlignmentDesignUid, siteModel, siteModel.CellSize, out var loadResult) as SVLAlignmentDesign; if (alignmentDesign == null || loadResult != DesignLoadResult.Success) { return(new StationOffsetReportRequestResponse_ApplicationService { ReturnCode = ReportReturnCode.NoData, ResultStatus = RequestErrorStatus.NoDesignProvided }); } try { argClusterCompute.Points = alignmentDesign.GetOffsetPointsInNEE(arg.CrossSectionInterval, arg.StartStation, arg.EndStation, arg.Offsets, out var calcResult); _log.LogInformation($"{nameof(StationOffsetReportRequestResponse_ApplicationService)}: pointCount: {argClusterCompute.Points.Count}, calcResult: {calcResult}"); if (argClusterCompute.Points.Count == 0) { return(new StationOffsetReportRequestResponse_ApplicationService { ReturnCode = ReportReturnCode.NoData, ResultStatus = RequestErrorStatus.NoProductionDataFound }); } } finally { designFiles.UnLock(arg.AlignmentDesignUid, alignmentDesign); } var request = new StationOffsetReportRequest_ClusterCompute(); var clusterComputeResponse = await request.ExecuteAsync(argClusterCompute); // Return the core package to the caller var applicationResponse = new StationOffsetReportRequestResponse_ApplicationService { ReturnCode = clusterComputeResponse.ReturnCode, ResultStatus = clusterComputeResponse.ResultStatus }; applicationResponse.LoadStationOffsets(clusterComputeResponse.StationOffsetRows); _log.LogInformation($"End {nameof(ComputeStationOffsetReportExecutor_ApplicationService)}: ReturnCode {applicationResponse.ReturnCode}."); return(applicationResponse); } catch (Exception e) { _log.LogError(e, $"{nameof(StationOffsetReportRequestResponse_ApplicationService)}: Unexpected exception."); throw; } }