public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("Export Drawing PDF ({Id})"); Logger.LogInformation($"ProcessJob (ExportDrawingPDF) {Id} for project {ProjectId} started."); (FdaStatsDTO stats, int drawingIndex) = await ProjectWork.ExportDrawingPdfAsync(ProjectId, _hash, _drawingKey); Logger.LogInformation($"ProcessJob (ExportDrawingPDF) {Id} for project {ProjectId} completed."); string url = ""; if (stats != null) { url = _linkGenerator.GetPathByAction(controller: "Download", action: "DrawingPdf", values: new { projectName = ProjectId, hash = _hash, index = drawingIndex }); // when local url starts with slash, it does not work, because it is doubled in url if (url.StartsWith('/')) { url = url.Substring(1); } } await resultSender.SendSuccessAsync(url, stats); }
public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("Project Adoption ({Id})"); Logger.LogInformation($"ProcessJob (Adopt) {Id} for project {_projectInfo.Name} started."); // Check for valid project and root names (where applicable) if ((!string.IsNullOrEmpty(_projectInfo.TopLevelAssembly) && Regex.Match(_projectInfo.TopLevelAssembly, @"[\uFFF0-\uFFFF]").Success) || Regex.Match(_projectInfo.Name, @"[\uFFF0-\uFFFF]").Success) { Logger.LogInformation($"Replacement charcters found in project name or top level assembly name for job {Id}."); throw new ProcessingException("Project name or assembly contains unsupported characters", new[] { "Please refer to https://github.com/Autodesk-Forge/forge-configurator-inventor/blob/master/README.md#project-file-zip-encoding" }); } // upload the file to OSS var bucket = await _userResolver.GetBucketAsync(tryToCreate : true); ProjectStorage projectStorage = await _userResolver.GetProjectStorageAsync(_projectInfo.Name); string ossSourceModel = projectStorage.Project.OSSSourceModel; await bucket.SmartUploadAsync(_fileName, ossSourceModel); // cleanup before adoption File.Delete(_fileName); // adopt the project bool adopted = false; FdaStatsDTO stats; string reportUrl = null; try { string signedUploadedUrl = await bucket.CreateSignedUrlAsync(ossSourceModel); (stats, reportUrl) = await ProjectWork.AdoptAsync(_projectInfo, signedUploadedUrl); adopted = true; } finally { // on any failure during adoption we consider that project adoption failed and it's not usable if (!adopted) { Logger.LogInformation($"Adoption failed. Removing '{ossSourceModel}' OSS object."); await bucket.DeleteObjectAsync(ossSourceModel); } } Logger.LogInformation($"ProcessJob (Adopt) {Id} for project {_projectInfo.Name} completed."); await resultSender.SendSuccessAsync(_dtoGenerator.ToDTO(projectStorage), stats, reportUrl); }
public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("Update Model ({Id})"); Logger.LogInformation($"ProcessJob (Update) {Id} for project {ProjectId} started."); ProjectStateDTO updatedState = await ProjectWork.DoSmartUpdateAsync(Parameters, ProjectId); Logger.LogInformation($"ProcessJob (Update) {Id} for project {ProjectId} completed."); // send that we are done to client await resultSender.SendSuccessAsync(updatedState); }
public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("Project Adoption ({Id})"); var payload = await _adoptProjectWithParametersPayloadProvider.GetParametersAsync(_payloadUrl); Logger.LogInformation($"ProcessJob (AdoptProjectWithParameters) {Id} for project {payload.Name} started."); var projectWithParameters = await _projectService.AdoptProjectWithParametersAsync(payload); Logger.LogInformation($"ProcessJob (AdoptProjectWithParameters) {Id} for project {payload.Name} completed."); await resultSender.SendSuccessAsync(projectWithParameters); }
public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("Project Adoption ({Id})"); Logger.LogInformation($"ProcessJob (Adopt) {Id} for project {_projectInfo.Name} started."); // upload the file to OSS var bucket = await _userResolver.GetBucketAsync(tryToCreate : true); ProjectStorage projectStorage = await _userResolver.GetProjectStorageAsync(_projectInfo.Name); string ossSourceModel = projectStorage.Project.OSSSourceModel; await bucket.SmartUploadAsync(_fileName, ossSourceModel); // cleanup before adoption File.Delete(_fileName); // adopt the project bool adopted = false; FdaStatsDTO stats; try { string signedUploadedUrl = await bucket.CreateSignedUrlAsync(ossSourceModel); stats = await ProjectWork.AdoptAsync(_projectInfo, signedUploadedUrl); adopted = true; } catch (FdaProcessingException fpe) { await resultSender.SendErrorAsync(Id, fpe.ReportUrl); return; } finally { // on any failure during adoption we consider that project adoption failed and it's not usable if (!adopted) { Logger.LogInformation($"Adoption failed. Removing '{ossSourceModel}' OSS object."); await bucket.DeleteObjectAsync(ossSourceModel); } } Logger.LogInformation($"ProcessJob (Adopt) {Id} for project {_projectInfo.Name} completed."); await resultSender.SendSuccessAsync(_dtoGenerator.ToDTO(projectStorage), stats); }
public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("Drawing generation ({Id})"); Logger.LogInformation($"ProcessJob (Drawing) {Id} for project {ProjectId} started."); FdaStatsDTO stats = await ProjectWork.GenerateDrawingAsync(ProjectId, _hash); Logger.LogInformation($"ProcessJob (Drawing) {Id} for project {ProjectId} completed."); // TODO: this url can be generated right away... we can simply acknowledge that OSS file is ready, // without generating URL here var drawingUrl = _linkGenerator.GetPathByAction(controller: "Download", action: "Drawing", values: new { projectName = ProjectId, hash = _hash }); // send resulting URL to the client await resultSender.SendSuccessAsync(drawingUrl, stats); }
public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("RFA generation ({Id})"); Logger.LogInformation($"ProcessJob (RFA) {Id} for project {ProjectId} started."); (var stats, var reportUrl) = await ProjectWork.GenerateRfaAsync(ProjectId, _hash); Logger.LogInformation($"ProcessJob (RFA) {Id} for project {ProjectId} completed."); // TODO: this url can be generated right away... we can simply acknowledge that the OSS file is ready, // without generating a URL here string rfaUrl = _linkGenerator.GetPathByAction(controller: "Download", action: "RFA", values: new { projectName = ProjectId, hash = _hash }); // send resulting URL to the client await resultSender.SendSuccessAsync(rfaUrl, stats, reportUrl); }
public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("Project Adoption ({Id})"); try { var payload = await _adoptProjectWithParametersPayloadProvider.GetParametersAsync(_payloadUrl); Logger.LogInformation($"ProcessJob (AdoptProjectWithParameters) {Id} for project {payload.Name} started."); var projectWithParameters = await _projectService.AdoptProjectWithParametersAsync(payload); Logger.LogInformation($"ProcessJob (AdoptProjectWithParameters) {Id} for project {payload.Name} completed."); await resultSender.SendSuccessAsync(projectWithParameters); } catch (Exception ex) { await resultSender.SendErrorAsync(new MessagesError(Id, "Adopt project went wrong", new string[] { ex.Message })); } }
public override async Task ProcessJobAsync(IResultSender resultSender) { using var scope = Logger.BeginScope("Export Drawing ({Id})"); Logger.LogInformation($"ProcessJob (ExportDrawing) {Id} for project {ProjectId} started."); bool generated = await ProjectWork.ExportDrawingViewablesAsync(ProjectId, _hash); Logger.LogInformation($"ProcessJob (ExportDrawing) {Id} for project {ProjectId} completed."); string url = ""; if (generated) { url = _linkGenerator.GetPathByAction(controller: "Download", action: "DrawingViewables", values: new { projectName = ProjectId, fileName = "drawing.pdf", hash = _hash }); // when local url starts with slash, it does not work, because it is doubled in url url = url.IndexOf("/") == 0 ? url.Substring(1) : url; } await resultSender.SendSuccessAsync(url); }