/// <summary> /// Creates an associated DXF file /// </summary> /// <param name="projectId">The id of the project to which the file belongs</param> /// <param name="fileDescr">The original file for which the associated file is created</param> /// <param name="suffix">The suffix applied to the file name to get the generated file name</param> /// <param name="userUnits">The user units preference</param> private async Task <bool> CreateDxfFile(long projectId, FileDescriptor fileDescr, string suffix, DxfUnitsType userUnits) { const double ImperialFeetToMetres = 0.3048; const double USFeetToMetres = 0.304800609601; //NOTE: For alignment files only (not surfaces), there are labels generated as part of the DXF file. //They need to be in the user units. double interval; TVLPDDistanceUnits raptorUnits; switch (userUnits) { case DxfUnitsType.ImperialFeet: raptorUnits = TVLPDDistanceUnits.vduImperialFeet; interval = 300 * ImperialFeetToMetres; break; case DxfUnitsType.Meters: raptorUnits = TVLPDDistanceUnits.vduMeters; interval = 100; break; case DxfUnitsType.UsSurveyFeet: default: raptorUnits = TVLPDDistanceUnits.vduUSSurveyFeet; interval = 300 * USFeetToMetres; break; } log.LogDebug("Getting DXF design boundary from Raptor"); raptorClient.GetDesignBoundary( DesignProfiler.ComputeDesignBoundary.RPC.__Global.Construct_CalculateDesignBoundary_Args (projectId, fileDescr.DesignDescriptor(configStore, log, 0, 0), DesignProfiler.ComputeDesignBoundary.RPC.TDesignBoundaryReturnType.dbrtDXF, interval, raptorUnits, 0), out var memoryStream, out var designProfilerResult); if (memoryStream != null) { return(await PutFile(projectId, fileDescr, suffix, FileUtils.DXF_FILE_EXTENSION, memoryStream, memoryStream.Length)); } else { log.LogWarning("Failed to generate DXF boundary for file {0} for project {1}. Raptor error {2}", fileDescr.FileName, projectId, designProfilerResult); //We need gracefully fail here as the file may be imported to an empty datamodel return(false); /*throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult( * ContractExecutionStatesEnum.FailedToGetResults, * string.Format("Failed to create " + FileUtils.DXF_FILE_EXTENSION + " file with error: {0}", * ContractExecutionStates.FirstNameWithOffset((int)designProfilerResult))));*/ } }