Code Monkey home page Code Monkey logo

easycronjob's People

Contributors

furkandeveloper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

easycronjob's Issues

โœจ [FEATURE] Add the ability to specify seconds in cron expressions

Summary

Hi! Can you please add the ability to specify seconds in cron expression? Need to run a task every 10 seconds.

Additional context
I saw that for parsing expressions you used Cronos, and in its Parse method there is an overload for include seconds
CronExpression expression = CronExpression.Parse("*/10 * * * * *", CronFormat.IncludeSeconds);

๐ŸŽ‰[INFRASTRUCTURE] Cron Configuration

Summary

Must be configurable cron jobs. So ICronConfiguration uses object with get cron configuration.

In that must be define;

    /// <summary>
    /// This interface includes base parameter for Cron Job.
    /// </summary>
    /// <typeparam name="T">
    /// Cron Job
    /// </typeparam>
    public interface ICronConfiguration<T>
    {
        /// <summary>
        /// Cron Expression. For Example; '****' Cron.Minutely
        /// </summary>
        public string CronExpression { get; set; }

        /// <summary>
        /// TimeZone Information
        /// </summary>
        public TimeZoneInfo TimeZoneInfo { get; set; }
    }

๐Ÿ› [BUG] DoWork gets never called

Describe the bug
I have a very simple Job like this:

public class Test : CronJobService
    {
        public TimTest(ICronConfiguration<TrainingsReminderJob> cronConfiguration)
            : base(cronConfiguration.CronExpression, cronConfiguration.TimeZoneInfo, cronConfiguration.CronFormat)
        {
        }

        public override Task StartAsync(CancellationToken cancellationToken)
        {
            Log();
            return base.StartAsync(cancellationToken);
        }

        public override Task ScheduleJob(CancellationToken cancellationToken)
        {
            Log();
            return base.StartAsync(cancellationToken);
        }

        public async override Task DoWork(CancellationToken cancellationToken)
        {
            await DoMyWorkAsync();
            return base.DoWork(cancellationToken);
        }

I set it up like this:

services.ApplyResulation<Test>(options =>
            {
                options.CronExpression = "* * * * *";
                options.TimeZoneInfo = TimeZoneInfo.Local;
                options.CronFormat = Cronos.CronFormat.Standard;
            });

So it should run every minute. I can see in my logs, that Startasync and ScheduleJob are being called, but DoWork is called never. What am I doing wrong?

How to use any thread

public class CronJobUpdateVisitorVisitDay:CronJobService
{
private readonly ApplicationDbContext _ApplicationDbContext;
private readonly UserManager _UserManager;

    public CronJobUpdateVisitorVisitDay(ICronConfiguration<CronJobUpdateVisitorVisitDay> cronConfiguration, ApplicationDbContext applicationDbContext,UserManager<ApplicationUser> userManager) 
        : base(cronConfiguration.CronExpression,cronConfiguration.TimeZoneInfo,cronConfiguration.CronFormat)
    {
        _ApplicationDbContext = applicationDbContext;
        _UserManager = userManager;
    }
    protected override async Task ScheduleJob(CancellationToken cancellationToken)
    {
        await CustomExtension.StoreVisitorVisitDay(_ApplicationDbContext, _UserManager);
        await base.ScheduleJob(cancellationToken);

    }

    
    public override async Task StartAsync(CancellationToken cancellationToken)
    {
        await CustomExtension.StoreVisitorVisitDay(_ApplicationDbContext, _UserManager);
        await base.StartAsync(cancellationToken);

    }

 
}

In this code, StartAsync and ScheduleJob are run consecutively, while according to the settings, they must be run every 25 minutes every hour.

services.ApplyResulation<CronJobUpdateVisitorVisitDay>(options =>
        {
            options.CronExpression = "25 * * * *";
            options.TimeZoneInfo = TimeZoneInfo.Local;
            options.CronFormat = Cronos.CronFormat.Standard;
        });

๐Ÿ› [BUG] Unhandled exception. System.ArgumentException: Invalid value '2671030968.9793' for parameter 'interval'.

Describe the bug
Not sure what's causing this, but it sometimes happens and sometimes doesn't happen.

To Reproduce
Steps to reproduce the behavior:
Here is the code I used.
image
The line in question I believe is the InactiveRemoverService.

Code of AddCronJob
image

Expected behavior
Job scheduled to run every two hours.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04 I believe
  • Browser None
  • Version latest

More targeted dotnet versionโœจ [FEATURE]

Summary

This library could easily target more that .net5. I successfully tested this in in core3.1 without any problem. Having taken a look in this library I see no reason for this not to work in any version of donet. This could be done by a simple edit in the csproj files. I have personally tested 3.1 so anything newer should be ok.

Advantage

Makes this project usable independently of c# version. The Timers api works since core2.0 and .net standard 2.0.

๐ŸŽ‰[INFRASTRUCTURE] Service Collection

Summary

Must be IServiceCollection extension for initialize job.

Usage

services.ApplyResulation<DbWriterCronJob>(options =>
{
       options.CronExpression = "* * * * *"
       options.TimeZoneInfo = TimeZoneInfo.Local;
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.