예제 #1
0
        public async Task <bool> Callback(CancellationToken cancellationToken)
        {
            _logger.LogInfo("Reporting callback invoked");

            try
            {
                foreach (string taskItem in _reportServiceContext.Tasks)
                {
                    _reports.TryGetValue(taskItem, out var report);

                    if (cancellationToken.IsCancellationRequested)
                    {
                        break;
                    }

                    if (report == null)
                    {
                        if (taskItem.CaseInsensitiveEquals("TaskClearPeriodEndDASZip"))
                        {
                            await _reportZipService.RemoveZipAsync(_reportServiceContext, cancellationToken);
                        }
                        else
                        {
                            _logger.LogError($"Report with key {taskItem} not found");
                        }

                        continue;
                    }

                    var fileName = await report.GenerateReport(_reportServiceContext, cancellationToken);

                    if (report.IncludeInZip)
                    {
                        await _reportZipService.CreateOrUpdateZipWithReportAsync(fileName, _reportServiceContext, cancellationToken);
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message, e);
                throw;
            }

            _logger.LogInfo("End of Reporting Entry Point");
            return(true);
        }