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.

106 lines
3.9 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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();
}
}
}