Exemplo n.º 1
0
        public ScheduleJobResult StartExport([FromBody] ScheduleJobRequest request)
        {
            log.LogInformation($"StartExport: Url {request?.Url}");

            JobRequest jobRequest = new JobRequest()
            {
                JobUid = Guid.Parse("c3cbb048-05c1-4961-a799-70434cb2f162"), SetupParameters = request, RunParameters = Request.Headers.GetCustomHeaders()
            };

            log.LogInformation($"{nameof(StartExport)}: {JsonConvert.SerializeObject(request)}");
            jobRequest.Validate();
            jobRequest.AttributeFilters = SpecialFilters.ExportFilter;
            string hangfireJobId;

            try
            {
                hangfireJobId = jobRunner.QueueHangfireJob(jobRequest);
            }
            catch (Exception e)
            {
                log.LogError($"Queue VSS job failed with exception {e.Message}", e);
                throw;
            }

            //Hangfire will substitute a PerformContext automatically
            return(new ScheduleJobResult {
                JobId = hangfireJobId
            });
        }
Exemplo n.º 2
0
        public async Task Run(object o, object context)
        {
            recipients = o.GetConvertedObject <string[]>();

            log.LogDebug($"Starting to process {customerProjects?.Count} projects");

            foreach (var project in customerProjects)
            {
                JobRequest jobRequest;

                try
                {
                    log.LogInformation($"Processing project {project.Name}");
                    // Create a relevant filter
                    var filter = await filters.CreateFilter(project.ProjectUID, new FilterRequest()
                    {
                        FilterType = FilterType.Transient, FilterJson = FILTER_JSON
                    }, headers);

                    log.LogDebug($"Created filter {filter.FilterDescriptor.FilterUid}");
                    //generate filename
                    var generatedFilename = $"{project.Name + " " + DateTime.UtcNow.ToString("yyyy-MM-ddTHH-mm-ss")}";
                    log.LogDebug($"Generated filename {generatedFilename}");
                    //generate uri
                    var baseUri = await serviceResolution.ResolveService("productivity3dinternal_service_public_v2");

                    var requestUri = $"{baseUri.Endpoint}/api/v2/export/machinepasses?projectUid={project.ProjectUID}&filename={generatedFilename}&filterUid={filter.FilterDescriptor.FilterUid}&coordType=0&outputType=0&restrictOutput=False&rawDataOutput=False";
                    log.LogDebug($"Export request url {requestUri}");
                    var jobExportRequest = new ScheduleJobRequest()
                    {
                        Url = requestUri, Timeout = 9000000, Filename = generatedFilename
                    };
                    jobRequest = new JobRequest()
                    {
                        JobUid = Guid.Parse("c3cbb048-05c1-4961-a799-70434cb2f162"), SetupParameters = jobExportRequest, RunParameters = headers, AttributeFilters = SpecialFilters.ExportFilter
                    };
                }
                catch (Exception e)
                {
                    log.LogError(e, $"Failed to prepare for exports with exception");
                    throw;
                }

                try
                {
                    log.LogDebug($"Firing export job for project {project.Name}");
                    var hangfireJobId = jobRunner.QueueHangfireJob(jobRequest, exportEmailGenerator);
                    JobStorage.Current.GetConnection().SetJobParameter(hangfireJobId, Tags.PROJECTNAME_TAG, JsonConvert.SerializeObject(project.Name));
                    JobStorage.Current.GetConnection().SetJobParameter(hangfireJobId, Tags.RECIPIENTS_TAG, JsonConvert.SerializeObject(recipients));
                }
                catch (Exception e)
                {
                    log.LogError(e, $"Queue VSS job failed with exception {e.Message}");
                    throw;
                }
            }
        }
Exemplo n.º 3
0
        public ScheduleJobResult RunJob([FromBody] JobRequest request)
        {
            Log.LogInformation($"{nameof(RunJob)}: {JsonConvert.SerializeObject(request)}");
            request.Validate();
            string hangfireJobId;

            try
            {
                hangfireJobId = JobRunner.QueueHangfireJob(request);
            }
            catch (Exception e)
            {
                Log.LogError(e, $"Queue VSS job failed with exception {e.Message}");
                throw;
            }

            //Hangfire will substitute a PerformContext automatically
            return(new ScheduleJobResult {
                JobId = hangfireJobId
            });
        }