Пример #1
0
 public void DoJob()
 {
     try
     {
         OnDoJob();
         JobFinished?.Invoke(this, EventArgs.Empty);
     }
     catch (Exception err)
     {
         JobFailed?.Invoke(this, err);
         throw;
     }
 }
Пример #2
0
        public void OnJobFailed(JobInfo job, string reason, string details = null, bool notifyUser = false)
        {
            using var scope       = scopeFactory.CreateScope();
            using var dataContext = scope.ServiceProvider.GetRequiredService <DataContext>();

            job.State     = JobState.Failed;
            job.Completed = DateTimeOffset.UtcNow;
            dataContext.SaveChanges();

            userLogger.LogInfo("Job failed", reason, userId: job.UserId, jobId: job.Id);
            JobFailed?.Invoke(this, new JobFailedEventArgs()
            {
                Job = job, Reason = reason, Details = details
            });
        }
 public void InvokeJobFailed(TranslationJob job)
 {
     JobFailed?.Invoke(job);
 }
Пример #4
0
 private void OnJobFailed(JobFailedEventArgs eventArgs) => JobFailed?.Invoke(this, eventArgs);