1. Create the Task Method
namespace Nop.Plugin.Misc.Name.Services
{
/// <summary>
/// Represents task for myprogram
/// </summary>
public partial class ProgramTask : IScheduleTask
{
#region Fields
private readonly ICustomerService _customerService;
private readonly IStoreContext _storeContext;
#endregion
#region Ctor
public ProgramTask(ICustomerService customerService,
IStoreContext storeContext)
{
_customerService = customerService;
_storeContext = storeContext;
}
#endregion
#region Methods
/// <summary>
/// Executes a task
/// </summary>
public async System.Threading.Tasks.Task ExecuteAsync()
{
var store = await _storeContext.GetCurrentStoreAsync();
// Do the task
}
#endregion
}
2. Create the Task
private const string PROGRAM_TASK_TYPE = "Nop.Plugin.Misc.Name.Services.ProgramTask, Nop.Plugin.Misc.Name";
//task for process
if (await _scheduleTaskService.GetTaskByTypeAsync(PROGRAM_TASK_TYPE) == null)
{
await _scheduleTaskService.InsertTaskAsync(new ScheduleTask
{
Enabled = true,
Name = "My rewards points program task",
Seconds = 3600,
Type = PROGRAM_TASK_TYPE
});
}
Checking code, I can't find the InsertTaskAsync anywhere else in the code base, except for the SendInBlue plugin.
i've tried to follow/figure out the DeleteGuestTask without success.