示例#1
0
        public void LoadOffsetsSingleOffset_Streaming_Successful()
        {
            // When Response returned via MasterData Proxies,
            //  it is converted to byte[], then stream then file stream, then back

            double station1 = 10;
            var    stationOffsetRowStation1_1 = new StationOffsetRow(
                station1, -1, 1.0, 2.0, 3.0,
                4.0, 5, 6, 7, 8
                );

            var stationOffsetRows = new List <StationOffsetRow>()
            {
                stationOffsetRowStation1_1
            };
            var stationOffsetResponse = new StationOffsetReportRequestResponse_ApplicationService()
            {
            };

            stationOffsetResponse.LoadStationOffsets(stationOffsetRows);

            var retrievedStation1 = stationOffsetResponse.StationOffsetReportDataRowList.Where(x => x.Station == station1).First();

            Assert.NotNull(retrievedStation1);

            var original = new StationOffsetReportResult(ReportType.StationOffset);

            original.GriddedData.Rows.Add(retrievedStation1);
            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 StationOffsetReportResult();

            copyOfOrig.Read(byteArrayOfOriginal);

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

            resultFromStream.Read(memoryStream.ToArray());

            Assert.True(ReportType.StationOffset == resultFromStream.ReportType, "Invalid report type");
            Assert.True(original.GriddedData.Rows.Count == resultFromStream.GriddedData.Rows.Count, "Invalid number of rows");
            Assert.Equal(original.GriddedData.Rows[0].Station, resultFromStream.GriddedData.Rows[0].Station);
            Assert.Equal(original.GriddedData.Rows[0].Offsets.Count, resultFromStream.GriddedData.Rows[0].Offsets.Count);
            Assert.Equal(original.GriddedData.Rows[0].Offsets[0].Offset, resultFromStream.GriddedData.Rows[0].Offsets[0].Offset);
            Assert.Equal(original.GriddedData.Rows[0].Offsets[0].Northing, resultFromStream.GriddedData.Rows[0].Offsets[0].Northing);
            Assert.Equal(original.GriddedData.Rows[0].Minimum.CutFill, resultFromStream.GriddedData.Rows[0].Minimum.CutFill);
            Assert.Equal(original.GriddedData.Rows[0].Maximum.Elevation, resultFromStream.GriddedData.Rows[0].Maximum.Elevation);
        }
示例#2
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            var request   = CastRequestObjectTo <CompactionReportStationOffsetTRexRequest>(item);
            var siteModel = GetSiteModel(request.ProjectUid);
            var filter    = ConvertFilter(request.Filter, siteModel);

            var tRexRequest = new StationOffsetReportRequest_ApplicationService();
            var stationOffsetReportRequestArgument_ApplicationService = AutoMapperUtility.Automapper.Map <StationOffsetReportRequestArgument_ApplicationService>(request);

            stationOffsetReportRequestArgument_ApplicationService.Filters = new FilterSet(filter);

            var response = await tRexRequest.ExecuteAsync(stationOffsetReportRequestArgument_ApplicationService);

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

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