You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using AutoMapper;
|
|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Quartz.Impl;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Topshelf;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Service.Output
|
|
|
|
|
{
|
|
|
|
|
public class OutputJobService : ServiceControl
|
|
|
|
|
{
|
|
|
|
|
private static ILog logger = LogManager.GetLogger("MailJobService");
|
|
|
|
|
|
|
|
|
|
public bool Start(HostControl hostControl)
|
|
|
|
|
{
|
|
|
|
|
// 开始具体的业务逻辑
|
|
|
|
|
logger.Debug("开始运行");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var scheduler = StdSchedulerFactory.GetDefaultScheduler();
|
|
|
|
|
scheduler.ListenerManager.AddSchedulerListener(new JobListener());
|
|
|
|
|
scheduler.Start();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logger.Error("启动出错:");
|
|
|
|
|
logger.Error(ex.Message);
|
|
|
|
|
logger.Error(ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Stop(HostControl hostControl)
|
|
|
|
|
{
|
|
|
|
|
// 结束
|
|
|
|
|
logger.Debug("停止运行");
|
|
|
|
|
|
|
|
|
|
StdSchedulerFactory.GetDefaultScheduler().Shutdown();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|