Esempio n. 1
0
    public int UnRegisterRssFeedByChatId(long chatId)
    {
        var op = Operation.Begin("UnRegistering RSS by ChatId: {ChatId}", chatId);

        var reduceChatId = chatId.ReduceChatId();
        var prefixJobId  = $"RSS_{reduceChatId}";

        var connection = JobStorage.Current.GetConnection();

        var recurringJobs = connection.GetRecurringJobs();
        var filteredJobs  = recurringJobs.Where
                            (
            job =>
            job.Id.Contains(prefixJobId)
                            );

        filteredJobs.ForEach
        (
            job => {
            Log.Debug(
                "Remove RSS Cron With ID {JobId}. Args: {Args}",
                job.Id,
                job.Job.Args
                );
            _recurringJobManager.RemoveIfExists(job.Id);
        }
        );

        op.Complete();

        return(filteredJobs.Count());
    }
        public static IApplicationBuilder UseAndConfigureHangfire(this IApplicationBuilder app, IRecurringJobManager recurringJobs, IConfiguration config)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (recurringJobs == null)
            {
                throw new ArgumentNullException(nameof(recurringJobs));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var backgroundJobSettings = config.GetSection(ConfigurationKeys.BackgroundJobs).Get <BackgroundJobSettings>();

            app.UseHangfireServer(additionalProcesses: new[] { new ProcessMonitor(TimeSpan.FromSeconds(1.5)) });
            app.UseHangfireDashboard(
                "/hangfire",
                new DashboardOptions
            {
                DashboardTitle = $"{FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductName} - {config.GetEnvironment()} ({Assembly.GetExecutingAssembly().GetName().Version})",
                Authorization  = new[] { new DashboardAuthorizationFilter(config) }
            }
                );

            if (backgroundJobSettings.PullAuctionDataBackgroundJob.Enabled)
            {
                recurringJobs.AddOrUpdate <PullAuctionDataBackgroundJob>(nameof(PullAuctionDataBackgroundJob), job => job.PullAuctionData(null !), backgroundJobSettings.PullAuctionDataBackgroundJob.Schedule);
            }
            else
            {
                recurringJobs.RemoveIfExists(nameof(PullAuctionDataBackgroundJob));
            }

            if (backgroundJobSettings.RemoveOldDataBackgroundJob.Enabled)
            {
                recurringJobs.AddOrUpdate <RemoveOldDataBackgroundJob>(nameof(RemoveOldDataBackgroundJob), job => job.RemoveOldData(null !), backgroundJobSettings.RemoveOldDataBackgroundJob.Schedule);
            }
            else
            {
                recurringJobs.RemoveIfExists(nameof(RemoveOldDataBackgroundJob));
            }

            if (backgroundJobSettings.PullRealmDataBackgroundJob.Enabled)
            {
                recurringJobs.AddOrUpdate <PullRealmDataBackgroundJob>(nameof(PullRealmDataBackgroundJob), job => job.PullRealmData(null !), backgroundJobSettings.PullRealmDataBackgroundJob.Schedule);
            }
            else
            {
                recurringJobs.RemoveIfExists(nameof(PullRealmDataBackgroundJob));
            }

            return(app);
        }
Esempio n. 3
0
        public void UnscheduleJob(string identity)
        {
            var job = QueryJobs().FirstOrDefault(x => GetJobModel(x.Job).GetIdentity() == identity);

            if (job == null)
            {
                return;
            }

            _backgroundJobClient.Delete(job.Id);
            _recurringJobManager.RemoveIfExists(job.Id);
        }
Esempio n. 4
0
        public async Task <bool> UpdateAsync(int id, SpiderDto viewModel)
        {
            if (ModelState.IsValid)
            {
                var spider = await _dockerCrawlerService.Get <SpiderDto>(x => x.Id == id);

                if (spider == null)
                {
                    throw new ApplicationException($"Spider {id} exists");
                }

                var exists = await _dockerCrawlerService.CountAsync <SpiderDto>(x =>
                                                                                x.Name == viewModel.Name && x.Id != id);

                if (exists > 0)
                {
                    ModelState.AddModelError("Name", "名称已经存在");
                }

                try
                {
                    CrontabSchedule.Parse(viewModel.Cron);
                }
                catch
                {
                    ModelState.AddModelError("Cron", "Cron 表达式不正确");
                }


                spider.Name        = viewModel.Name;
                spider.Cron        = viewModel.Cron;
                spider.Image       = viewModel.Image;
                spider.Volume      = viewModel.Volume;
                spider.Environment = viewModel.Environment;

                spider.LastModificationTime = DateTimeOffset.Now;

                await _dockerCrawlerService.AddOrUpdate <SpiderDto, int>(spider);

                _recurringJobManager.RemoveIfExists(spider.Name);
                await ScheduleJobAsync(spider);



                return(true);
            }
            else
            {
                throw new ApplicationException("ModelState is invalid");
            }
        }
