|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Linq;
|
|
|
using System.ServiceProcess;
|
|
|
using System.Text;
|
|
|
using System.Runtime;
|
|
|
using System.Runtime.Remoting;
|
|
|
using System.Runtime.Remoting.Channels;
|
|
|
using System.Runtime.Remoting.Channels.Tcp;
|
|
|
using System.Collections;
|
|
|
namespace CommService
|
|
|
{
|
|
|
/*
|
|
|
*类名称:NYJLCommService
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*功能描述:能源计量服务类
|
|
|
*/
|
|
|
|
|
|
public partial class NYJLCommService : ServiceBase
|
|
|
{
|
|
|
public NYJLCommService()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
InitService();
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:InitService
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:服务初始化
|
|
|
*/
|
|
|
|
|
|
private void InitService()
|
|
|
{
|
|
|
//Common.logFile = new LogFile();// LogFile.instance();
|
|
|
//Common.logFile.init(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
|
|
|
// "\\log", "log.txt", "\\err", "err.txt", 1048000);
|
|
|
//Common.logSYSFile = new LogFile();
|
|
|
//Common.logSYSFile.init(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
|
|
|
// "\\sys", "log.txt", "\\err", "err.txt", 1048000);
|
|
|
//Common.configReader.Load(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\config.xml");
|
|
|
|
|
|
|
|
|
|
|
|
Common.logFile = new LogFile();// LogFile.instance();
|
|
|
Common.logFile.init(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
|
|
|
"\\log\\log", "log.txt", "\\error", "errlog.txt", 1024000);
|
|
|
// 系统运行日志
|
|
|
Common.logSystemFile = new LogFile();
|
|
|
Common.logSystemFile.init(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
|
|
|
"\\log\\system", "syslog.txt", "\\error", "errlog.txt", 1024000);
|
|
|
// 调试日志
|
|
|
Common.logDebugFile = new LogFile();
|
|
|
Common.logDebugFile.init(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
|
|
|
"\\log\\debug", "debuglog.txt", "\\error", "errlog.txt", 1024000);
|
|
|
// 异常日志
|
|
|
Common.logErrFile = new LogFile();
|
|
|
Common.logErrFile.init(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
|
|
|
"\\log\\error", "errlog.txt", "\\error", "errlog.txt", 1024000);
|
|
|
|
|
|
Common.configReader.Load(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\config.xml");
|
|
|
|
|
|
////设置日志最低level
|
|
|
//Common.logFile.SetLogMinLevel(Common.configReader.sLogLevel);
|
|
|
//Common.logSYSFile.SetLogMinLevel(Common.configReader.sLogLevel);
|
|
|
|
|
|
//设置日志最低level
|
|
|
Common.logFile.SetLogMinLevel(Common.configReader.sLogLevel);
|
|
|
Common.logDebugFile.SetLogMinLevel(Common.configReader.sLogLevel);
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:OnStart
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:string[] args 默认
|
|
|
*返回描述:void
|
|
|
*功能描述:服务启动函数
|
|
|
*/
|
|
|
protected override void OnStart(string[] args)
|
|
|
{
|
|
|
Common.logSystemFile.write("服务启动...", LogFile.LOGLVL_NORMAL);
|
|
|
Common.platForm.Start();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:OnStop
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:服务停止函数
|
|
|
*/
|
|
|
protected override void OnStop()
|
|
|
{
|
|
|
Common.logSystemFile.write("服务已停止。\r\n", LogFile.LOGLVL_NORMAL);
|
|
|
Common.platForm.Stop();
|
|
|
}
|
|
|
}
|
|
|
}
|