Exemplo n.º 1
0
 public async Task ExecuteAsync(RunHangfireWorkflowJobModel data)
 {
     if (data.WorkflowInstanceId == null)
     {
         await _workflowDefinitionDispatcher.DispatchAsync(new ExecuteWorkflowDefinitionRequest(data.WorkflowDefinitionId !, data.ActivityId, TenantId : data.TenantId));
     }
     else
     {
         await _workflowInstanceDispatcher.DispatchAsync(new ExecuteWorkflowInstanceRequest(data.WorkflowInstanceId, data.ActivityId));
     }
 }
        public static void UnscheduleJobWhenAlreadyExists(this IBackgroundJobClient backgroundJobClient, RunHangfireWorkflowJobModel data)
        {
            var identity        = data.GetIdentity();
            var monitor         = JobStorage.Current.GetMonitoringApi();
            var workflowJobType = typeof(RunHangfireWorkflowJob);

            var jobs = monitor.ScheduledJobs(0, int.MaxValue)
                       .Where(x => x.Value.Job.Type == workflowJobType && ((RunHangfireWorkflowJobModel)x.Value.Job.Args[0]).GetIdentity() == identity);

            foreach (var job in jobs)
            {
                BackgroundJob.Delete(job.Key);
            }
        }
 public static void ScheduleWorkflow(this IBackgroundJobClient backgroundJobClient, RunHangfireWorkflowJobModel data, DateTimeOffset dateTimeOffset)
 {
     backgroundJobClient.UnscheduleJobWhenAlreadyExists(data);
     backgroundJobClient.Schedule <RunHangfireWorkflowJob>(job => job.ExecuteAsync(data), dateTimeOffset);
 }
Exemplo n.º 4
0
        public void UnscheduleJob(RunHangfireWorkflowJobModel data)
        {
            var identity = data.GetIdentity();

            UnscheduleJob(identity);
        }
Exemplo n.º 5
0
        public void ScheduleJob(RunHangfireWorkflowJobModel data, string cronExpression)
        {
            var identity = data.GetIdentity();

            _recurringJobManager.AddOrUpdate <RunHangfireWorkflowJob>(identity, job => job.ExecuteAsync(data), cronExpression);
        }
Exemplo n.º 6
0
 public void ScheduleJob(RunHangfireWorkflowJobModel data, Instant instant)
 {
     UnscheduleJob(data);
     _backgroundJobClient.Schedule <RunHangfireWorkflowJob>(job => job.ExecuteAsync(data), instant.ToDateTimeOffset());
 }