|
@@ -16,10 +16,17 @@ using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace OTSIncAReportApp
|
|
|
{
|
|
|
+ public struct PostLogMsg
|
|
|
+ {
|
|
|
+ public int logLevel;//1 trace 2 debug 3info 4 warn 5 error 6 fatal
|
|
|
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)200)]
|
|
|
+ public char[] logMessage;
|
|
|
+ };
|
|
|
/// <summary>
|
|
|
/// 报告主窗体类
|
|
|
/// </summary>
|
|
@@ -38,6 +45,11 @@ namespace OTSIncAReportApp
|
|
|
|
|
|
#region 报告类结构相关------------------------------------------------------------------------------------
|
|
|
NLog.Logger log;
|
|
|
+
|
|
|
+ private PostLogMsg m_LogMsg;
|
|
|
+ public const int MsgID = 0x0464;
|
|
|
+ public const int LogMsgID = 0x0465;
|
|
|
+
|
|
|
public OutputNlog m_OutputNlog; //日志类对象
|
|
|
public ResultDataMgr m_rstDataMgr = null; //DataMgrFun 对象, 此类是和调用C++ DataMGR交互数据
|
|
|
public OTSRibbonFun m_RibbonFun = null; //报告菜单相关操作类
|
|
@@ -1068,6 +1080,53 @@ namespace OTSIncAReportApp
|
|
|
Help help = new Help();
|
|
|
help.ShowDialog();
|
|
|
}
|
|
|
+ protected override void DefWndProc(ref Message m)
|
|
|
+ {
|
|
|
+ switch (m.Msg)
|
|
|
+ {
|
|
|
+
|
|
|
+ case LogMsgID:
|
|
|
+ m_LogMsg = new PostLogMsg();
|
|
|
+
|
|
|
+ m_LogMsg = (PostLogMsg)Marshal.PtrToStructure(m.LParam, typeof(PostLogMsg));
|
|
|
+ var log = NLog.LogManager.GetCurrentClassLogger();
|
|
|
+ string s = GetString(m_LogMsg.logMessage);
|
|
|
+ switch (m_LogMsg.logLevel)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ log.Trace(s);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ log.Debug(s);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ log.Info(s);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ log.Warn(s);
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ log.Error(s);
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ log.Fatal(s);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ base.DefWndProc(ref m);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private string GetString(char[] csStr)
|
|
|
+ {
|
|
|
+ int ilen = csStr.Length;
|
|
|
+ string csName = new string(csStr); //MSTMsg.STMSampleStu.cSName
|
|
|
+ csName.IndexOf('\0');
|
|
|
+ csName = csName.Substring(0, csName.IndexOf('\0'));
|
|
|
+ return csName;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|