Esempio n. 5
0
        public async Task <bool> Delete(int id)
        {
            var record = await _dbService.GetBaseData(id);

            if (record != null)
            {
                if (record.IsFireAndForgetOrScheduled())
                {
                    _bgClient.Delete(record.HfJobId);
                }
                else if (record.IsRecurringJob())
                {
                    var job = JobStorage.Current
                              .GetConnection()
                              .GetRecurringJobs()
                              .FirstOrDefault(x => x.Id == record.HfJobId);
                    if (job != null)
                    {
                        _bgClient.Delete(job.LastJobId);
                    }
                    _recClient.RemoveIfExists(record.HfJobId);
                }
                else
                {
                    throw new Exception("Cannot delete, invalid job type detected.");
                }

                return(await _dbService.Delete(record.Id));
            }

            return(false);
        }
        public void AddHelloSecondsJobs()
        {
            string jobId = "seconds";

            _recurringJobs.RemoveIfExists(jobId);
            _recurringJobs.AddOrUpdate <MessageService>(jobId, a => a.Send(), "*/1 * * * * *");
        }
        public async Task Consume(ConsumeContext <CancelScheduledRecurringMessage> context)
        {
            var jobKey = GetJobKey(context.Message.ScheduleId, context.Message.ScheduleGroup);

            _recurringJobManager.RemoveIfExists(jobKey);

            LogContext.Debug?.Log("Cancelled Recurring Message: {Key}", jobKey);
        }
Esempio n. 8
0
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            //Removing old job
            _recurringJobManager.RemoveIfExists("TalkAt15MinutesNotifier");

            _recurringJobManager.AddOrUpdate(
                "EventAt15MinutesNotifier",
                Job.FromExpression <EventAt15MinutesNotifier>(notifier => notifier.NotifyAsync()),
                Cron.Minutely());

            return(Task.CompletedTask);
        }
Esempio n. 9
0
        public async Task <IActionResult> RemoveScan(int id)
        {
            List <SourceSite> sites = await _context.Set <SourceSite>().AsNoTracking().TagWith("Creator Scan API")
                                      .Where(x => x.Creator.ID == id)
                                      .ToListAsync();

            foreach (SourceSite site in sites)
            {
                _recurringJobManager.RemoveIfExists(site.ID.ToString());
            }

            return(Ok());
        }
        private static void CreateManagmentJob()
        {
            //注册js文件路由
            string pathTemplate = DashboardRoutes.Routes.Contains("/js[0-9]+") ? "/js[0-9]+" : "/js[0-9]{3}";

            DashboardRoutes.Routes.Append(pathTemplate, new CombinedResourceDispatcher(
                                              "application/javascript",
                                              GetExecutingAssembly(),
                                              GetContentFolderNamespace("js"),
                                              Javascripts));

            //注册css文件路由
            var cssPath = DashboardRoutes.Routes.Contains("/css[0-9]+") ? "/css[0-9]+" : "/css[0-9]{3}";

            DashboardRoutes.Routes.Append(cssPath, new CombinedResourceDispatcher(
                                              "text/css",
                                              GetExecutingAssembly(),
                                              GetContentFolderNamespace("css"),
                                              Stylesheets));

            //注册页面路由
            DashboardRoutes.Routes.AddRazorPage(PeriodicJobPage.PageRoute, x => new PeriodicJobPage());
            DashboardRoutes.Routes.AddRazorPage($"{PeriodicJobPage.PageRoute}/edit", x => new PeriodicJobEditPage());

            //新增顶部菜单
            NavigationMenu.Items.Add(page =>
                                     new MenuItem(RayStrings.NavigationMenu_PeriodicJobs, page.Url.To(PeriodicJobPage.PageRoute))
            {
                Active = page.RequestPath.StartsWith(PeriodicJobPage.PageRoute),
                Metric = DashboardMetrics.RecurringJobCount
            });

            //注册api
            DashboardRoutes.Routes.Add($"{PeriodicJobPage.PageRoute}/stop", new PetiodicStopDispatcher());
            DashboardRoutes.Routes.Add($"{PeriodicJobPage.PageRoute}/start", new PetiodicStartDispatcher());
            DashboardRoutes.Routes.Add($"{PeriodicJobPage.PageRoute}/addOrUpdate", new PetiodicAddOrUpdateDispatcher());
            DashboardRoutes.Routes.AddBatchCommand($"{PeriodicJobPage.PageRoute}/remove",
                                                   (context, jobId) =>
            {
                IRecurringJobManager manager = context.GetRecurringJobManager();
                PeriodicJobRepository periodicJobRepository = new PeriodicJobRepository();
                var job = periodicJobRepository.GetPeriodicJobById(jobId);

                if (job.JobStateEnum == Models.JobState.Stoped)
                {
                    periodicJobRepository.StartPeriodicJob(jobId);
                }
                manager.RemoveIfExists(jobId);
            });
        }
