errorlog.cs

来自「用vs2005写的一个生产任务管理系统。数据的统计和综合查询是主要功能」· CS 代码 · 共 86 行

CS
86
字号
using System; 
using System.Diagnostics;

namespace RWSB.Modules
{
	/// <summary>
	/// errorLog 的摘要说明。
	/// </summary>
	public class ErrorLog
	{
		public ErrorLog()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public static void WriteLog(string Message,System.Diagnostics.EventLogEntryType EventLogEntryType)
		{
			System.Diagnostics.EventLog oEventLog=new EventLog();
			try
			{
				if (!EventLog.SourceExists("RWSB"))
				{
					EventLog.CreateEventSource("RWSB","供电设备检修生产任务管理系统");
				}
			
				oEventLog.Source="RWSB";
				oEventLog.WriteEntry(Message,EventLogEntryType);
			}
			catch{}
		}
		public static void WriteLog(string Message)
		{
			System.Diagnostics.EventLog oEventLog=new EventLog();
			try
			{
				if (!EventLog.SourceExists("RWSB"))
				{
					EventLog.CreateEventSource("RWSB","供电设备检修生产任务管理系统");
				}
			
				oEventLog.Source="RWSB";
				oEventLog.WriteEntry(Message,System.Diagnostics.EventLogEntryType.Error);
			}
			catch{
			
			}
		}
		public static void WriteLog(string ModuleName,string Message,System.Diagnostics.EventLogEntryType EventLogEntryType)
		{
			System.Diagnostics.EventLog oEventLog=new EventLog();
			try
			{
				if (!EventLog.SourceExists("RWSB"))
				{
					EventLog.CreateEventSource("RWSB","供电设备检修生产任务管理系统");
				}
			
				oEventLog.Source="OI";
				oEventLog.WriteEntry("发生模块:"+ModuleName+"\n"+Message,EventLogEntryType);
			}
			catch{
			
			}
		}
		public static void WriteLog(string ModuleName,string Message)
		{
			
			System.Diagnostics.EventLog oEventLog=new EventLog();
			try
			{
				if (!EventLog.SourceExists("RWSB"))
				{
					EventLog.CreateEventSource("RWSB","供电设备检修生产任务管理系统");
				}
				oEventLog.Source="RWSB";
				oEventLog.WriteEntry("发生模块:"+ModuleName+"\n"+Message,System.Diagnostics.EventLogEntryType.Error);
			}
			catch{
			
			}
		}

	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?