时间表功能服务Web API

问题描述 投票:0回答:0

我了解 laraval PHP,我想用我的 Web API .Net Core 构建类似的东西。

在我的 laraval PHP 项目中,我得到了一个 Kernal,它处理工作和其他一些事情的时间表。

代码

<?php


declare(strict_types=1);

namespace App\Console;

use App\Jobs\UpdateProductPrices;
use App\Jobs\MailSenderOrdersWoa;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

/**
 * Class Kernel
 *
 * @package App\Console
 */
class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
    ];

    /**
     * The location of docker's sysout.
     */
    const DOCKER_SYSOUT = '/proc/1/fd/1';

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('modelCache:clear')->dailyAt('01:00')->appendOutputTo(self::DOCKER_SYSOUT);
        $schedule->command('offer:expiration')->dailyAt('02:00')->appendOutputTo(self::DOCKER_SYSOUT);
        $schedule->command('holidays:sync')->weeklyOn(Schedule::SATURDAY)->at('01:00')->appendOutputTo(self::DOCKER_SYSOUT);
        $schedule->job(new UpdateProductPrices)->dailyAt('00:30')->appendOutputTo(self::DOCKER_SYSOUT);
        $schedule->job(new MailSenderOrdersWoa)->dailyAt('00:30')->appendOutputTo(self::DOCKER_SYSOUT);
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');
        require base_path('routes/console.php');

    }
}

我想调用一个每天 00:30 自动调用的函数,就像这行一样

$schedule->job(new MailSenderOrdersWoa)->dailyAt('00:30')->appendOutputTo(self::DOCKER_SYSOUT)
`

我将如何在 .Net Core 中执行此操作?

.net time jobs schedule core
© www.soinside.com 2019 - 2024. All rights reserved.