Esempio n. 11
0
        public async Task <IActionResult> DeleteProductScheduler(int productId)
        {
            _logger.LogInformation($"Поступил запрос на удаление задач для продукта productId={productId}");

            var regex = new Regex($@"^{productId}-");

            var productRecurrentJobs = JobStorage.Current.GetConnection().GetRecurringJobs().Where(j => regex.IsMatch(j.Id));

            if (!productRecurrentJobs.Any())
            {
                _logger.LogError($"Не найдено задач удовлетворяющих {regex}");
                return(NotFound());
            }

            foreach (var productRecurrentJob in productRecurrentJobs)
            {
                _recurringJobManager.RemoveIfExists(productRecurrentJob.Id);

                _logger.LogInformation($"Задача c id={productRecurrentJob.Id} успешно удалена");
            }

            return(Ok());
        }
        public static void AddLeagueJobs(this IRecurringJobManager jobManager, DatabaseContext context)
        {
            var leagues = context.Leagues
                          .IgnoreQueryFilters()
                          .ToList();

            foreach (var league in leagues.Where(o => !o.IsDeactivated))
            {
                jobManager.AddOrUpdate <ILeagueJob>(league.Id.ToString(), o => o.RunMatchAsync(league.Id), league.Options.IntervalCron);
            }

            foreach (var league in leagues.Where(o => o.IsDeactivated))
            {
                jobManager.RemoveIfExists(league.Id.ToString());
            }
        }
Esempio n. 13
0
        public void AddCronJob(ICronJob cronJob)
        {
            if (cronJob == null)
            {
                throw new ArgumentNullException("cronJob");
            }

            if (cronJob.Enabled)
            {
                _recurringJobManager.AddOrUpdate(cronJob.Name,
                                                 () => cronJob.Execute(JobCancellationToken.Null),
                                                 cronJob.Schedule);
            }
            else
            {
                _recurringJobManager.RemoveIfExists(cronJob.Name);
            }
        }
Esempio n. 14
0
        /// <inheritdoc/>
        public void ScheduleCleanup()
        {
            string recurringJobId = "cleanup";

            if (configuration.Options.CleanupPeriod > 0)
            {
                manager.AddOrUpdate <CleanupServiceProxy>(
                    recurringJobId,
                    x => x.CleanupAsync(JobCancellationToken.Null),
                    "0 * * ? * *", // Every minute
                    TimeZoneInfo.Utc,
                    QueueNames.Default);
            }
            else
            {
                manager.RemoveIfExists(recurringJobId);
            }
        }
