protected DesignRequest CreateDesignFromRandomImageAsync() { var rand = new Random(); var files = Directory.GetFiles("C:\\BFU\\350years\\pngs", "*.png"); var randomImageFileName = files[rand.Next(files.Length)]; var design = new DesignRequest { name = $"Design created on {DateTime.Now}", type = DesignTypes.dtg, sides = new DesignSides { front = new DesignSide { artwork = randomImageFileName, aspect = 1, resize = true, dimensions = Dimension.Width(11), position = new Position { horizontal = "C", offset = PositionOffset.FromTop(2.5f) } } } }; return(design); }
public Task <ContractExecutionResult> UpdateDesign([FromBody] DesignRequest designRequest) { Log.LogInformation($"{nameof(UpdateDesign)}: {JsonConvert.SerializeObject(designRequest)}"); designRequest.Validate(); GatewayHelper.ValidateAndGetSiteModel(nameof(UpdateDesign), designRequest.ProjectUid, true); if (!DesignExists(designRequest.ProjectUid, designRequest.FileType, designRequest.DesignUid)) { return(Task.FromResult(new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Design doesn't exist. Cannot update."))); } if (designRequest.FileType == ImportedFileType.DesignSurface || designRequest.FileType == ImportedFileType.SurveyedSurface) { return(WithServiceExceptionTryExecuteAsync(() => RequestExecutorContainer .Build <UpdateTTMDesignExecutor>(ConfigStore, LoggerFactory, ServiceExceptionHandler) .ProcessAsync(designRequest))); } if (designRequest.FileType == ImportedFileType.Alignment) { return(WithServiceExceptionTryExecuteAsync(() => RequestExecutorContainer .Build <UpdateSVLDesignExecutor>(ConfigStore, LoggerFactory, ServiceExceptionHandler) .ProcessAsync(designRequest))); } throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "File type must be DesignSurface, SurveyedSurface or Alignment")); }
/// <summary> /// Notify TRex of updated DESIGN file /// </summary> public static async Task <ContractExecutionResult> NotifyTRexUpdateFile(Guid projectUid, ImportedFileType importedFileType, string filename, Guid importedFileUid, DateTime?surveyedUtc, ILogger log, IHeaderDictionary headers, IServiceExceptionHandler serviceExceptionHandler, ITRexImportFileProxy tRexImportFileProxy) { var result = new ContractExecutionResult(); string fullFileName = filename; if (importedFileType == ImportedFileType.SurveyedSurface && surveyedUtc != null) { fullFileName = fullFileName.IncludeSurveyedUtcInName(surveyedUtc.Value); } var request = new DesignRequest(projectUid, importedFileType, fullFileName, importedFileUid, surveyedUtc); try { result = await tRexImportFileProxy .UpdateFile(request, headers) .ConfigureAwait(false); } catch (Exception e) { log.LogError(e, $"NotifyTRexAddFile UpdateFile in Trex gateway failed with exception. request:{JsonConvert.SerializeObject(request)} filename: {fullFileName}"); serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 57, "tRexImportFile.UpdateFile", e.Message); } return(result); }
/// ***************************************************************************************** /// General Tables process - Only Web/convert orders rows are processed here: /// (1) - Select order type process depending on order type. /// (2) - Route process to the corresponding order types import process using delegates. /// (3) - Unrecognized data types and Service reading errors are detected here. /// (4) - Errors are logged in service log and reported through web services. /// ----------------------------------------------------------------------------------------- public void ProcessOrder(string order, EtlTimer sync) { /// Initialize Error messages object basic information string OrdNumber = ""; ServiceResponse errMsg = new ServiceResponse(); errMsg.FileType = "1"; errMsg.FileName = "Catalog Design Request: " + order.ToString(); errMsg.NISOrderId = "0"; errMsg.Status = "Not Processed"; errMsg.Message = string.Empty; try { /// ********************************************************************************* /// Select files acceptable to be process, all other file types (extension) will not /// be processed (they stay in the newFiles folder) and an error message is generated /// to the WebServices. /// Only Catalog Web Order (1) row are processed by entry. /// --------------------------------------------------------------------------------- // access catalog convert orders list if (sync.OrderType == 0) { /// ======== > DesignRequest designRequest = new DesignRequest(); designRequest = idr.getDesignRequest(order); /// <========= OrdNumber = designRequest.DesignId; // /// Instanciate NBI Tables methods delegate Del handler = null; // Declare a class instance: ImportProcedure_DesignRequest.DesignRequestJson.ImportProcess table = new ImportProcedure_DesignRequest.DesignRequestJson.ImportProcess(); /// Declare an interface instance Table: ImportProcedure_DesignRequest.DesignRequestJson.IDesignRequestTables designClass = (ImportProcedure_DesignRequest.DesignRequestJson.IDesignRequestTables)table; /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /// Identify Catalog Web order table and route them to the corresponding import procedure /// ---------------------------------------------------------------------------- // Catalog Web Order table process handler = designClass.ProcessDesignRequestOrder; // /// =========== > bool ok = false; ok = handler(designRequest, order, sync); // Process file and WebService // OrdNumber = (designRequest.DesignId).ToString(); // } else { // update error order - set imported on and import problem on ikr.writeSyncLog(1, sync.MwEtlTimerId, 1, sync.ServiceName, "Table reading error order header not found or no items in file, order " + OrdNumber); } } catch (Exception fle) { int res = ikr.updImportControl(sync.MwEtlTimerId, 0); // set EtlTimer for this service to not Running (isRunning = false) errMsg.Message = "(Catalog Design request Process) Table reading error - in order " + errMsg.FileName + ". " + fle; ikr.writeSyncLog(1, sync.MwEtlTimerId, 1, sync.ServiceName, errMsg.Message); } }
public void DesignRequestValidation_Errors(string projectUid, ImportedFileType fileType, string fileName, string designUid, int expectedCode, string expectedMessage) { var designSurfaceRequest = new DesignRequest(Guid.Parse(projectUid), fileType, fileName, Guid.Parse(designUid), null); var ex = Assert.Throws <ServiceException>(() => designSurfaceRequest.Validate()); Assert.Equal(expectedCode, ex.GetResult.Code); Assert.Equal(expectedMessage, ex.GetResult.Message); }
private async Task <ContractExecutionResult> SendImportFileRequest(DesignRequest designRequest, IHeaderDictionary customHeaders, HttpMethod method) { var jsonData = JsonConvert.SerializeObject(designRequest); using (var payload = new MemoryStream(Encoding.UTF8.GetBytes(jsonData))) { // Need to await this, as we need the stream (if we return the task, the stream is disposed) return(await MasterDataItemServiceDiscoveryNoCache <ContractExecutionResult>("design", customHeaders, method, payload : payload)); } }
/// <summary> /// Notify TRex of new DESIGN file /// </summary> /// <returns></returns> public static async Task <ContractExecutionResult> NotifyTRexAddFile(Guid projectUid, ImportedFileType importedFileType, string filename, Guid importedFileUid, DateTime?surveyedUtc, ILogger log, IHeaderDictionary headers, IServiceExceptionHandler serviceExceptionHandler, ITRexImportFileProxy tRexImportFileProxy, IProjectRepository projectRepo ) { var result = new ContractExecutionResult(); string fullFileName = filename; if (importedFileType == ImportedFileType.SurveyedSurface && surveyedUtc != null) { fullFileName = fullFileName.IncludeSurveyedUtcInName(surveyedUtc.Value); } var request = new DesignRequest(projectUid, importedFileType, fullFileName, importedFileUid, surveyedUtc); try { result = await tRexImportFileProxy .AddFile(request, headers) .ConfigureAwait(false); } catch (Exception e) { log.LogError(e, $"NotifyTRexAddFile AddFile in Trex gateway failed with exception. request:{JsonConvert.SerializeObject(request)} filename: {fullFileName}"); await ImportedFileRequestDatabaseHelper.DeleteImportedFileInDb (projectUid, importedFileUid, serviceExceptionHandler, projectRepo, true) .ConfigureAwait(false); serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 57, "tRexImportFile.AddFile", e.Message); } log.LogDebug( $"NotifyTRexAddFile: projectUid: {projectUid}, filename: {filename} importedFileUid {importedFileUid}. TRex returned code: {result?.Code ?? -1}."); if (result != null && result.Code != 0) { log.LogError( $"NotifyTRexAddFile AddFile in Trex failed. projectUid: {projectUid}, filename: {filename} importedFileUid {importedFileUid}. Reason: {result?.Code ?? -1} {result?.Message ?? "null"}."); await ImportedFileRequestDatabaseHelper.DeleteImportedFileInDb(projectUid, importedFileUid, serviceExceptionHandler, projectRepo, true) .ConfigureAwait(false); serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 114, result.Code.ToString(), result.Message); } return(result); }
/// ************************************************************************************************* /// <summary> /// 07/06/2017 10:23 version /// Catalog Web Orders process, un-imported web orders are retreived and mapped to an object (header/detail /// sections). /// Each section is send to WebServices as a JSON string if header/detail information is complete, /// when detail info. /// All errors are send to a Webservice (Error) and included in the Service log. /// </summary> /// <param name="doc">Imported Web orders</param> /// <param name="oNumber">Web Order number</param> /// <param name="syncRow">EtlTimer sync control data)</param> /// <returns>Process status true if procees was completed ok, else false</returns> /// ------------------------------------------------------------------------------------------------- bool IDesignRequestTables.ProcessDesignRequestOrder(DesignRequest doc, string oNumber, EtlTimer syncRow) { //bool rStatus = false; // WebService return status (default=false) ServiceResponse rStatus = new ServiceResponse(); Dictionary <string, string> configValues = new Dictionary <string, string>(); FTPServerIP = ConfigurationManager.AppSettings["FTPServerIP"]; // configValues[ConfigurationValues.FTP_SERVER_IP]; FTPUserID = ConfigurationManager.AppSettings["FTPUserID"]; // configValues[ConfigurationValues.FTP_USER_ID]; FTPPassword = ConfigurationManager.AppSettings["FTPPassword"]; // configValues[ConfigurationValues.FTP_PASSWORD]; // ClientArtImagesFolderSource = syncRow.ExcelFileFolder; ClientArtImagesFolderDestination = syncRow.ProcessedFileFolder; /// Create error message object and initialice it ServiceResponse errMsg = new ServiceResponse(); errMsg.FileType = "1"; // Set Nis Type errMsg.FileName = "Catalog Design Request Table"; errMsg.NISOrderId = oNumber.ToString(); errMsg.Status = "Not Processed"; errMsg.Message = "Design request not found"; /// ********************************************************************************************* // Design request order /// --------------------------------------------------------------------------------------------- /// =============================================================================== /// Send Imported files data content to webServices - information must be complete /// Order Header + all related Order Items. /// ------------------------------------------------------------------------------- if (doc != null) { /// ****************************************************************************** /// Call Web Service /// <param name="json2"> Header/detail object Json serialized string.</param> /// <param name="fname"> Xml file name </param> /// <param name="syncRow.WebServiceOrders">File Type, route to web service(url)</param> /// <param name="syncRow"> EtlTimer control data. /// <returns>"rStatus.IsOk" true if WebService was processed, else false</returns> /// *** Web service url is defined in the App.Config file key 'NisOrder'. /// ------------------------------------------------------------------------------ /// /// Process design Request image /// string errorMessage = " "; rStatus.IsOk = ProcessDesignRequestImage(doc, out errorMessage); // , errorMessage); /// string apiMsg = ""; int resp = 0; // Order update response // string json2 = "{ \"WebOrderSummary\":" + Newtonsoft.Json.JsonConvert.SerializeObject(doc) + "}"; if (rStatus.IsOk) { /// ==============> save order data through the defined web service /// rStatus = wsm.ConsumeWebService(json2, oNumber, syncRow.WebServiceOrders, syncRow); //"OrderData", syncRow); //// TEMPORARY UNCOMMENT TO SEND JSON INFO /// ------------------------------------------------------------------------------ /// UNCOMMENT IF WEB SERVICE IS USED TO SEND JSON INFO //rStatus.IsOk = true; /// set order process to ok TEMPORARY, rStatus.NISOrderId = "Nav1234567"; /// ------------------------------------------------------------------------------ if (rStatus.IsOk) { // set order condition to imported apiMsg = " Imported"; // resp = idr.updDesignRequest(oNumber, "Imported", 1); if (resp < 1) { apiMsg += " but Design Request status not updated due to DB access errors."; } } else { // Set order contion to imported with errors. apiMsg = " Not Imported - API errors" + " Image errors: " + errorMessage; } } string ret = ikr.writeSyncLog(1, syncRow.MwEtlTimerId, 1, syncRow.ServiceName, "> " + syncRow.Description + " Catalog Web Order: <" + doc.DesignId + "> " + apiMsg + "."); // <============== } else { /// Incomplete order (No order items included and no xls file Name reported in orderHeader) //json2 = json2 + " }"; /// Send Message to WebService wsm.WriteErrorFile(errMsg, syncRow); //// TEMPORARY UNCOMMENT TO SEND JSON INFO } return(rStatus.IsOk); }
// ****************************************************** IMAGES MANAGEMENT ****************************************************** /// <summary> /// Get design request image information - create it from image or text depending iin the artwork column /// </summary> /// <param name="designRequest"></param> /// <param name="errorMessage"> Out parameter error message</param> /// <returns>boolean</returns> bool ProcessDesignRequestImage(DesignRequest designRequest, out string errorMessage) { bool bRetVal; string sRetVal = ""; string font_1_art = ""; string textbox_1_art = ""; string font_2_art = ""; string textbox_2_art = ""; string font_3_art = ""; string textbox_3_art = ""; errorMessage = ""; try { /* ALL DESIGN REQUESTS VALIDATION WILL BE PERFORMED BY THE MIDDLEWARE * /// When shipping quantity is not 0 and shipping address is not blank, address edit can't be 0 * if ((designRequest.ShipQty1 != "0") && (designRequest.ShipAddress1 != "") * && (designRequest.ShippingAddressesAddress1Addedit == 0 )) // shipping_addresses_address_1_addedit == 0)) * { * errorMessage = Constants.ERROR_FOUND_PROCESSING_DESIGN_REQUEST_SHIPPING_ADDRESS_HAVE_NOT_BEEN_UPDATED + designRequest.DesignId; * return false; * } * * if ((designRequest.ShipQty2 != "0") && (designRequest.ShipAddress2 != "") * && (designRequest.ShippingAddressesAddress2Addedit == 0 )) //shipping_addresses_address_2_addedit == 0)) * { * errorMessage = Constants.ERROR_FOUND_PROCESSING_DESIGN_REQUEST_SHIPPING_ADDRESS_HAVE_NOT_BEEN_UPDATED + designRequest.DesignId; * return false; * } * * * if ((designRequest.ShipQty3 != "0") && (designRequest.ShipAddress3 != "") * && (designRequest.ShippingAddressesAddress3Addedit == 0 )) //shipping_addresses_address_3_addedit == 0)) * { * errorMessage = Constants.ERROR_FOUND_PROCESSING_DESIGN_REQUEST_SHIPPING_ADDRESS_HAVE_NOT_BEEN_UPDATED + designRequest.DesignId; * return false; * } * * // Validate design id column, must be 6 characters. * if (designRequest.DesignId.Length != 6) * { * errorMessage = Constants.ERROR_FOUND_PROCESSING_DESIGN_REQUEST_DESIGN_ID_LENGTH_IS_NOT_VALID + designRequest.CatDesignRequestOrderId; * return false; * } */ if (designRequest.DrStitchFonts1WeiId != null) { font_1_art = designRequest.DrStitchFonts1WeiId; } if (designRequest.DrStitchFonts2WeiId != null) { font_2_art = designRequest.DrStitchFonts2WeiId; } if (designRequest.DrStitchFonts3WeiId != null) { font_3_art = designRequest.DrStitchFonts3WeiId; } if (designRequest.OptionalArtText1 != null) { textbox_1_art = designRequest.OptionalArtText1; } if (designRequest.OptionalArtText2 != null) { textbox_2_art = designRequest.OptionalArtText2; } if (designRequest.OptionalArtText3 != null) { textbox_3_art = designRequest.OptionalArtText3; } if (designRequest.Artwork.Equals("Upload")) { if ((designRequest.DrProductTypeWeiId != "STP") && (textbox_2_art == "")) { errorMessage = Constants.ERROR_FOUND_PROCESSING_DESIGN_REQUEST_NO_ARTWORK_IMAGE_AVAILABLE + designRequest.CatDesignRequestOrderId; return(false); } if (textbox_2_art != "") { sRetVal = DownloadFileFromServerUsingWebClientFTP(FTPServerIP, FTPUserID, FTPPassword, textbox_2_art, ClientArtImagesFolderDestination, designRequest.CatDesignRequestOrderId); if (sRetVal != "") { errorMessage = Constants.ERROR_FOUND_PROCESSING_DESIGN_REQUEST_FTP_PROBLEM + designRequest.DesignId + ". FTP Problem = " + sRetVal; return(false); } } } else { bRetVal = CreateImageFileFromText(font_1_art, font_2_art, font_3_art, textbox_1_art, textbox_2_art, textbox_3_art, ClientArtImagesFolderDestination, designRequest.CatDesignRequestOrderId); if (!bRetVal) { errorMessage = Constants.ERROR_FOUND_PROCESSING_DESIGN_REQUEST_SHIPPING_ADDRESS_HAVE_NOT_BEEN_UPDATED + designRequest.CatDesignRequestOrderId; return(false); } } } catch (Exception ex) { errorMessage = Constants.ERROR_FOUND_PROCESSING_DESIGN_REQUEST_EXCEPTION_THROWN + designRequest.DesignId + ". Exception =" + ex.Message; return(false); } return(true); }
public void GivenADesignIsCreatedFromARandomImageInTheImagesFolder() { design = CreateDesignFromRandomImageAsync(); }
public ContractExecutionResult DeleteDesign([FromBody] DesignRequest designRequest) { return(new ContractExecutionResult()); }
/// <summary> /// Add a design or surveyed surface or alignment file to TRex /// </summary> protected async Task AddDesign(DesignRequest request, string executorName) { // load core file from s3 to local var localPath = FilePathHelper.GetTempFolderForProject(request.ProjectUid); var localPathAndFileName = Path.Combine(new[] { localPath, request.FileName }); DesignBase design; if (request.FileType == ImportedFileType.Alignment) { design = new SVLAlignmentDesign(); } else { design = new TTMDesign(SubGridTreeConsts.DefaultCellSize); } var designLoadResult = design.LoadFromStorage(request.ProjectUid, request.FileName, localPath); if (designLoadResult != DesignLoadResult.Success) { log.LogError($"#Out# {executorName}. Addition of design failed :{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}, designLoadResult: {designLoadResult}"); throw CreateServiceException <TExecutor> (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError, RequestErrorStatus.DesignImportUnableToRetrieveFromS3, designLoadResult.ToString()); } if (request.FileType != ImportedFileType.Alignment) { // This generates the 2 index files designLoadResult = design.LoadFromFile(localPathAndFileName); if (designLoadResult != DesignLoadResult.Success) { log.LogError($"#Out# {executorName}. Addition of design failed :{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}, designLoadResult: {designLoadResult}"); throw CreateServiceException <TExecutor> (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError, RequestErrorStatus.DesignImportUnableToCreateDesign, designLoadResult.ToString()); } } var extents = new BoundingWorldExtent3D(); design.GetExtents(out extents.MinX, out extents.MinY, out extents.MaxX, out extents.MaxY); design.GetHeightRange(out extents.MinZ, out extents.MaxZ); if (request.FileType == ImportedFileType.DesignSurface) { // Create the new designSurface in our site var tRexRequest = new AddTTMDesignRequest(); var designSurfaceUid = await tRexRequest.ExecuteAsync(new AddTTMDesignArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), Extents = extents, ExistenceMap = design.SubGridOverlayIndex() }); } if (request.FileType == ImportedFileType.SurveyedSurface) { // Create the new SurveyedSurface in our site model var tRexRequest = new AddSurveyedSurfaceRequest(); var surveyedSurfaceUid = await tRexRequest.ExecuteAsync(new AddSurveyedSurfaceArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), AsAtDate = request.SurveyedUtc ?? TRex.Common.Consts.MIN_DATETIME_AS_UTC, // validation will have ensured this exists Extents = extents, ExistenceMap = design.SubGridOverlayIndex() }); } if (request.FileType == ImportedFileType.Alignment) { // Create the new alignment in our site model var tRexRequest = new AddAlignmentRequest(); var alignmentUid = await tRexRequest.ExecuteAsync(new AddAlignmentArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), Extents = extents }); } if (request.FileType != ImportedFileType.Alignment) { // TTM.LoadFromFile() will have created these 3 files. We need to store them on S3 to reload cache when required var s3FileTransfer = new S3FileTransfer(TransferProxyType.DesignImport); s3FileTransfer.WriteFile(localPath, request.ProjectUid, SubGridIndexFileName(request.FileName)); s3FileTransfer.WriteFile(localPath, request.ProjectUid, SpatialIndexFileName(request.FileName)); s3FileTransfer.WriteFile(localPath, request.ProjectUid, BoundaryFileName(request.FileName)); } }
/// <summary> /// Delete a design or surveyed surface or alignment file from TRex /// </summary> protected async Task RemoveDesign(DesignRequest request, string executorName) { bool removedOk = false; if (request.FileType == ImportedFileType.DesignSurface) { // Remove the designSurface var tRexRequest = new RemoveTTMDesignRequest(); var removeResponse = await tRexRequest.ExecuteAsync(new RemoveTTMDesignArgument { ProjectID = request.ProjectUid, DesignID = request.DesignUid }); removedOk = removeResponse.RequestResult == DesignProfilerRequestResult.OK; } if (request.FileType == ImportedFileType.SurveyedSurface) { // Remove the new surveyedSurface var tRexRequest = new RemoveSurveyedSurfaceRequest(); var removeResponse = await tRexRequest.ExecuteAsync(new RemoveSurveyedSurfaceArgument { ProjectID = request.ProjectUid, DesignID = request.DesignUid }); removedOk = removeResponse.RequestResult == DesignProfilerRequestResult.OK; } if (request.FileType == ImportedFileType.Alignment) { // Remove the alignment var tRexRequest = new RemoveAlignmentRequest(); var removeResponse = await tRexRequest.ExecuteAsync(new RemoveAlignmentArgument { ProjectID = request.ProjectUid, AlignmentID = request.DesignUid }); removedOk = removeResponse.RequestResult == DesignProfilerRequestResult.OK; } if (!removedOk) { log.LogError($"#Out# {executorName}. Deletion failed, of design:{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}"); throw CreateServiceException <TExecutor> (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError, RequestErrorStatus.DesignImportUnableToDeleteDesign); } //Remove local copies of files var localPath = FilePathHelper.GetTempFolderForProject(request.ProjectUid); var localPathAndFileName = Path.Combine(new[] { localPath, request.FileName }); if (File.Exists(localPathAndFileName)) { try { File.Delete(localPathAndFileName); if (request.FileType != ImportedFileType.Alignment) { //Delete index files var indexFileName = SubGridIndexFileName(localPathAndFileName); if (File.Exists(indexFileName)) { File.Delete(indexFileName); } indexFileName = SpatialIndexFileName(localPathAndFileName); if (File.Exists(indexFileName)) { File.Delete(indexFileName); } indexFileName = BoundaryFileName(localPathAndFileName); if (File.Exists(indexFileName)) { File.Delete(indexFileName); } } } catch (Exception e) { log.LogError(e, $"Failed to delete files related to design/surveyed surface {request.DesignUid} in project {request.ProjectUid}"); } } if (request.FileType != ImportedFileType.Alignment) { //Remove the index files from s3 (project service removes the actual file from s3 as it put it there originally) var s3FileTransfer = new S3FileTransfer(TransferProxyType.DesignImport); s3FileTransfer.RemoveFileFromBucket(request.ProjectUid, SubGridIndexFileName(request.FileName)); s3FileTransfer.RemoveFileFromBucket(request.ProjectUid, SpatialIndexFileName(request.FileName)); s3FileTransfer.RemoveFileFromBucket(request.ProjectUid, BoundaryFileName(request.FileName)); } }
/// <summary> /// Notifies Trex that a design file has been deleted from a project /// </summary> public async Task <ContractExecutionResult> DeleteFile(DesignRequest designRequest, IHeaderDictionary customHeaders = null) { Gateway = GatewayType.Mutable; return(await SendImportFileRequest(designRequest, customHeaders, HttpMethod.Delete)); }
public void DesignRequestValidation_HappyPath(string projectUid, ImportedFileType fileType, string fileName, string designUid, DateTime surveyedUtc) { var designSurfaceRequest = new DesignRequest(Guid.Parse(projectUid), fileType, fileName, Guid.Parse(designUid), surveyedUtc); designSurfaceRequest.Validate(); }
public async Task <DesignResponse> CreateDesignAsync(DesignRequest design) => await CallMultipartAPIAsync <DesignResponse>(typeof(DesignAPI), nameof(DesignAPI.CreateDesignAsync), design).ConfigureAwait(false);