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;
});
});
//停止
}
///
/// 输出日志
///
///
///
static void server_ExportMonitorEvent(object sender, MonitorInfo arg)
{
Console.WriteLine(arg.PlanName + "\t" + arg.LastExecuteTime.ToString() + "\t" + arg.LastExecuteResult);
}
}
}