using FlowAlert.Model; using Quartz; using Quartz.Impl; using RDIFramework.Utilities; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.IO; using System.Linq; using System.Text; using Topshelf; namespace TimedUpload { class Program { private static string programName = ConfigurationManager.AppSettings["serverName"]; static void Main(string[] args) { log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config")); try { HostFactory.Run(x => { x.UseLog4Net(); x.Service(); x.SetDescription(programName); x.SetDisplayName(programName); x.SetServiceName(programName); x.EnablePauseAndContinue(); }); } catch (Exception ex) { Console.Write(ex.Message); } } } public class DataUploadService { private readonly IScheduler scheduler; public DataUploadService() { scheduler = StdSchedulerFactory.GetDefaultScheduler(); } public bool Start() { scheduler.Start(); return true; } public bool Stop() { scheduler.Shutdown(false); return true; } public bool Continue() { scheduler.ResumeAll(); return true; } public bool Pause() { scheduler.PauseAll(); return true; } public bool AddJobTrigger(IJobDetail jobDetail, ITrigger trigger) { if (scheduler != null) { scheduler.ScheduleJob(jobDetail, trigger); } return true; } } }