88 lines
3.0 KiB
C#
88 lines
3.0 KiB
C#
using Core.AuditService.pack;
|
|
using Quartz;
|
|
using Quartz.Xml;
|
|
using System;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using System.ServiceProcess;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using WX.CRM.Common;
|
|
|
|
namespace Core.AuditService
|
|
{
|
|
public partial class CoreAuditService : ServiceBase
|
|
{
|
|
public CoreAuditService()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private Thread _sms_send;
|
|
|
|
protected override void OnStart(string[] args)
|
|
{
|
|
try
|
|
{
|
|
_sms_send = new Thread(new ThreadStart(GetScheduleJob));
|
|
_sms_send.Start();
|
|
LogHelper.Info("-----服务启动成功-----");
|
|
|
|
Task.Run(() =>
|
|
{
|
|
Module_Order_Init module_Order_Init = new Module_Order_Init();
|
|
module_Order_Init.SatartInit();
|
|
new ExecIncomeActCur().Start();
|
|
});
|
|
//EventBus.Instance.Subscribe(new SoftAliyunSubEventHandler());
|
|
//if (ConfigurationManager.AppSettings["AliyunSubOpen"] != null && ConfigurationManager.AppSettings["AliyunSubOpen"] == "1")
|
|
//{
|
|
// OnscSharp.CreatePushConsumer();
|
|
// OnscSharp.StartPushConsumer();
|
|
// LogHelper.Info("--阿里云订阅成功!");
|
|
//}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
WX.CRM.Common.LogHelper.Error(e);
|
|
}
|
|
}
|
|
|
|
protected override void OnStop()
|
|
{
|
|
try
|
|
{
|
|
LogHelper.Info("*******服务停止********");
|
|
//if (ConfigurationManager.AppSettings["AliyunSubOpen"] != null && ConfigurationManager.AppSettings["AliyunSubOpen"] == "1")
|
|
//{
|
|
//OnscSharp.ShutdownProducer();
|
|
//OnscSharp.shutdownPushConsumer();
|
|
//LogHelper.Info("**阿里云订阅关闭");
|
|
//}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
WX.CRM.Common.LogHelper.Error(e);
|
|
}
|
|
}
|
|
|
|
public void GetScheduleJob()
|
|
{
|
|
try
|
|
{
|
|
JobSchedulingDataProcessor processor = new JobSchedulingDataProcessor(true, true);
|
|
ISchedulerFactory sf = new Quartz.Impl.StdSchedulerFactory();
|
|
IScheduler sched = sf.GetScheduler();
|
|
LogHelper.Info("------GetScheduleJob开始执行-----");
|
|
Stream s = new StreamReader(string.Concat(AppDomain.CurrentDomain.BaseDirectory, "XML/JobConfig.xml"), System.Text.Encoding.GetEncoding("UTF-8")).BaseStream;
|
|
processor.ProcessStream(s, null);
|
|
processor.ScheduleJobs(new Hashtable(), sched, false);
|
|
sched.StartDelayed(TimeSpan.FromMilliseconds(10));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
WX.CRM.Common.LogHelper.Error(ex);
|
|
}
|
|
}
|
|
}
|
|
} |