public async Task <JsonResult> GetCCASummary([FromRoute] string siteModelID, [FromBody] OverrideParameters overrides) { string resultToReturn; if (!Guid.TryParse(siteModelID, out var UID)) { resultToReturn = $"<b>Invalid Site Model UID: {siteModelID}</b>"; } else { var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(UID, false); if (siteModel == null) { resultToReturn = $"<b>Site model {UID} is unavailable</b>"; } else { var sw = new Stopwatch(); sw.Start(); var operation = new CCAStatisticsOperation(); var result = await operation.ExecuteAsync( new CCAStatisticsArgument() { ProjectID = siteModel.ID, Filters = new FilterSet() { Filters = new[] { new CombinedFilter() } } } ); if (result != null) { string resultString = $"<b>CCA Summary Results (in {sw.Elapsed}) :</b><br/>"; resultString += "<b>================================================</b><br/>"; resultString += $"<b>Above CCA Percentage:</b> {result.AboveTargetPercent}<br/>"; resultString += $"<b>Within CCA Percentage Range:</b> {result.WithinTargetPercent}<br/>"; resultString += $"<b>Below CCA Percentage:</b> {result.BelowTargetPercent}<br/>"; resultString += $"<b>Total Area Covered in Sq Meters:</b> {result.TotalAreaCoveredSqMeters}<br/>"; resultToReturn = resultString; } else { resultToReturn = "<b>No result</b>"; } } } return(new JsonResult(resultToReturn)); }
public async Task Test_SummaryCCAStatistics_EmptySiteModel_FullExtents() { AddClusterComputeGridRouting(); AddApplicationGridRouting(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var operation = new CCAStatisticsOperation(); var ccaStatisticsResult = await operation.ExecuteAsync(SimpleCCAStatisticsArgument(siteModel)); ccaStatisticsResult.Should().NotBeNull(); ccaStatisticsResult.ResultStatus.Should().Be(RequestErrorStatus.FailedToRequestDatamodelStatistics); }
public async Task Test_SummaryCCAStatistics_SiteModelWithSingleCell_FullExtents_NoTarget() { AddClusterComputeGridRouting(); AddApplicationGridRouting(); var siteModel = BuildModelForSingleCellCCA(CCA_INCREMENT); var operation = new CCAStatisticsOperation(); var ccaStatisticsResult = await operation.ExecuteAsync(SimpleCCAStatisticsArgument(siteModel)); ccaStatisticsResult.Should().NotBeNull(); ccaStatisticsResult.ResultStatus.Should().Be(RequestErrorStatus.OK); ccaStatisticsResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoResult); ccaStatisticsResult.BelowTargetPercent.Should().Be(0); ccaStatisticsResult.AboveTargetPercent.Should().Be(0); ccaStatisticsResult.WithinTargetPercent.Should().Be(0); ccaStatisticsResult.TotalAreaCoveredSqMeters.Should().Be(0); ccaStatisticsResult.ConstantTargetCCA.Should().Be(CellPassConsts.NullCCATarget); ccaStatisticsResult.IsTargetCCAConstant.Should().BeTrue(); ccaStatisticsResult.Counts.Should().BeNull(); ccaStatisticsResult.Percents.Should().BeNull(); }
protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item) { var request = item as CCASummaryRequest; if (request == null) { ThrowRequestTypeCastException <CCASummaryRequest>(); } var siteModel = GetSiteModel(request.ProjectUid); var filter = ConvertFilter(request.Filter, siteModel); var operation = new CCAStatisticsOperation(); var ccaSummaryResult = await operation.ExecuteAsync( new CCAStatisticsArgument() { ProjectID = siteModel.ID, Filters = new FilterSet(filter), Overrides = AutoMapperUtility.Automapper.Map <OverrideParameters>(request.Overrides), LiftParams = ConvertLift(request.LiftSettings, request.Filter?.LayerType) } ); if (ccaSummaryResult != null) { if (ccaSummaryResult.ResultStatus == RequestErrorStatus.OK) { return(ConvertResult(ccaSummaryResult)); } throw CreateServiceException <SummaryCCAExecutor>(ccaSummaryResult.ResultStatus); } throw CreateServiceException <SummaryCCAExecutor>(); }
public async Task Test_SummaryCCAStatistics_SiteModelWithSingleCell_FullExtents() { const byte TARGET_CCA = 5; AddClusterComputeGridRouting(); AddApplicationGridRouting(); var siteModel = BuildModelForSingleCellCCA(CCA_INCREMENT, TARGET_CCA); var operation = new CCAStatisticsOperation(); var ccaStatisticsResult = await operation.ExecuteAsync(SimpleCCAStatisticsArgument(siteModel)); ccaStatisticsResult.Should().NotBeNull(); ccaStatisticsResult.ResultStatus.Should().Be(RequestErrorStatus.OK); ccaStatisticsResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoProblems); ccaStatisticsResult.BelowTargetPercent.Should().Be(0); ccaStatisticsResult.AboveTargetPercent.Should().Be(0); ccaStatisticsResult.WithinTargetPercent.Should().Be(100); ccaStatisticsResult.TotalAreaCoveredSqMeters.Should().BeApproximately(SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, 0.000001); ccaStatisticsResult.ConstantTargetCCA.Should().Be(TARGET_CCA); ccaStatisticsResult.IsTargetCCAConstant.Should().BeTrue(); ccaStatisticsResult.Counts.Should().BeNull(); ccaStatisticsResult.Percents.Should().BeNull(); }
public void Test_SummaryCCAStatistics_Creation() { var operation = new CCAStatisticsOperation(); operation.Should().NotBeNull(); }