protected override Result <RecurringJobDto?> Handle(Command request) { var(serverId, cronExpression) = request; var jobId = AutoServerRestartJob.CreateJobId(serverId); RecurringJob.AddOrUpdate <AutoServerRestartJob>(jobId, job => job.Execute(serverId), cronExpression); return(JobStorage.Current .GetConnection() .GetRecurringJobs(new[] { jobId }) .FirstOrDefault()); }
protected override Result Handle(Command request) { var jobId = AutoServerRestartJob.CreateJobId(request.ServerId); try { RecurringJob.RemoveIfExists(jobId); } catch (Exception e) { return(e); } return(Result.FromSuccess()); }