コード例 #1
0
        public async Task RunAtTimeOf(DateTime now)
        {
            var config = _ctx.JobGettingConfig.FirstOrDefault();

            if (config == null)
            {
                return;
            }
            _logger.LogInformation("SummaryGeneratorJob Starts... ");
            string connectionString = Secrets.GetDBConnectionString(_configuration);

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                // Create the Command and Parameter objects.
                MySqlCommand command = new MySqlCommand(@"
                      SELECT Id, Description FROM `jobtransparency`.`JobPostings` WHERE Description = ''
                ", connection);

                command.CommandTimeout = config.SQLCommandTimeOut;
                try
                {
                    connection.Open();
                    var reader = await command.ExecuteReaderAsync();

                    while (reader.Read())
                    {
                        var Id          = (int)reader[0];
                        var Description = (string)reader[1];

                        Description = new string(Description.Where(c => !char.IsPunctuation(c)).ToArray());
                        SummaryDTO nltkSummary = await _nltkService.ExtractSummary(Description);

                        var Job = await _jobPostingRepository.GetById(Id);

                        Job.Summary = nltkSummary.SummaryText;

                        await _jobPostingRepository.Put(Job.Id, Job);
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    _logger.LogInformation(ex, "SummaryGeneratorJob Ends... ");
                }
            }

            _logger.LogInformation("SummaryGeneratorJob Ends... ");
        }
コード例 #2
0
        public async Task <IActionResult> PutJobPosting(int id, JobPosting jobPosting)
        {
            if (id != jobPosting.Id)
            {
                return(BadRequest());
            }

            JobPosting returnedJobPosting = await _JobPostingRepository.Put(id, jobPosting);

            if (returnedJobPosting != null)
            {
                return(Ok());
            }

            return(BadRequest());
        }