Ejemplo n.º 1
0
        public async Task MakeReportAsync(MakeReportContract contract)
        {
            var record = await GetRecordAsync(contract.Name);

            record.Events.Add(new DashboardEventModel
            {
                Created     = DateTime.UtcNow,
                Description = contract.Description,
                Id          = Guid.NewGuid(),
                Type        = contract.Type
            });

            record.Status = contract.Type switch
            {
                DashboardEventType.Started => DashboardRecordStatus.Started,
                DashboardEventType.Completed => DashboardRecordStatus.Completed,
                DashboardEventType.InProggress => DashboardRecordStatus.Working,
                DashboardEventType.ExceptionRaised => DashboardRecordStatus.FailedWithException,
                DashboardEventType.ScheduleCheckFail => DashboardRecordStatus.NotStarted,
                _ => record.Status
            };

            record.NextUpdate = GetNextUpdate(record.Cron, DateTime.UtcNow);
            record.Updated    = DateTime.UtcNow;
            await _recordsRepository.SaveAsync(record);
        }
Ejemplo n.º 2
0
        public async Task Execute(IJobExecutionContext context)
        {
            var service = serviceProvider.GetService <IDashboradService>();
            var records = await service.GetRecordsAsync();

            foreach (var item in records)
            {
                if (item.NextUpdate < DateTime.UtcNow)
                {
                    var contract = new MakeReportContract()
                    {
                        Description = "Service not started on sceduled time",
                        Name        = item.Name,
                        Type        = Domain.DashboardEventType.ScheduleCheckFail
                    };
                    await service.MakeReportAsync(contract);
                }
            }

            System.Diagnostics.Debug.WriteLine("I AM RUNNER");
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> MakeReport(MakeReportContract contract)
        {
            await _service.MakeReportAsync(contract);

            return(NoContent());
        }