예제 #1
0
        private ContractExecutionResult ProcessWithRaptor(ExportReport request)
        {
            var raptorFilter = RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient);

            bool success = raptorClient.GetProductionDataExport(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                                                                ASNodeRPC.__Global.Construct_TASNodeRequestDescriptor(request.CallId ?? Guid.NewGuid(), 0,
                                                                                                                      TASNodeCancellationDescriptorType.cdtProdDataExport),
                                                                RaptorConverters.convertToRaptorUserPreferences(request.UserPrefs), (int)request.ExportType, request.CallerId, raptorFilter,
                                                                RaptorConverters.ConvertLift(request.LiftBuildSettings, raptorFilter.LayerMethod),
                                                                request.TimeStampRequired, request.CellSizeRequired, request.RawData, request.RestrictSize, true,
                                                                request.Tolerance, request.IncludeSurveydSurface,
                                                                request.Precheckonly, request.Filename, RaptorConverters.convertToRaptorMachines(request.MachineList), (int)request.CoordType, (int)request.OutputType,
                                                                request.DateFromUTC, request.DateToUTC,
                                                                RaptorConverters.convertToRaptorTranslations(request.Translations),
                                                                RaptorConverters.convertToRaptorProjectExtents(request.ProjectExtents), out var dataexport);

            if (success)
            {
                try
                {
                    return(ExportResult.Create(
                               File.ReadAllBytes(BuildFilePath(request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID, request.CallerId, request.Filename, true)),
                               dataexport.ReturnCode));
                }
                catch (Exception ex)
                {
                    throw new ServiceException(HttpStatusCode.NoContent,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                           "Failed to retrieve received export data: " + ex.Message));
                }
            }

            throw CreateServiceException <ExportReportExecutor>(dataexport.ReturnCode);
        }
예제 #2
0
        private ExportResult ConvertTRexGridResult(Stream stream)
        {
            log.LogDebug($"{nameof(ConvertTRexGridResult)}: Retrieving response data from TRex");

            try
            {
                var griddedReportResult = new GriddedReportResult(ReportType.Gridded);
                griddedReportResult.Read((stream as MemoryStream)?.ToArray());

                var outputStream = new MemoryStream();
                var sb           = new StringBuilder();

                sb.Append($"{STR_NORTHING}, {STR_EASTING}");

                if (griddedReportResult.GriddedData.ReportElevation)
                {
                    sb.Append($", {STR_ELEVATION}");
                }
                if (griddedReportResult.GriddedData.ReportCutFill)
                {
                    sb.Append($", {STR_CUT_FILL}");
                }
                if (griddedReportResult.GriddedData.ReportCmv)
                {
                    sb.Append($", {STR_CMV}");
                }
                if (griddedReportResult.GriddedData.ReportMdp)
                {
                    sb.Append($", {STR_MDP}");
                }
                if (griddedReportResult.GriddedData.ReportPassCount)
                {
                    sb.Append($", {STR_PASS_COUNT}");
                }
                if (griddedReportResult.GriddedData.ReportTemperature)
                {
                    sb.Append($", {STR_TEMPERATURE}");
                }
                sb.Append(STR_INSERT_LINE);

                // Write a header...
                var bytes = Encoding.ASCII.GetBytes(sb.ToString());
                outputStream.Write(bytes, 0, bytes.Length);

                // Write a series of CSV records from the data...
                foreach (GriddedReportDataRowBase row in griddedReportResult.GriddedData.Rows)
                {
                    sb.Clear();

                    sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F3}, {1:F3}", row.Northing, row.Easting));
                    if (griddedReportResult.GriddedData.ReportElevation)
                    {
                        sb.Append(string.Format(CultureInfo.InvariantCulture, ", {0:F3}", row.Elevation));
                    }
                    if (griddedReportResult.GriddedData.ReportCutFill)
                    {
                        sb.Append(row.CutFill == VelociraptorConstants.NULL_SINGLE
              ? ", "
              : string.Format(CultureInfo.InvariantCulture, ", {0:F3}", row.CutFill));
                    }
                    if (griddedReportResult.GriddedData.ReportCmv)
                    {
                        sb.Append(row.Cmv == VelociraptorConstants.NO_CCV
              ? ", "
              : string.Format(CultureInfo.InvariantCulture, ", {0}", row.Cmv));
                    }
                    if (griddedReportResult.GriddedData.ReportMdp)
                    {
                        sb.Append(row.Mdp == VelociraptorConstants.NO_MDP
              ? ", "
              : string.Format(CultureInfo.InvariantCulture, ", {0}", row.Mdp));
                    }
                    if (griddedReportResult.GriddedData.ReportPassCount)
                    {
                        sb.Append(row.PassCount == VelociraptorConstants.NO_PASSCOUNT
              ? ", "
              : string.Format(CultureInfo.InvariantCulture, ", {0}", row.PassCount));
                    }
                    if (griddedReportResult.GriddedData.ReportTemperature)
                    {
                        sb.Append(row.Temperature == VelociraptorConstants.NO_TEMPERATURE
              ? ", "
              : string.Format(CultureInfo.InvariantCulture, ", {0}", row.Temperature));
                    }
                    sb.Append(STR_INSERT_LINE);

                    bytes = Encoding.ASCII.GetBytes(sb.ToString());
                    outputStream.Write(bytes, 0, bytes.Length);
                }

                outputStream.Close();

                return(ExportResult.Create(outputStream.ToArray(), 1));
            }
            catch
            {
                throw CreateServiceException <ExportGridCSVExecutor>();
            }
        }