Example #1
0
        public void GriddedReportDataResult()
        {
            var projectUid = Guid.NewGuid();
            //Set these for testing Automapper - they're not actually used in the gridded data
            var cutFillDesignUid    = Guid.NewGuid();
            var cutFillDesignOffset = 1.5;
            var request             = new CompactionReportGridTRexRequest(
                projectUid, null,
                true, true, true, true, true, true,
                cutFillDesignUid, cutFillDesignOffset,
                null, GridReportOption.Automatic,
                800000, 400000, 800001, 400001, 2, null, null);

            var computeResult = new GriddedReportResult()
            {
                ReturnCode  = ReportReturnCode.NoError,
                ReportType  = ReportType.Gridded,
                GriddedData = AutoMapperUtility.Automapper.Map <GriddedReportData>(request)
            };

            computeResult.GriddedData.NumberOfRows = 1;
            computeResult.GriddedData.Rows.Add(new GriddedReportDataRow()
            {
                Northing    = 1.0,
                Easting     = 2.0,
                Elevation   = 3.0,
                CutFill     = 4.0,
                Cmv         = 5,
                Mdp         = 6,
                PassCount   = 7,
                Temperature = 8
            });
            var executorResult = new GriddedReportDataResult(computeResult.Write());

            var retrieved = new GriddedReportResult();

            using (var ms = new MemoryStream(executorResult.GriddedData))
            {
                using (var reader = new BinaryReader(ms, Encoding.UTF8, true))
                {
                    retrieved.ReturnCode = (ReportReturnCode)reader.ReadInt32();
                    retrieved.ReportType = (ReportType)reader.ReadInt32();

                    retrieved.GriddedData.Read(reader);
                }
            }

            retrieved.ReturnCode.Should().Be(computeResult.ReturnCode);
            retrieved.ReportType.Should().Be(computeResult.ReportType);
            retrieved.GriddedData.Should().NotBeNull();
            retrieved.GriddedData.NumberOfRows.Should().Be(computeResult.GriddedData.NumberOfRows);
            retrieved.GriddedData.Rows[0].Northing.Should().Be(computeResult.GriddedData.Rows[0].Northing);
            retrieved.GriddedData.Rows[0].Easting.Should().Be(computeResult.GriddedData.Rows[0].Easting);
            retrieved.GriddedData.Rows[0].Elevation.Should().Be(computeResult.GriddedData.Rows[0].Elevation);
            retrieved.GriddedData.Rows[0].CutFill.Should().Be(computeResult.GriddedData.Rows[0].CutFill);
            retrieved.GriddedData.Rows[0].Cmv.Should().Be(computeResult.GriddedData.Rows[0].Cmv);
            retrieved.GriddedData.Rows[0].Mdp.Should().Be(computeResult.GriddedData.Rows[0].Mdp);
            retrieved.GriddedData.Rows[0].PassCount.Should().Be(computeResult.GriddedData.Rows[0].PassCount);
            retrieved.GriddedData.Rows[0].Temperature.Should().Be(computeResult.GriddedData.Rows[0].Temperature);
        }
Example #2
0
        public void CutFillResult_Population_Successful()
        {
            var original       = new GriddedReportResult(ReportType.Gridded);
            var griddedDataRow = new GriddedReportDataRow()
            {
                Northing    = 1.0,
                Easting     = 2.0,
                Elevation   = 3.0,
                CutFill     = 4.0,
                Cmv         = 5,
                Mdp         = 6,
                PassCount   = 7,
                Temperature = 8
            };

            original.GriddedData.Rows.Add(griddedDataRow);
            original.GriddedData.ReportElevation   = true;
            original.GriddedData.ReportCutFill     = true;
            original.GriddedData.ReportCmv         = false;
            original.GriddedData.ReportMdp         = true;
            original.GriddedData.ReportPassCount   = false;
            original.GriddedData.ReportTemperature = true;

            var byteArrayOfOriginal = original.Write();
            var copyOfOrig          = new GriddedReportResult();

            copyOfOrig.Read(byteArrayOfOriginal);

            Assert.True(original.ReportType == copyOfOrig.ReportType, "Invalid report type");
            Assert.True(original.GriddedData.Rows.Count == copyOfOrig.GriddedData.Rows.Count, "Invalid number of rows");
            Assert.True(original.GriddedData.ReportCutFill == copyOfOrig.GriddedData.ReportCutFill, "Invalid ReportCutFull setting");
        }
Example #3
0
        public void CutFillResult_Streaming_Successful()
        {
            // When Response returned via MasterData Proxies,
            //  it is converted to byte[], then stream then file stream, then back
            var original       = new GriddedReportResult(ReportType.Gridded);
            var griddedDataRow = new GriddedReportDataRow()
            {
                Northing    = 1.0,
                Easting     = 2.0,
                Elevation   = 3.0,
                CutFill     = 4.0,
                Cmv         = 5,
                Mdp         = 6,
                PassCount   = 7,
                Temperature = 8
            };

            original.GriddedData.Rows.Add(griddedDataRow);
            original.GriddedData.ReportElevation   = true;
            original.GriddedData.ReportCutFill     = true;
            original.GriddedData.ReportCmv         = false;
            original.GriddedData.ReportMdp         = true;
            original.GriddedData.ReportPassCount   = false;
            original.GriddedData.ReportTemperature = true;

            var byteArrayOfOriginal = original.Write();
            var copyOfOrig          = new GriddedReportResult();

            copyOfOrig.Read(byteArrayOfOriginal);

            // Graceful WebReq
            var fileStream       = new FileStreamResult(new MemoryStream(byteArrayOfOriginal), ContentTypeConstants.ApplicationOctetStream);
            var memoryStream     = (MemoryStream)fileStream.FileStream;
            var resultFromStream = new GriddedReportResult();

            resultFromStream.Read(memoryStream.ToArray());

            Assert.True(ReportType.Gridded == resultFromStream.ReportType, "Invalid report type");
            Assert.True(original.GriddedData.Rows.Count == resultFromStream.GriddedData.Rows.Count, "Invalid number of rows");
            Assert.True(original.GriddedData.ReportCutFill == resultFromStream.GriddedData.ReportCutFill, "Invalid ReportCutFull setting");
        }
Example #4
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            var request   = CastRequestObjectTo <CompactionReportGridTRexRequest>(item);
            var siteModel = GetSiteModel(request.ProjectUid);
            var filter    = ConvertFilter(request.Filter, siteModel);

            var tRexRequest = new GriddedReportRequest();
            var griddedReportRequestArgument = AutoMapperUtility.Automapper.Map <GriddedReportRequestArgument>(request);

            griddedReportRequestArgument.Filters = new FilterSet(filter);

            var response = await tRexRequest.ExecuteAsync(griddedReportRequestArgument);

            var result = new GriddedReportResult()
            {
                ReturnCode  = response?.ReturnCode ?? ReportReturnCode.UnknownError,
                ReportType  = ReportType.Gridded,
                GriddedData = AutoMapperUtility.Automapper.Map <GriddedReportData>(request)
            };

            result.GriddedData.NumberOfRows = response?.GriddedReportDataRowList.Count ?? 0;
            result.GriddedData.Rows.AddRange(response?.GriddedReportDataRowList ?? new List <GriddedReportDataRow>());
            return(new GriddedReportDataResult(result.Write()));
        }