You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
60 lines
1.8 KiB
4 years ago
|
using System;
|
||
|
using System.Configuration;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using Topshelf;
|
||
|
using QMTask.Core;
|
||
|
using QMAPP.ServicesAgent;
|
||
|
|
||
|
namespace QMTask.Host
|
||
|
{
|
||
|
class Program
|
||
|
{
|
||
|
static void Main(string[] args)
|
||
|
{
|
||
|
//配置日志处理组件
|
||
|
QMFrameWork.Log.LogManager.Configure("log4net");
|
||
|
//QMFrameWork.Data.DataFactory.Configure(true);
|
||
|
//初始化服务
|
||
|
ServiceAgent.Init();
|
||
|
|
||
|
//启动
|
||
|
HostFactory.Run(x =>
|
||
|
{
|
||
|
x.RunAsLocalSystem();
|
||
|
|
||
|
x.SetDescription(QMTask.Core.Configuration.ServiceDescription);
|
||
|
x.SetDisplayName(QMTask.Core.Configuration.ServiceDisplayName);
|
||
|
x.SetServiceName(QMTask.Core.Configuration.ServiceName);
|
||
|
|
||
|
x.Service(factory =>
|
||
|
{
|
||
|
TaskServer server = new TaskServer();
|
||
|
|
||
|
//绑定监控信息输出事件
|
||
|
server.ExportMonitorEvent += new TaskServer.ExportMonitorEventHandler(server_ExportMonitorEvent);
|
||
|
|
||
|
TaskService.MyTaskServer = server;
|
||
|
//指定服务凭据
|
||
|
TaskService.ServiceCredentialID = ConfigurationManager.AppSettings["ServiceCredentialID"];
|
||
|
|
||
|
return server;
|
||
|
});
|
||
|
});
|
||
|
|
||
|
//停止
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 输出日志
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="arg"></param>
|
||
|
static void server_ExportMonitorEvent(object sender, MonitorInfo arg)
|
||
|
{
|
||
|
Console.WriteLine(arg.PlanName + "\t" + arg.LastExecuteTime.ToString() + "\t" + arg.LastExecuteResult);
|
||
|
}
|
||
|
}
|
||
|
}
|