public async Task <ReturnLongV5Result> UpsertImportedFileV5TBC( [FromRoute] long projectId, [FromBody] ImportedFileTbc importedFileTbc, [FromServices] ISchedulerProxy schedulerProxy) { // MobileLinework .kml/.kmz files are sent along with linework files // we need to suppress any error and return as if all ok. // however we won't have a LegacyFileId to return - hmmm hope Business centre ignores this if (importedFileTbc.ImportedFileTypeId == ImportedFileType.MobileLinework) { Logger.LogInformation( $"{nameof(UpsertImportedFileV5TBC)}: Ignore MobileLinework from BusinessCentre. projectId {projectId} importedFile: {JsonConvert.SerializeObject(importedFileTbc)}"); return(ReturnLongV5Result.CreateLongV5Result(HttpStatusCode.OK, -1)); } // this also validates that this customer has access to the projectUid var project = await ProjectRequestHelper.GetProjectForCustomer(new Guid(CustomerUid), new Guid(UserId), projectId, Logger, ServiceExceptionHandler, CwsProjectClient, customHeaders); var projectUid = project.ProjectId; importedFileTbc = FileImportV5TBCDataValidator.ValidateUpsertImportedFileRequest(new Guid(projectUid), importedFileTbc); Logger.LogInformation( $"{nameof(UpsertImportedFileV5TBC)}: projectId {projectId} projectUid {projectUid} importedFile: {JsonConvert.SerializeObject(importedFileTbc)}"); var fileEntry = await TccHelper.GetFileInfoFromTccRepository(importedFileTbc, Logger, ServiceExceptionHandler, FileRepo); await TccHelper.CopyFileWithinTccRepository(importedFileTbc, CustomerUid, projectUid, FileSpaceId, Logger, ServiceExceptionHandler, FileRepo).ConfigureAwait(false); ImportedFileDescriptorSingleResult importedFileResult; using (var ms = await TccHelper.GetFileStreamFromTcc(importedFileTbc, Logger, ServiceExceptionHandler, FileRepo)) { importedFileResult = await UpsertFileInternal(importedFileTbc.Name, ms, new Guid(projectUid), importedFileTbc.ImportedFileTypeId, importedFileTbc.ImportedFileTypeId == ImportedFileType.Linework ?importedFileTbc.LineworkFile.DxfUnitsTypeId : DxfUnitsType.Meters, fileEntry.createTime, fileEntry.modifyTime, importedFileTbc.ImportedFileTypeId == ImportedFileType.SurveyedSurface ?importedFileTbc.SurfaceFile.SurveyedUtc : (DateTime?)null, schedulerProxy); } // Automapper maps src.ImportedFileId to LegacyFileId, so this IS the one sent to TRex and used to ref via TCC var response = importedFileResult != null ? ReturnLongV5Result.CreateLongV5Result(HttpStatusCode.OK, importedFileResult.ImportedFileDescriptor.LegacyFileId) : ReturnLongV5Result.CreateLongV5Result(HttpStatusCode.InternalServerError, -1); Logger.LogInformation( $"{nameof(UpsertImportedFileV5TBC)}: Completed successfully. Response: {response} importedFile: {JsonConvert.SerializeObject(importedFileResult)}"); return(response); }
public void ValidateImportFile_CompleteDesignSurface() { var importedFileTbc = new ImportedFileTbc { FileSpaceId = _fileSpaceId, Path = _path, Name = "TheAlignment.ttm", ImportedFileTypeId = ImportedFileType.DesignSurface, CreatedUtc = _createdUtc }; FileImportV5TBCDataValidator.ValidateUpsertImportedFileRequest(_projectUid, importedFileTbc); }
public void ValidateImportFile_CompleteLinework() { var importedFileTbc = new ImportedFileTbc { FileSpaceId = _fileSpaceId, Path = _path, Name = "TheLineWork.dxf", ImportedFileTypeId = ImportedFileType.Linework, CreatedUtc = _createdUtc, LineworkFile = new LineworkFile { DxfUnitsTypeId = DxfUnitsType.ImperialFeet } }; FileImportV5TBCDataValidator.ValidateUpsertImportedFileRequest(_projectUid, importedFileTbc); }
public void ValidateImportFile_IncompleteLinework() { var importedFileTbc = new ImportedFileTbc { FileSpaceId = _fileSpaceId, Path = _path, Name = "TheLineWork.dxf", ImportedFileTypeId = ImportedFileType.Linework, CreatedUtc = _createdUtc }; var ex = Assert.Throws <ServiceException>( () => FileImportV5TBCDataValidator.ValidateUpsertImportedFileRequest(_projectUid, importedFileTbc)); Assert.NotEqual(-1, ex.GetContent.IndexOf("2075", StringComparison.Ordinal)); }
public void ValidateImportFile_UnsupportedImportedFileType() { var importedFileTbc = new ImportedFileTbc { FileSpaceId = _fileSpaceId, Path = _path, Name = _name, ImportedFileTypeId = ImportedFileType.MassHaulPlan, CreatedUtc = _createdUtc }; var ex = Assert.Throws <ServiceException>( () => FileImportV5TBCDataValidator.ValidateUpsertImportedFileRequest(_projectUid, importedFileTbc)); Assert.NotEqual(-1, ex.GetContent.IndexOf("2031", StringComparison.Ordinal)); }
public void ValidateImportFile_InvalidProjectId() { var importedFileTbc = new ImportedFileTbc { FileSpaceId = _fileSpaceId, Path = _path, Name = _name, ImportedFileTypeId = _importedFileTypeId, CreatedUtc = _createdUtc }; var ex = Assert.Throws <ServiceException>( () => FileImportV5TBCDataValidator.ValidateUpsertImportedFileRequest(new Guid(), importedFileTbc)); Assert.NotEqual(-1, ex.GetContent.IndexOf("2005", StringComparison.Ordinal)); }
public void ValidateImportFile_CompleteAlignment() { var importedFileTbc = new ImportedFileTbc { FileSpaceId = _fileSpaceId, Path = _path, Name = "TheAlignment.svl", ImportedFileTypeId = ImportedFileType.Alignment, CreatedUtc = _createdUtc, AlignmentFile = new AlignmentFile { Offset = 3 } }; FileImportV5TBCDataValidator.ValidateUpsertImportedFileRequest(_projectUid, importedFileTbc); }
public void ValidateImportFile_CompleteSurveyedSurface() { var importedFileTbc = new ImportedFileTbc { FileSpaceId = _fileSpaceId, Path = _path, Name = "TheSurfaceFile.ttm", ImportedFileTypeId = ImportedFileType.SurveyedSurface, CreatedUtc = _createdUtc, SurfaceFile = new SurfaceFile { SurveyedUtc = DateTime.UtcNow.AddDays(-1) } }; FileImportV5TBCDataValidator.ValidateUpsertImportedFileRequest(_projectUid, importedFileTbc); }