public virtual string Enqueue <TJob, TArgs>(TArgs args, BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan?delay = null) where TJob : IBackgroundJobBase <TArgs> { string jobUniqueIdentifier = string.Empty; if (!delay.HasValue) { if (typeof(IBackgroundJob <TArgs>).IsAssignableFrom(typeof(TJob))) { jobUniqueIdentifier = HangfireBackgroundJob.Enqueue <TJob>(job => ((IBackgroundJob <TArgs>)job).Execute(args)); } else { jobUniqueIdentifier = HangfireBackgroundJob.Enqueue <TJob>(job => ((IAsyncBackgroundJob <TArgs>)job).ExecuteAsync(args)); } } else { if (typeof(IBackgroundJob <TArgs>).IsAssignableFrom(typeof(TJob))) { jobUniqueIdentifier = HangfireBackgroundJob.Schedule <TJob>(job => ((IBackgroundJob <TArgs>)job).Execute(args), delay.Value); } else { jobUniqueIdentifier = HangfireBackgroundJob.Schedule <TJob>(job => ((IAsyncBackgroundJob <TArgs>)job).ExecuteAsync(args), delay.Value); } } return(jobUniqueIdentifier); }
public void RefreshInventory() { var monitor = _monitoringService.ProvisionMonitor(BackgroundJobType.RefreshInventory); var hangfireJobId = BackgroundJob.Enqueue <JobRunner>( x => x.RefreshInventory(_tenantContext.InstanceId, monitor.Id)); _monitoringService.AssignHangfireJob(monitor.Id, hangfireJobId); }
public void RunDiagnostics() { var monitor = _monitoringService.ProvisionMonitor(BackgroundJobType.Diagnostics); var hangfireJobId = BackgroundJob.Enqueue <JobRunner>( x => x.Diagnostics(_tenantContext.InstanceId, monitor.Id)); _monitoringService.AssignHangfireJob(monitor.Id, hangfireJobId); }
public void SyncWarehouseAndLocation() { var monitor = _monitoringService.ProvisionMonitor(BackgroundJobType.SyncWarehouseAndLocation); var hangfireJobId = BackgroundJob.Enqueue <JobRunner>( x => x.SyncWarehouseAndLocation(_tenantContext.InstanceId, monitor.Id)); _monitoringService.AssignHangfireJob(monitor.Id, hangfireJobId); }
public void ConnectToAcumatica() { var monitor = _monitoringService.ProvisionMonitor(BackgroundJobType.ConnectToAcumatica); var hangfireJobId = BackgroundJob.Enqueue <JobRunner>( x => x.ConnectToAcumatica(_tenantContext.InstanceId, monitor.Id)); _monitoringService.AssignHangfireJob(monitor.Id, hangfireJobId); }
public void EndToEndSyncSingleShopifyOrder(long shopifyOrderId) { var monitor = _monitoringService.ProvisionMonitor(BackgroundJobType.EndToEndSync); var hangfireJobId = BackgroundJob.Enqueue <JobRunner>( x => x.EndToEndSyncSingleOrder(_tenantContext.InstanceId, monitor.Id, shopifyOrderId)); _monitoringService.AssignHangfireJob(monitor.Id, hangfireJobId); }
public void ImportAddShopifyVariantsToProduct(ShopifyAddVariantImportContext context) { var monitor = _monitoringService.ProvisionMonitor(BackgroundJobType.ImportAddShopifyVariantsToProduct); var hangfireJobId = BackgroundJob.Enqueue <JobRunner>( x => x.ImportAddShopifyVariantsToProduct(_tenantContext.InstanceId, context, monitor.Id)); _monitoringService.AssignHangfireJob(monitor.Id, hangfireJobId); }
public bool Delete(string jobId) { if (string.IsNullOrWhiteSpace(jobId)) { throw new ArgumentNullException(nameof(jobId)); } bool successfulDeletion = HangfireBackgroundJob.Delete(jobId); return(successfulDeletion); }
public Task <bool> DeleteAsync(string jobId) { if (string.IsNullOrWhiteSpace(jobId)) { throw new ArgumentNullException(nameof(jobId)); } bool successfulDeletion = HangfireBackgroundJob.Delete(jobId); return(Task.FromResult(successfulDeletion)); }
public Task EnqueueAsync <TJob, TArgs>(TArgs args, BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan?delay = null) where TJob : IBackgroundJob <TArgs> { if (!delay.HasValue) { HangfireBackgroundJob.Enqueue <TJob>(job => job.Execute(args)); } else { HangfireBackgroundJob.Schedule <TJob>(job => job.Execute(args), delay.Value); } return(Task.FromResult(0)); }
public string Enqueue <TJob, TArgs>(TArgs args, BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan?delay = null) where TJob : IBackgroundJob <TArgs> { string jobUniqueIdentifier = string.Empty; if (!delay.HasValue) { jobUniqueIdentifier = HangfireBackgroundJob.Enqueue <TJob>(job => job.Execute(args)); } else { jobUniqueIdentifier = HangfireBackgroundJob.Schedule <TJob>(job => job.Execute(args), delay.Value); } return(jobUniqueIdentifier); }
public void SyncAcumaticaStockItems(List <long> spids, bool automaticEnable) { var context = new AcumaticaStockItemImportContext { ShopifyProductIds = spids, IsSyncEnabled = automaticEnable, CreateInventoryReceipts = false, SynchronizeOnly = true, WarehouseId = null, }; var monitor = _monitoringService.ProvisionMonitor(BackgroundJobType.ImportAcumaticaStockItems); var hangfireJobId = BackgroundJob.Enqueue <JobRunner>( x => x.ImportAcumaticaStockItems(_tenantContext.InstanceId, context, monitor.Id)); _monitoringService.AssignHangfireJob(monitor.Id, hangfireJobId); }
public string Enqueue(Expression <Func <Task> > methodCall) { logger.LogDebug("Start background job"); return(HangfireBackgroundJob.Enqueue(methodCall)); }