FreeScheduler

repository·master·Indexed 43 days ago

https://github.com/2881099/freescheduler

A lightweight scheduled task scheduler implemented using IdleBus. It supports clusters, temporary delayed tasks, and persistent recurring tasks including fixed intervals, calendar-based scheduling (daily, weekly, monthly), and custom cron expressions. It can be configured via FreeSchedulerBuilder and supports persistence through Database or Redis.

Tokens
5.5K
Snippets
17
Records
26
Agent score
56%

What's inside FreeScheduler

  1. Overview of Multiple Select plugin

    master

    Multiple Select is a jQuery plugin that enables multi-element selection using checkboxes. It provides a user-friendly interface for selecting multiple items from a list.

    Key Features:

    • Displays checkboxes by default for selection.
    • Supports grouping elements using optgroups.
    • Supports displaying multiple options in a single row.
    • Includes a 'Select All' functionality.
    • Supports custom placeholder/prompt messages.
  2. Use the Multiple Select jQuery plugin

    master

    Multiple Select is a jQuery plugin that allows users to select multiple elements using checkboxes. It is used within the FreeScheduler dashboard for enhanced selection capabilities.

    For detailed documentation, advanced configuration options, and full usage guides, refer to the official project website: http://wenzhixin.net.cn/p/multiple-select

  3. Install and use Multiple Select

    master

    Multiple Select is a jQuery plugin that enhances <select> elements to allow users to select multiple options using checkboxes. It supports grouping elements (optgroups), showing multiple items per row, a 'select all' feature, and placeholders.

    <!-- Ensure jQuery is loaded before initializing the plugin -->
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="multiple-select.js"></script>
    
    <select multiple="multiple">
      <option value="1">Option 1</option>
      <option value="2">Option 2</option>
    </select>
    
    <script>
      $(function() {
        $('select').multipleSelect();
      });
    </script>
  4. Use jQuery treetable to display hierarchical data in tables

    master
    jQuery treetable is a plugin that allows you to display tree structures (like directory structures or nested lists) within an HTML table. This is particularly useful when you need to display multiple columns of data alongside the hierarchical tree structure, which standard HTML lists cannot easily accommodate.
  5. How temporary tasks work

    master

    Temporary tasks are non-persistent delay tasks. They are useful for one-off delays and are not stored in a database or Redis. If the process restarts, these tasks are lost.

    Use AddTempTask to schedule a callback after a specific TimeSpan.

    void Callback()
    {
        Console.WriteLine("时间到了");
        scheduler.AddTempTask(TimeSpan.FromSeconds(10), Callback); // Next scheduled delay
    }
    // Schedule the first one
    scheduler.AddTempTask(TimeSpan.FromSeconds(10), Callback);
  6. Use Multiple Select with Optgroups

    master

    Multiple Select natively supports HTML <optgroup> elements. You can group options under labels, and these groups can also be disabled using the disabled="disabled" attribute on the <optgroup> tag.

    <select multiple="multiple">
        <optgroup label="Group 1">
            <option value="1">Option 1</option>
            <option value="2">Option 2</option>
        </optgroup>
        <optgroup label="Group 2" disabled="disabled">
            <option value="3">Option 3</option>
        </optgroup>
    </select>
  7. Access jQuery treetable documentation and examples

    master

    For technical documentation, implementation details, and usage examples, refer to the index.html file within the plugin directory. You can also find online documentation and an AJAX-enabled example (built with Ruby on Rails) via the links below:

  8. Initialize the Scheduler with FreeSchedulerBuilder

    master

    Use FreeSchedulerBuilder to configure and create your Scheduler instance. You must define an execution handler using OnExecuting to process tasks when they are triggered.

    Key builder methods:

    • OnExecuting(Action<TaskInfo> executing): Defines the logic to run when a task is triggered.
    • UseTimeZone(): Sets the time zone.
    • UseStorage(): Enables persistence via Database or Redis.
    • UseCluster(): Enables cluster mode (requires Redis) for cross-process communication.
    • UseCustomInterval(...): Enables custom interval logic (e.g., for cron expressions).
    • UseScanInterval(int ms): Sets the scanning interval (default 200ms). Smaller values increase precision.
    • Build(): Finalizes the configuration and returns the Scheduler object.
    static Scheduler scheduler = new FreeSchedulerBuilder()
        .OnExecuting(task =>
        {
            Console.WriteLine($"[{DateTime.Now.ToString("HH:mm:ss.fff")}] {task.Topic} 被执行");
            switch (task.Topic)
            {
                case "武林大会": Wulin(task.Body); break;
                case "攻城活动": AttackCity(task.Body); break;
            }
        })
        .Build();
  9. Initialize Multiple Select on a standard select box

    master

    To use Multiple Select, include the multiple-select.css and multiple-select.js files. You can then initialize it on any standard HTML <select> element that has the multiple="multiple" attribute using the jQuery method $(selector).multipleSelect().

    It supports standard HTML features like disabled attributes on the select box or individual options, and selected attributes for pre-selecting items.

    <head>
    	<link href="multiple-select.css" rel="stylesheet"/>
    </head>
    <body>
    	<select multiple="multiple">
    	    <option value="1">January</option>
    	    <option value="2">February</option>
    	</select>
    	<script src="multiple-select.js"></script>
    	<script>
    		$('select').multipleSelect();
    	</script>
    </body>