using GB5Shared.DTO.Framework.Login;
using System.Threading;
using System.Threading.Tasks;
namespace FrameworkBLL.SchedulerTaskGenerator
{
///
/// Bridges MJOBDEFINE/TSCHEDULER to Quartz's own native, persistent, per-job triggers.
/// Quartz owns "when to fire" for a job from here on — no custom due-time computation.
///
public interface IQuartzSyncService
{
///
/// (Re)builds the Quartz trigger for a job from its current MJOBDEFINE/TSCHEDULER
/// row. If the job/scheduler is inactive, removes any existing trigger instead.
/// If a trigger already exists for this job, it is deleted first (clean slate).
/// Safe to call repeatedly — e.g. after every save.
///
Task SyncJobAsync(int jobId, LoginDTO login, CancellationToken ct = default);
///
/// Removes the Quartz trigger/job for the given JobId, if one exists. No-op otherwise.
///
Task RemoveJobAsync(int jobId, LoginDTO login, CancellationToken ct = default);
///
/// Returns whether a Quartz JobKey is currently registered for this job — used to
/// reject manual "trigger now" requests for jobs that were never synced (avoids
/// falling back to an anonymous, un-scoped one-shot trigger).
///
Task IsJobRegisteredAsync(int jobId, int tenantId, CancellationToken ct = default);
///
/// One-time startup migration: enumerates all active tenants, loads every
/// STATUS=1 (active) MJOBDEFINE row per tenant, and syncs each into Quartz.
/// Errors on an individual job/tenant are logged and skipped — one bad row
/// must not block the rest.
///
Task BootstrapAllAsync(CancellationToken ct = default);
}
}