Esempio n. 15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IRecurringJobManager recurringJobs)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseHangfireServer();

            //remove the dashboard before production
            app.UseHangfireDashboard();
            app.UseStaticFiles();
            app.UseSession();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });


            //To clear scheduler on startup.
            using (var connection = JobStorage.Current.GetConnection())
            {
                foreach (var recurringjob in connection.GetRecurringJobs())
                {
                    recurringJobs.RemoveIfExists(recurringjob.Id);
                }
            }


            //actual uncomment it later
            //recurringJobs.AddOrUpdate("EmailStartup", Job.FromExpression<CentricsContext>(x => x.Emailcaller()), Cron.Daily());

            //testing purpose print 878smh every 2 mins
            recurringJobs.AddOrUpdate("EmailStartup", Job.FromExpression <CentricsContext>(x => x.callmemaybe()), Cron.MinuteInterval(2));
        }
        private static async Task RunOrRemoveJobAsync(this IRecurringJobManager recurringJobManager, ISettingsManager settingsManager, SettingCronJob settingCronJob)
        {
            var processJobEnable = await settingsManager.GetValueAsync(settingCronJob.EnableSetting.Name, (bool)settingCronJob.EnableSetting.DefaultValue);

            if (processJobEnable)
            {
                var cronExpression = await settingsManager.GetValueAsync(settingCronJob.CronSetting.Name, settingCronJob.CronSetting.DefaultValue.ToString());

                recurringJobManager.AddOrUpdate(
                    settingCronJob.RecurringJobId,
                    settingCronJob.Job,
                    cronExpression,
                    settingCronJob.TimeZone,
                    settingCronJob.Queue);
            }
            else
            {
                recurringJobManager.RemoveIfExists(settingCronJob.RecurringJobId);
            }
        }
        private void RegisterRecurringJobs(CancellationToken stoppingToken)
        {
            foreach (IRecurringJob recurringJob in _recurringJobs)
            {
                var recurringJobId = recurringJob.GetType().Name;
                var cronExpression = recurringJob.GetCronExpression();

                if (!string.IsNullOrEmpty(cronExpression))
                {
                    _recurringJobsManager.AddOrUpdate(
                        recurringJobId,
                        () => recurringJob.RunAsync(stoppingToken),
                        cronExpression);
                }
                else
                {
                    _recurringJobsManager.RemoveIfExists(recurringJobId);
                }
            }
        }
Esempio n. 18
0
        public void Register(CronJobBroadcast payload)
        {
            string MakeKey(CronJobDescription j, int i) => $"{payload.Application}@{payload.Environment}.{j.Name}#{i}";

            var app = $"{payload.Application}@{payload.Environment}";

            _logger.LogDebug("Looking for registered jobs for {Application}", app);
            var existingJobs = _jobStorage.GetConnection().GetRecurringJobs()
                               .Where(j => j.Id.StartsWith(app))
                               .ToList();

            _logger.LogDebug($"Found {existingJobs.Count} jobs. Replacing with new ones.");

            foreach (var job in existingJobs)
            {
                _jobManager.RemoveIfExists(job.Id);
            }

            var jobs = payload.Jobs.ToList();

            foreach (var job in jobs)
            {
                _logger.LogDebug("Registering {Job} for {Application}", job, payload.Application);
                for (var i = 0; i < job.CronExpressions.Count; i++)
                {
                    var cron   = job.CronExpressions[i];
                    var jobKey = MakeKey(job, i);
                    _jobManager.AddOrUpdate <CronJobTriggerer>(
                        jobKey,
                        t => t.Trigger(job),
                        cron,
                        TimeZoneInfo.Local
                        );
                }
            }

            _logger.LogInformation($"Registered {jobs.Count} jobs for {{Application}}.", app);
        }
