
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace CallCenter.QuartzService
{
    public partial class SMSService : ServiceBase
    {
        public SMSService()
        {
            InitializeComponent();
        }

        Log log = LogFactory.GetLogger("服务");

        protected override void OnStart(string[] args)
        {
            QuartzWorker qw = new QuartzWorker();
            Quartz.IScheduler _scheduler = qw.GetScheduler();
            List<string> crns = new List<string>();
            crns.Add(ConfigurationManager.AppSettings["t_crns"]);

            SMSTask qj = new SMSTask();
            qj.jobID = 0;
            qj.CronExpressionList = crns;

            bool bl = qw.AddWork(qj, _scheduler);
            if (bl)
            {
                log.Warn("服务开启成功");
            }
            else
            {
                log.Warn("服务开启失败");
            }
        }

        public void Shutdown()
        {
        }

        protected override void OnStop()
        {
            log.Warn("服务停止");
        }
        
        protected override void OnShutdown()
        {
            log.Warn("服务关闭");
        }

    }
}