Esempio n. 19
0
        public string CreateJob(string scheduleSerializeObject, IEnumerable<ParametersViewModel>? parameters)
        {
            var schedule = JsonSerializer.Deserialize<Schedule>(scheduleSerializeObject);
            //if schedule has expired
            if (DateTime.UtcNow > schedule.ExpiryDate)
            {
                _recurringJobManager.RemoveIfExists(schedule.Id.Value.ToString());//removes an existing recurring job
                return "ScheduleExpired";
            }

            if (_organizationSettingManager.HasDisallowedExecution())
            {
                return "DisallowedExecution";
            }

            //if this is not a "RunNow" job, then use the schedule parameters
            if (schedule.StartingType.Equals("RunNow") == false)
            {
                if (schedule.MaxRunningJobs != null)
                {
                    if (ActiveJobLimitReached(schedule.Id, schedule.MaxRunningJobs))
                    {
                        return "ActiveJobLimitReached";
                    }
                }

                List<ParametersViewModel> parametersList = new List<ParametersViewModel>();

                var scheduleParameters = _scheduleParameterRepository.Find(null, p => p.ScheduleId == schedule.Id).Items;
                foreach (var scheduleParameter in scheduleParameters)
                {
                    ParametersViewModel parametersViewModel = new ParametersViewModel
                    {
                        Name = scheduleParameter.Name,
                        DataType = scheduleParameter.DataType,
                        Value = scheduleParameter.Value,
                        CreatedBy = scheduleParameter.CreatedBy,
                        CreatedOn = DateTime.UtcNow
                    };
                    parametersList.Add(parametersViewModel);
                }
                parameters = parametersList.AsEnumerable();
            }

            var automationVersion = _automationVersionRepository.Find(null, a => a.AutomationId == schedule.AutomationId).Items?.FirstOrDefault();

            Job job = new Job();
            job.AgentId = schedule.AgentId == null ? Guid.Empty : schedule.AgentId.Value;
            job.AgentGroupId = schedule.AgentGroupId == null ? Guid.Empty : schedule.AgentGroupId.Value;
            job.CreatedBy = schedule.CreatedBy;
            job.CreatedOn = DateTime.UtcNow;
            job.EnqueueTime = DateTime.UtcNow;
            job.JobStatus = JobStatusType.New;
            job.AutomationId = schedule.AutomationId == null ? Guid.Empty : schedule.AutomationId.Value;
            job.AutomationVersion = automationVersion != null ? automationVersion.VersionNumber : 0;
            job.AutomationVersionId = automationVersion != null ? automationVersion.Id : Guid.Empty;
            job.Message = "Job is created through internal system logic.";
            job.ScheduleId = schedule.Id;

            foreach (var parameter in parameters ?? Enumerable.Empty<ParametersViewModel>())
            {
                JobParameter jobParameter = new JobParameter
                {
                    Name = parameter.Name,
                    DataType = parameter.DataType,
                    Value = parameter.Value,
                    JobId = job.Id ?? Guid.Empty,
                    CreatedBy = schedule.CreatedBy,
                    CreatedOn = DateTime.UtcNow,
                    Id = Guid.NewGuid()
                };
                _jobParameterRepository.Add(jobParameter);
            }
            _jobRepository.Add(job);

            if (job.AgentGroupId == null || job.AgentGroupId == Guid.Empty)
            {
                _hub.Clients.All.SendAsync("botnewjobnotification", job.AgentId.ToString());
            }
            else //notify all group members
            {
                var agentsInGroup = _agentGroupManager.GetAllMembersInGroup(job.AgentGroupId.ToString());
                foreach (var groupMember in agentsInGroup ?? Enumerable.Empty<AgentGroupMember>())
                {
                    _hub.Clients.All.SendAsync("botnewjobnotification", groupMember.AgentId.ToString());
                }
            }

            _webhookPublisher.PublishAsync("Jobs.NewJobCreated", job.Id.ToString()).ConfigureAwait(false);

            return "Success";
        }
        public async Task <IActionResult> Post([FromBody] ScheduleViewModel request)
        {
            if (request == null)
            {
                ModelState.AddModelError("Save", "No data passed");
                return(BadRequest(ModelState));
            }

            //Validate the cron expression
            if (!string.IsNullOrWhiteSpace(request.CRONExpression))
            {
                try
                {
                    CronExpression expression = CronExpression.Parse(request.CRONExpression, CronFormat.Standard);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Save", string.Concat("Invalid cron expression, ", ex.Message));
                    return(BadRequest(ModelState));
                }
            }

            Guid entityId = Guid.NewGuid();

            try
            {
                Schedule requestObj = new Schedule();
                requestObj.Id             = entityId;
                requestObj.Name           = request.Name;
                requestObj.AgentId        = request.AgentId;
                requestObj.CRONExpression = request.CRONExpression;
                requestObj.LastExecution  = request.LastExecution;
                requestObj.NextExecution  = request.NextExecution;
                requestObj.IsDisabled     = request.IsDisabled;
                requestObj.ProjectId      = request.ProjectId;
                requestObj.StartingType   = request.StartingType;
                requestObj.Status         = request.Status;
                requestObj.ExpiryDate     = request.ExpiryDate;
                requestObj.StartDate      = request.StartDate;
                requestObj.ProcessId      = request.ProcessId;

                var response = await base.PostEntity(requestObj);

                try
                {
                    recurringJobManager.RemoveIfExists(requestObj.Id?.ToString());

                    if (request.IsDisabled == false && !request.StartingType.ToLower().Equals("manual"))
                    {
                        var jsonScheduleObj = JsonSerializer.Serialize <Schedule>(requestObj);

                        backgroundJobClient.Schedule(() => hubManager.StartNewRecurringJob(jsonScheduleObj),
                                                     new DateTimeOffset(requestObj.StartDate.Value));
                    }
                }
                catch (Exception ex) { }

                return(response);
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }
Esempio n. 21
0
 public Task EndJobAsync(string jobId)
 {
     _recurringJobClient.RemoveIfExists(jobId);
     return(Task.CompletedTask);
 }
        protected void ClearRecurringJob(int userId, int orgId)
        {
            var jobToken = GetHangfireToken(userId, orgId);

            recurringJobManager.RemoveIfExists(jobToken);
        }
Esempio n. 23
0
        public async Task <IActionResult> Post([FromBody] CreateScheduleViewModel request)
        {
            if (request == null)
            {
                ModelState.AddModelError("Save", "No data passed");
                return(BadRequest(ModelState));
            }

            //validate the cron expression
            if (!string.IsNullOrWhiteSpace(request.CRONExpression))
            {
                try
                {
                    CronExpression expression = CronExpression.Parse(request.CRONExpression, CronFormat.Standard);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Save", string.Concat("Invalid cron expression, ", ex.Message));
                    return(BadRequest(ModelState));
                }
            }

            Guid entityId = Guid.NewGuid();

            if (request.Id == null || !request.Id.HasValue || request.Id.Equals(Guid.Empty))
            {
                request.Id = entityId;
            }

            try
            {
                Schedule requestObj = request.Map(request); //assign request to schedule entity

                foreach (var parameter in request.Parameters ?? Enumerable.Empty <ParametersViewModel>())
                {
                    ScheduleParameter scheduleParameter = new ScheduleParameter
                    {
                        Name       = parameter.Name,
                        DataType   = parameter.DataType,
                        Value      = parameter.Value,
                        ScheduleId = entityId,
                        CreatedBy  = applicationUser?.UserName,
                        CreatedOn  = DateTime.UtcNow,
                        Id         = Guid.NewGuid()
                    };
                    scheduleParameterRepository.Add(scheduleParameter);
                }

                var response = await base.PostEntity(requestObj);

                recurringJobManager.RemoveIfExists(requestObj.Id?.ToString());

                if (request.IsDisabled == false && !request.StartingType.ToLower().Equals("manual"))
                {
                    var jsonScheduleObj = JsonSerializer.Serialize <Schedule>(requestObj);

                    backgroundJobClient.Schedule(() => hubManager.ScheduleNewJob(jsonScheduleObj),
                                                 new DateTimeOffset(requestObj.StartDate.Value));
                }

                return(response);
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }
 public void UnRegisterJobShalatTime(long chatId)
 {
     _recurringJobManager.RemoveIfExists(
         recurringJobId: GetJobId(chatId)
         );
 }
Esempio n. 25
0
 public void RemoveRecurringJob(string jobId)
 {
     recurringJobManager.RemoveIfExists(jobId);
 }
Esempio n. 26
0
        /// <summary>
        /// Cleans up all recurring jobs that have been started by this server
        /// to prevent jobs from being processed multiple times.
        /// </summary>
        private void ClearJobs()
        {
            List <RecurringJobDto> recurringJobs = JobStorage.Current.GetConnection().GetRecurringJobs();

            recurringJobs.ForEach(job => _recurringJobManager.RemoveIfExists(job.Id));
        }
Esempio n. 27
0
        private void DeleteRecurringJob(RunHangfireWorkflowDefinitionJobModel data)
        {
            var identity = data.GetIdentity();

            _recurringJobManager.RemoveIfExists(identity);
        }
 public void Delete(string id)
 {
     _recurringJobManager.RemoveIfExists(id);
 }
 public void RemoveRecurringJob()
 => _recurringJobManager.RemoveIfExists(_recurringJobName);
Esempio n. 30
0
 public async Task RemoveJobs(IEnumerable <JobSchedule> schedules)
 {
     await Task.Run(() => schedules.ForAll(schedule => _recurringJobManager.RemoveIfExists(
                                               recurringJobId: schedule.Cron)));
 }