Commit 888be158 authored by denny's avatar denny

同步代码

parent eb195acc
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace MilitaryGuaranteeCard namespace MilitaryGuaranteeCard
{ {
/// <summary> /// <summary>
/// Dll导入 /// Dll导入
/// </summary> /// </summary>
public class DllImport public class DllImport
{ {
#region Define #region Define
/// <summary> /// <summary>
/// 动态库路径 /// 动态库路径
/// </summary> /// </summary>
private const String DllPath = @"PLA\RW_VC_MMSC.dll"; private const String DllPath = @"PLA\RW_VC_MMSC.dll";
#endregion #endregion
#region DllImport #region DllImport
[DllImport(DllPath, EntryPoint = "UnloadTargetDll", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "UnloadTargetDll", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern void UnloadTargetDll(); public static extern void UnloadTargetDll();
[DllImport(DllPath, EntryPoint = "OpenComm", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "OpenComm", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int OpenComm(string devPort); public static extern int OpenComm(string devPort);
[DllImport(DllPath, EntryPoint = "CloseComm", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "CloseComm", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int CloseComm(); public static extern int CloseComm();
[DllImport(DllPath, EntryPoint = "PowerOn", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "PowerOn", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int PowerOn(IntPtr recData,ref uint pLen); public static extern int PowerOn(IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "PowerOff", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "PowerOff", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int PowerOff(IntPtr recData,ref uint pLen); public static extern int PowerOff(IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "ReadCard", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "ReadCard", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int ReadCard(uint zone, uint addr, uint len, IntPtr recData, ref uint pLen); public static extern int ReadCard(uint zone, uint addr, uint len, IntPtr recData, ref uint pLen);
[DllImport(DllPath, EntryPoint = "WriteCard", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "WriteCard", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int WriteCard (uint zone,uint addr,uint len,byte[] sendData,IntPtr recData,ref uint pLen); public static extern int WriteCard (uint zone,uint addr,uint len,byte[] sendData,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "ChkSecret", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "ChkSecret", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int ChkSecret (int keyType,byte[] key,IntPtr recData,ref uint pLen); public static extern int ChkSecret (int keyType,byte[] key,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "WriteSecret", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "WriteSecret", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int WriteSecret (int keyType,byte[] key,IntPtr recData,ref uint pLen); public static extern int WriteSecret (int keyType,byte[] key,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "ReadSecret", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "ReadSecret", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int ReadSecret (int keyType,IntPtr recData,ref uint pLen); public static extern int ReadSecret (int keyType,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "HexStrToByte", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "HexStrToByte", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int HexStrToByte (string str,ref byte[] data); public static extern int HexStrToByte (string str,ref byte[] data);
[DllImport(DllPath, EntryPoint = "ByteToHexStr", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "ByteToHexStr", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int ByteToHexStr (byte[] data,uint size,ref string str); public static extern int ByteToHexStr (byte[] data,uint size,ref string str);
[DllImport(DllPath, EntryPoint = "HexByteToDec", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "HexByteToDec", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int HexByteToDec (byte[] strBytes,ref ulong dec); public static extern int HexByteToDec (byte[] strBytes,ref ulong dec);
[DllImport(DllPath, EntryPoint = "DecToHexByte", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "DecToHexByte", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int DecToHexByte (ulong dec,ref byte[] strBytes) ; public static extern int DecToHexByte (ulong dec,ref byte[] strBytes) ;
[DllImport(DllPath, EntryPoint = "SetKeyVersion", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "SetKeyVersion", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int SetKeyVersion (int keyKind,int keyVer,IntPtr recData,ref uint pLen); public static extern int SetKeyVersion (int keyKind,int keyVer,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "Chk1608Secret", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "Chk1608Secret", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int Chk1608Secret (int keyNo,IntPtr recData,ref uint pLen); public static extern int Chk1608Secret (int keyNo,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "Authenfic1608", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "Authenfic1608", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int Authenfic1608 (IntPtr recData,ref uint pLen); public static extern int Authenfic1608 (IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "HexByteToLong", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "HexByteToLong", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int HexByteToLong (byte[] strBytes,ref ulong dec); public static extern int HexByteToLong (byte[] strBytes,ref ulong dec);
[DllImport(DllPath, EntryPoint = "LongToHexByte", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "LongToHexByte", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int LongToHexByte (ulong dec,ref byte[] strBytes); public static extern int LongToHexByte (ulong dec,ref byte[] strBytes);
[DllImport(DllPath, EntryPoint = "Signature", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "Signature", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int Signature (byte[] idInfo,byte[] info,int infoLen,IntPtr recData,ref uint pLen); public static extern int Signature (byte[] idInfo,byte[] info,int infoLen,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "VerifySignet", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "VerifySignet", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int VerifySignet (byte[] idInfo,byte[] info,int infoLen,byte[] infoSign,IntPtr recData,ref uint pLen); public static extern int VerifySignet (byte[] idInfo,byte[] info,int infoLen,byte[] infoSign,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "WriteIDInfo", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "WriteIDInfo", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int WriteIDInfo (byte[] idInfo,IntPtr recData,ref uint pLen); public static extern int WriteIDInfo (byte[] idInfo,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "PINOpfunc", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "PINOpfunc", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int PINOpfunc (int iopType,int slot,byte[] pinInfo,int pinInfoLen,IntPtr recData,ref uint pLen); public static extern int PINOpfunc (int iopType,int slot,byte[] pinInfo,int pinInfoLen,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "UpdateIDInfo", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "UpdateIDInfo", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int UpdateIDInfo (byte[] rightInfo,IntPtr recData,ref uint pLen); public static extern int UpdateIDInfo (byte[] rightInfo,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "LockUserCard", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "LockUserCard", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int LockUserCard (IntPtr recData,ref uint pLen); public static extern int LockUserCard (IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "ReadSamIDInfo", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "ReadSamIDInfo", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int ReadSamIDInfo (IntPtr recData,ref uint pLen); public static extern int ReadSamIDInfo (IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "GetICCardNo", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "GetICCardNo", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int GetICCardNo (int slot,IntPtr recData,ref uint pLen); public static extern int GetICCardNo (int slot,IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "PowerOnSam", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "PowerOnSam", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int PowerOnSam (IntPtr recData,ref uint pLen); public static extern int PowerOnSam (IntPtr recData,ref uint pLen);
[DllImport(DllPath, EntryPoint = "HexStrToByte", CallingConvention = CallingConvention.StdCall, [DllImport(DllPath, EntryPoint = "HexStrToByte", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi, SetLastError = false)] CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int GetUpdateIDRight (byte[] icCardNo,byte[] hospitalId,IntPtr recData,ref uint pLen); public static extern int GetUpdateIDRight (byte[] icCardNo,byte[] hospitalId,IntPtr recData,ref uint pLen);
#endregion #endregion
} }
} }
 
using ClosedXML.Excel; using ClosedXML.Excel;
using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml.Spreadsheet;
using System; using System;
using System.Data; using System.Data;
using System.Data.OleDb; using System.Data.OleDb;
using System.IO; using System.IO;
namespace MilitaryGuaranteeCard namespace MilitaryGuaranteeCard
{ {
/// <summary> /// <summary>
/// Excel帮助类 /// Excel帮助类
/// </summary> /// </summary>
public class ExcelHelper public class ExcelHelper
{ {
private static object m_lock = new object(); private static object m_lock = new object();
private static ExcelHelper m_excelHelper = null; private static ExcelHelper m_excelHelper = null;
public static ExcelHelper GetInstance public static ExcelHelper GetInstance
{ {
get get
{ {
if (m_excelHelper == null) if (m_excelHelper == null)
{ {
lock (m_lock) lock (m_lock)
{ {
if (m_excelHelper == null) if (m_excelHelper == null)
{ {
m_excelHelper = new ExcelHelper(); m_excelHelper = new ExcelHelper();
} }
return m_excelHelper; return m_excelHelper;
} }
} }
return m_excelHelper; return m_excelHelper;
} }
} }
public static DataSet ReadExcel(string path) public static DataSet ReadExcel(string path)
{ {
try try
{ {
string fileSuffix = System.IO.Path.GetExtension(path); string fileSuffix = System.IO.Path.GetExtension(path);
if (string.IsNullOrEmpty(fileSuffix)) if (string.IsNullOrEmpty(fileSuffix))
return null; return null;
using (DataSet ds = new DataSet()) using (DataSet ds = new DataSet())
{ {
string connStr = ""; string connStr = "";
if (fileSuffix == ".xls") if (fileSuffix == ".xls")
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR = Yes;IMEX=1\""; connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR = Yes;IMEX=1\"";
else else
connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR = Yes;IMEX=1\""; connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR = Yes;IMEX=1\"";
string sql_select = "SELECT * FROM [SQL Results$]"; string sql_select = "SELECT * FROM [SQL Results$]";
using (OleDbConnection conn = new OleDbConnection(connStr)) using (OleDbConnection conn = new OleDbConnection(connStr))
using (OleDbDataAdapter cmd = new OleDbDataAdapter(sql_select, conn)) using (OleDbDataAdapter cmd = new OleDbDataAdapter(sql_select, conn))
{ {
OpenConn(conn); OpenConn(conn);
cmd.Fill(ds); cmd.Fill(ds);
CloseConn(conn); CloseConn(conn);
} }
if (ds == null || ds.Tables.Count <= 0) return null; if (ds == null || ds.Tables.Count <= 0) return null;
//Clear.BHC.Common.logManager.WriteLogByPath("Excel_Log", "Excel表数据查询成功"); //Clear.BHC.Common.logManager.WriteLogByPath("Excel_Log", "Excel表数据查询成功");
return ds; return ds;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new Exception($"ReadExcel函数发生异常:{ex.Message}"); throw new Exception($"ReadExcel函数发生异常:{ex.Message}");
} }
} }
public static void OpenConn(OleDbConnection conn) public static void OpenConn(OleDbConnection conn)
{ {
conn.Open(); conn.Open();
} }
public static void CloseConn(OleDbConnection conn) public static void CloseConn(OleDbConnection conn)
{ {
conn.Close(); conn.Close();
} }
/// <summary> /// <summary>
/// 根据条件获取表格 /// 根据条件获取表格
/// </summary> /// </summary>
/// <param name="path">路径</param> /// <param name="path">路径</param>
/// <param name="sheetname">表名</param> /// <param name="sheetname">表名</param>
/// <param name="condition">条件</param> /// <param name="condition">条件</param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public static DataSet ReadExcel2(string path, string sheetName, string condition) public static DataSet ReadExcel2(string path, string sheetName, string condition)
{ {
if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(sheetName)) if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(sheetName))
{ {
throw new ArgumentException("路径或工作表名称不能为空。"); throw new ArgumentException("路径或工作表名称不能为空。");
} }
try try
{ {
// 判断文件后缀,选择合适的连接字符串 // 判断文件后缀,选择合适的连接字符串
string fileSuffix = Path.GetExtension(path); string fileSuffix = Path.GetExtension(path);
if (string.IsNullOrEmpty(fileSuffix)) if (string.IsNullOrEmpty(fileSuffix))
{ {
throw new FileNotFoundException("文件后缀无法识别,请检查路径是否正确。"); throw new FileNotFoundException("文件后缀无法识别,请检查路径是否正确。");
} }
string connStr = ""; string connStr = "";
if (fileSuffix.ToLower() == ".xls") if (fileSuffix.ToLower() == ".xls")
{ {
connStr = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={path};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; connStr = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={path};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
} }
else if (fileSuffix.ToLower() == ".xlsx") else if (fileSuffix.ToLower() == ".xlsx")
{ {
connStr = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={path};Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\""; connStr = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={path};Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\"";
} }
else else
{ {
throw new NotSupportedException("仅支持 .xls 和 .xlsx 格式的文件。"); throw new NotSupportedException("仅支持 .xls 和 .xlsx 格式的文件。");
} }
string query = $"SELECT * FROM [{sheetName}$]"; string query = $"SELECT * FROM [{sheetName}$]";
if (!string.IsNullOrEmpty(condition)) if (!string.IsNullOrEmpty(condition))
{ {
query += $" {condition}"; query += $" {condition}";
} }
using (OleDbConnection conn = new OleDbConnection(connStr)) using (OleDbConnection conn = new OleDbConnection(connStr))
{ {
conn.Open(); conn.Open();
using (OleDbCommand cmd = new OleDbCommand(query, conn)) using (OleDbCommand cmd = new OleDbCommand(query, conn))
using (OleDbDataAdapter adapter = new OleDbDataAdapter(cmd)) using (OleDbDataAdapter adapter = new OleDbDataAdapter(cmd))
{ {
DataSet ds = new DataSet(); DataSet ds = new DataSet();
adapter.Fill(ds); adapter.Fill(ds);
if (ds.Tables.Count > 0) if (ds.Tables.Count > 0)
{ {
return ds; return ds;
} }
return null; return null;
} }
} }
} }
catch (OleDbException oleDbEx) catch (OleDbException oleDbEx)
{ {
throw new Exception($"数据库操作异常:{oleDbEx.Message}"); throw new Exception($"数据库操作异常:{oleDbEx.Message}");
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new Exception($"ReadExcel2函数发生异常:{ex}"); throw new Exception($"ReadExcel2函数发生异常:{ex}");
} }
} }
/// <summary> /// <summary>
/// 使用外部控件读取excel数据 /// 使用外部控件读取excel数据
/// </summary> /// </summary>
/// <param name="path"></param> /// <param name="path"></param>
/// <param name="sheetname"></param> /// <param name="sheetname"></param>
/// <returns></returns> /// <returns></returns>
public static IXLWorksheet ReadExcel3(string path, string sheetname) public static IXLWorksheet ReadExcel3(string path, string sheetname)
{ {
try try
{ {
using (var workbook = new XLWorkbook(path)) using (var workbook = new XLWorkbook(path))
{ {
var worksheet = workbook.Worksheet(sheetname); var worksheet = workbook.Worksheet(sheetname);
return worksheet; return worksheet;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new Exception($"ReadExcel3函数发生异常:{ex.Message}"); throw new Exception($"ReadExcel3函数发生异常:{ex.Message}");
} }
} }
} }
} }
namespace MilitaryGuaranteeCard namespace MilitaryGuaranteeCard
{ {
partial class Form1 partial class Form1
{ {
/// <summary> /// <summary>
/// 必需的设计器变量。 /// 必需的设计器变量。
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// 清理所有正在使用的资源。 /// 清理所有正在使用的资源。
/// </summary> /// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows 窗体设计器生成的代码 #region Windows 窗体设计器生成的代码
/// <summary> /// <summary>
/// 设计器支持所需的方法 - 不要修改 /// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。 /// 使用代码编辑器修改此方法的内容。
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.txtDevPort = new System.Windows.Forms.TextBox(); this.txtDevPort = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.btnOpen = new System.Windows.Forms.Button(); this.btnOpen = new System.Windows.Forms.Button();
this.btnPowerOn = new System.Windows.Forms.Button(); this.btnPowerOn = new System.Windows.Forms.Button();
this.btnPowerOff = new System.Windows.Forms.Button(); this.btnPowerOff = new System.Windows.Forms.Button();
this.btnReadCard = new System.Windows.Forms.Button(); this.btnReadCard = new System.Windows.Forms.Button();
this.rtbOutput = new System.Windows.Forms.RichTextBox(); this.rtbOutput = new System.Windows.Forms.RichTextBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.txtExcelName = new System.Windows.Forms.TextBox(); this.txtExcelName = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.txtSheetName = new System.Windows.Forms.TextBox(); this.txtSheetName = new System.Windows.Forms.TextBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// txtDevPort // txtDevPort
// //
this.txtDevPort.Location = new System.Drawing.Point(105, 25); this.txtDevPort.Location = new System.Drawing.Point(105, 25);
this.txtDevPort.Name = "txtDevPort"; this.txtDevPort.Name = "txtDevPort";
this.txtDevPort.Size = new System.Drawing.Size(105, 25); this.txtDevPort.Size = new System.Drawing.Size(105, 25);
this.txtDevPort.TabIndex = 1; this.txtDevPort.TabIndex = 1;
this.txtDevPort.Text = "USB"; this.txtDevPort.Text = "USB";
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 10F); this.label1.Font = new System.Drawing.Font("宋体", 10F);
this.label1.Location = new System.Drawing.Point(14, 32); this.label1.Location = new System.Drawing.Point(14, 32);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(85, 17); this.label1.Size = new System.Drawing.Size(85, 17);
this.label1.TabIndex = 2; this.label1.TabIndex = 2;
this.label1.Text = "设备端口:"; this.label1.Text = "设备端口:";
// //
// btnOpen // btnOpen
// //
this.btnOpen.Font = new System.Drawing.Font("宋体", 10F); this.btnOpen.Font = new System.Drawing.Font("宋体", 10F);
this.btnOpen.Location = new System.Drawing.Point(222, 25); this.btnOpen.Location = new System.Drawing.Point(222, 25);
this.btnOpen.Name = "btnOpen"; this.btnOpen.Name = "btnOpen";
this.btnOpen.Size = new System.Drawing.Size(104, 33); this.btnOpen.Size = new System.Drawing.Size(104, 33);
this.btnOpen.TabIndex = 3; this.btnOpen.TabIndex = 3;
this.btnOpen.Text = "打开设备"; this.btnOpen.Text = "打开设备";
this.btnOpen.UseVisualStyleBackColor = true; this.btnOpen.UseVisualStyleBackColor = true;
this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click); this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
// //
// btnPowerOn // btnPowerOn
// //
this.btnPowerOn.Font = new System.Drawing.Font("宋体", 10F); this.btnPowerOn.Font = new System.Drawing.Font("宋体", 10F);
this.btnPowerOn.Location = new System.Drawing.Point(430, 25); this.btnPowerOn.Location = new System.Drawing.Point(430, 25);
this.btnPowerOn.Name = "btnPowerOn"; this.btnPowerOn.Name = "btnPowerOn";
this.btnPowerOn.Size = new System.Drawing.Size(104, 33); this.btnPowerOn.Size = new System.Drawing.Size(104, 33);
this.btnPowerOn.TabIndex = 4; this.btnPowerOn.TabIndex = 4;
this.btnPowerOn.Text = "IC卡上电"; this.btnPowerOn.Text = "IC卡上电";
this.btnPowerOn.UseVisualStyleBackColor = true; this.btnPowerOn.UseVisualStyleBackColor = true;
this.btnPowerOn.Click += new System.EventHandler(this.btnPowerOn_Click); this.btnPowerOn.Click += new System.EventHandler(this.btnPowerOn_Click);
// //
// btnPowerOff // btnPowerOff
// //
this.btnPowerOff.Font = new System.Drawing.Font("宋体", 10F); this.btnPowerOff.Font = new System.Drawing.Font("宋体", 10F);
this.btnPowerOff.Location = new System.Drawing.Point(585, 24); this.btnPowerOff.Location = new System.Drawing.Point(585, 24);
this.btnPowerOff.Name = "btnPowerOff"; this.btnPowerOff.Name = "btnPowerOff";
this.btnPowerOff.Size = new System.Drawing.Size(104, 33); this.btnPowerOff.Size = new System.Drawing.Size(104, 33);
this.btnPowerOff.TabIndex = 5; this.btnPowerOff.TabIndex = 5;
this.btnPowerOff.Text = "IC卡下电"; this.btnPowerOff.Text = "IC卡下电";
this.btnPowerOff.UseVisualStyleBackColor = true; this.btnPowerOff.UseVisualStyleBackColor = true;
this.btnPowerOff.Click += new System.EventHandler(this.btnPowerOff_Click); this.btnPowerOff.Click += new System.EventHandler(this.btnPowerOff_Click);
// //
// btnReadCard // btnReadCard
// //
this.btnReadCard.Font = new System.Drawing.Font("宋体", 10F); this.btnReadCard.Font = new System.Drawing.Font("宋体", 10F);
this.btnReadCard.Location = new System.Drawing.Point(587, 76); this.btnReadCard.Location = new System.Drawing.Point(587, 76);
this.btnReadCard.Name = "btnReadCard"; this.btnReadCard.Name = "btnReadCard";
this.btnReadCard.Size = new System.Drawing.Size(104, 33); this.btnReadCard.Size = new System.Drawing.Size(104, 33);
this.btnReadCard.TabIndex = 6; this.btnReadCard.TabIndex = 6;
this.btnReadCard.Text = "读取卡片"; this.btnReadCard.Text = "读取卡片";
this.btnReadCard.UseVisualStyleBackColor = true; this.btnReadCard.UseVisualStyleBackColor = true;
this.btnReadCard.Click += new System.EventHandler(this.btnReadCard_Click); this.btnReadCard.Click += new System.EventHandler(this.btnReadCard_Click);
// //
// rtbOutput // rtbOutput
// //
this.rtbOutput.Location = new System.Drawing.Point(17, 152); this.rtbOutput.Location = new System.Drawing.Point(17, 152);
this.rtbOutput.Name = "rtbOutput"; this.rtbOutput.Name = "rtbOutput";
this.rtbOutput.Size = new System.Drawing.Size(743, 377); this.rtbOutput.Size = new System.Drawing.Size(743, 377);
this.rtbOutput.TabIndex = 9; this.rtbOutput.TabIndex = 9;
this.rtbOutput.Text = ""; this.rtbOutput.Text = "";
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 10F); this.label2.Font = new System.Drawing.Font("宋体", 10F);
this.label2.Location = new System.Drawing.Point(14, 87); this.label2.Location = new System.Drawing.Point(14, 87);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(141, 21); this.label2.Size = new System.Drawing.Size(141, 21);
this.label2.TabIndex = 11; this.label2.TabIndex = 11;
this.label2.Text = "Excel文件名:"; this.label2.Text = "Excel文件名:";
// //
// txtExcelName // txtExcelName
// //
this.txtExcelName.Location = new System.Drawing.Point(136, 83); this.txtExcelName.Location = new System.Drawing.Point(136, 83);
this.txtExcelName.Name = "txtExcelName"; this.txtExcelName.Name = "txtExcelName";
this.txtExcelName.Size = new System.Drawing.Size(151, 25); this.txtExcelName.Size = new System.Drawing.Size(151, 25);
this.txtExcelName.TabIndex = 10; this.txtExcelName.TabIndex = 10;
this.txtExcelName.Text = "medical_card_schedule"; this.txtExcelName.Text = "medical_card_schedule";
// //
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 10F); this.label3.Font = new System.Drawing.Font("宋体", 10F);
this.label3.Location = new System.Drawing.Point(307, 87); this.label3.Location = new System.Drawing.Point(307, 87);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(143, 21); this.label3.Size = new System.Drawing.Size(143, 21);
this.label3.TabIndex = 13; this.label3.TabIndex = 13;
this.label3.Text = "表名(Sheet):"; this.label3.Text = "表名(Sheet):";
// //
// txtSheetName // txtSheetName
// //
this.txtSheetName.Location = new System.Drawing.Point(429, 81); this.txtSheetName.Location = new System.Drawing.Point(429, 81);
this.txtSheetName.Name = "txtSheetName"; this.txtSheetName.Name = "txtSheetName";
this.txtSheetName.Size = new System.Drawing.Size(105, 25); this.txtSheetName.Size = new System.Drawing.Size(105, 25);
this.txtSheetName.TabIndex = 12; this.txtSheetName.TabIndex = 12;
this.txtSheetName.Text = "SQL Results"; this.txtSheetName.Text = "SQL Results";
// //
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(785, 562); this.ClientSize = new System.Drawing.Size(785, 562);
this.Controls.Add(this.txtSheetName); this.Controls.Add(this.txtSheetName);
this.Controls.Add(this.txtExcelName); this.Controls.Add(this.txtExcelName);
this.Controls.Add(this.rtbOutput); this.Controls.Add(this.rtbOutput);
this.Controls.Add(this.btnReadCard); this.Controls.Add(this.btnReadCard);
this.Controls.Add(this.btnPowerOff); this.Controls.Add(this.btnPowerOff);
this.Controls.Add(this.btnPowerOn); this.Controls.Add(this.btnPowerOn);
this.Controls.Add(this.btnOpen); this.Controls.Add(this.btnOpen);
this.Controls.Add(this.txtDevPort); this.Controls.Add(this.txtDevPort);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "军人保障卡测试"; this.Text = "军人保障卡测试";
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.TextBox txtDevPort; private System.Windows.Forms.TextBox txtDevPort;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnOpen; private System.Windows.Forms.Button btnOpen;
private System.Windows.Forms.Button btnPowerOn; private System.Windows.Forms.Button btnPowerOn;
private System.Windows.Forms.Button btnPowerOff; private System.Windows.Forms.Button btnPowerOff;
private System.Windows.Forms.Button btnReadCard; private System.Windows.Forms.Button btnReadCard;
private System.Windows.Forms.RichTextBox rtbOutput; private System.Windows.Forms.RichTextBox rtbOutput;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtExcelName; private System.Windows.Forms.TextBox txtExcelName;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtSheetName; private System.Windows.Forms.TextBox txtSheetName;
} }
} }
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Data; using System.Data;
using System.Dynamic; using System.Dynamic;
using System.IO; using System.IO;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
namespace MilitaryGuaranteeCard namespace MilitaryGuaranteeCard
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
btnPowerOn.Enabled = false; btnPowerOn.Enabled = false;
btnPowerOff.Enabled = false; btnPowerOff.Enabled = false;
btnReadCard.Enabled = false; btnReadCard.Enabled = false;
} }
/// <summary> /// <summary>
/// 打开标识 /// 打开标识
/// </summary> /// </summary>
private static bool _openHandle=false; private static bool _openHandle=false;
/// <summary> /// <summary>
/// 打开/关闭设备 /// 打开/关闭设备
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
private void btnOpen_Click(object sender, EventArgs e) private void btnOpen_Click(object sender, EventArgs e)
{ {
try try
{ {
// 接收设备端口,并转换为全大写 // 接收设备端口,并转换为全大写
String devPort = txtDevPort.Text.Trim().ToUpper(); String devPort = txtDevPort.Text.Trim().ToUpper();
if (!_openHandle) if (!_openHandle)
{ {
// 判断设备端口是否为null // 判断设备端口是否为null
if (!String.IsNullOrEmpty(devPort)) if (!String.IsNullOrEmpty(devPort))
{ {
// 调用Dll,打开设备通讯 // 调用Dll,打开设备通讯
if (DllImport.OpenComm(devPort).Equals(0)) if (DllImport.OpenComm(devPort).Equals(0))
{ {
_openHandle = true; _openHandle = true;
btnPowerOn.Enabled=true; btnPowerOn.Enabled=true;
MessageBox.Show("设备通讯打开成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("设备通讯打开成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
btnOpen.Text = "关闭设备"; btnOpen.Text = "关闭设备";
btnOpen.Enabled = true; btnOpen.Enabled = true;
} }
else else
{ {
MessageBox.Show("设备通讯打开失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("设备通讯打开失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
else else
{ {
MessageBox.Show("请输入设备端口", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("请输入设备端口", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
else else
{ {
// 调用Dll,关闭设备通讯 // 调用Dll,关闭设备通讯
if (DllImport.CloseComm().Equals(0)) if (DllImport.CloseComm().Equals(0))
{ {
_openHandle = false; _openHandle = false;
MessageBox.Show("设备通讯关闭成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("设备通讯关闭成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
btnOpen.Text = "打开设备"; btnOpen.Text = "打开设备";
} }
else else
{ {
MessageBox.Show("设备通讯关闭失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("设备通讯关闭失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
DllImport.UnloadTargetDll(); DllImport.UnloadTargetDll();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Instance.ErrorLogs($"设备通讯操作函数发生异常", ex); Logger.Instance.ErrorLogs($"设备通讯操作函数发生异常", ex);
} }
} }
/// <summary> /// <summary>
/// IC卡片上电 /// IC卡片上电
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
private void btnPowerOn_Click(object sender, EventArgs e) private void btnPowerOn_Click(object sender, EventArgs e)
{ {
try try
{ {
// 判断打开标识 // 判断打开标识
if (_openHandle) if (_openHandle)
{ {
// 定义缓冲区大小 // 定义缓冲区大小
const int bufferSize = 256; const int bufferSize = 256;
// 托管缓冲区 // 托管缓冲区
byte[] managedBuffer = new byte[bufferSize]; byte[] managedBuffer = new byte[bufferSize];
// 初始长度 // 初始长度
uint dataLength = (uint)managedBuffer.Length; uint dataLength = (uint)managedBuffer.Length;
// 分配非托管内存 // 分配非托管内存
IntPtr recData = Marshal.AllocHGlobal(bufferSize); IntPtr recData = Marshal.AllocHGlobal(bufferSize);
// 初始化非托管内存 // 初始化非托管内存
Marshal.Copy(managedBuffer, 0, recData, bufferSize); Marshal.Copy(managedBuffer, 0, recData, bufferSize);
// 调用Dll,IC卡片上电 // 调用Dll,IC卡片上电
if (DllImport.PowerOn(recData, ref dataLength).Equals(0)) if (DllImport.PowerOn(recData, ref dataLength).Equals(0))
{ {
MessageBox.Show("IC卡片上电成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("IC卡片上电成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
btnPowerOn.Enabled = false; btnPowerOn.Enabled = false;
btnPowerOff.Enabled = true; btnPowerOff.Enabled = true;
btnReadCard.Enabled = true; btnReadCard.Enabled = true;
} }
else else
{ {
MessageBox.Show("IC卡片上电失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("IC卡片上电失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
else else
{ {
MessageBox.Show("设备通讯未打开", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("设备通讯未打开", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Instance.ErrorLogs($"IC卡片上电函数发生异常", ex); Logger.Instance.ErrorLogs($"IC卡片上电函数发生异常", ex);
} }
} }
/// <summary> /// <summary>
/// IC卡片下电 /// IC卡片下电
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
private void btnPowerOff_Click(object sender, EventArgs e) private void btnPowerOff_Click(object sender, EventArgs e)
{ {
try try
{ {
// 判断打开标识 // 判断打开标识
if (_openHandle) if (_openHandle)
{ {
// 定义缓冲区大小 // 定义缓冲区大小
const int bufferSize = 256; const int bufferSize = 256;
// 托管缓冲区 // 托管缓冲区
byte[] managedBuffer = new byte[bufferSize]; byte[] managedBuffer = new byte[bufferSize];
// 初始长度 // 初始长度
uint dataLength = (uint)managedBuffer.Length; uint dataLength = (uint)managedBuffer.Length;
// 分配非托管内存 // 分配非托管内存
IntPtr recData = Marshal.AllocHGlobal(bufferSize); IntPtr recData = Marshal.AllocHGlobal(bufferSize);
// 初始化非托管内存 // 初始化非托管内存
Marshal.Copy(managedBuffer, 0, recData, bufferSize); Marshal.Copy(managedBuffer, 0, recData, bufferSize);
if (DllImport.PowerOff(recData, ref dataLength).Equals(0)) if (DllImport.PowerOff(recData, ref dataLength).Equals(0))
{ {
MessageBox.Show("IC卡片下电成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("IC卡片下电成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
rtbOutput.Text = null; rtbOutput.Text = null;
btnPowerOn.Enabled = true; btnPowerOn.Enabled = true;
btnPowerOff.Enabled = false; btnPowerOff.Enabled = false;
btnReadCard.Enabled = false; btnReadCard.Enabled = false;
} }
else else
{ {
MessageBox.Show("IC卡片下电失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("IC卡片下电失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
else else
{ {
MessageBox.Show("设备通讯未打开", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("设备通讯未打开", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Instance.ErrorLogs($"IC卡片下电函数发生异常", ex); Logger.Instance.ErrorLogs($"IC卡片下电函数发生异常", ex);
} }
} }
/// <summary> /// <summary>
/// 读取卡片 /// 读取卡片
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
private void btnReadCard_Click(object sender, EventArgs e) private void btnReadCard_Click(object sender, EventArgs e)
{ {
try try
{ {
// 判断打开标识 // 判断打开标识
if (_openHandle) if (_openHandle)
{ {
// 定义缓冲区大小 // 定义缓冲区大小
const int bufferSize = 256; const int bufferSize = 256;
// 托管缓冲区 // 托管缓冲区
byte[] managedBuffer = new byte[bufferSize]; byte[] managedBuffer = new byte[bufferSize];
// 初始长度 // 初始长度
uint dataLength = (uint)managedBuffer.Length; uint dataLength = (uint)managedBuffer.Length;
// 分配非托管内存 // 分配非托管内存
IntPtr recData = Marshal.AllocHGlobal(bufferSize); IntPtr recData = Marshal.AllocHGlobal(bufferSize);
// 初始化非托管内存 // 初始化非托管内存
Marshal.Copy(managedBuffer, 0, recData, bufferSize); Marshal.Copy(managedBuffer, 0, recData, bufferSize);
if (!DllImport.Authenfic1608(recData, ref dataLength).Equals(0)) if (!DllImport.Authenfic1608(recData, ref dataLength).Equals(0))
{ {
MessageBox.Show("双向认证未通过", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("双向认证未通过", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
} }
int keyNo = ((8 * 0) + 0) + 1; int keyNo = ((8 * 0) + 0) + 1;
// 初始长度 // 初始长度
dataLength = (uint)managedBuffer.Length; dataLength = (uint)managedBuffer.Length;
// 分配非托管内存 // 分配非托管内存
recData = Marshal.AllocHGlobal(bufferSize); recData = Marshal.AllocHGlobal(bufferSize);
// 初始化非托管内存 // 初始化非托管内存
Marshal.Copy(managedBuffer, 0, recData, bufferSize); Marshal.Copy(managedBuffer, 0, recData, bufferSize);
if (!DllImport.Chk1608Secret(keyNo, recData, ref dataLength).Equals(0)) if (!DllImport.Chk1608Secret(keyNo, recData, ref dataLength).Equals(0))
{ {
MessageBox.Show("密码核对未通过", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("密码核对未通过", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
} }
#region 读取账号类型 #region 读取账号类型
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"PLA", $"{txtExcelName.Text.Trim()}.xls"); string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"PLA", $"{txtExcelName.Text.Trim()}.xls");
string cardType = "AT88SC1608"; string cardType = "AT88SC1608";
string accountType = "0"; // 假设这是一个数字,不需要引号 string accountType = "0"; // 假设这是一个数字,不需要引号
string itemName = "ACCOUNT_TYPE".ToUpper(); string itemName = "ACCOUNT_TYPE".ToUpper();
// 确保条件拼接时,字符串类型字段加引号,数字类型字段保持不变 // 确保条件拼接时,字符串类型字段加引号,数字类型字段保持不变
string sqlCondition = $"WHERE ICCARD_TYPE = '{cardType}' AND ACCOUNT_TYPE = {accountType} AND ITEM_ID = '{itemName}'"; string sqlCondition = $"WHERE ICCARD_TYPE = '{cardType}' AND ACCOUNT_TYPE = {accountType} AND ITEM_ID = '{itemName}'";
// 查询第一行数据 // 查询第一行数据
DataRow findRow = ExcelHelper.ReadExcel2(filePath, txtSheetName.Text.Trim(), sqlCondition)?.Tables[0]?.Rows[0]; DataRow findRow = ExcelHelper.ReadExcel2(filePath, txtSheetName.Text.Trim(), sqlCondition)?.Tables[0]?.Rows[0];
if (findRow == null) if (findRow == null)
{ {
MessageBox.Show("查询数据为null", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("查询数据为null", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
} }
int section_no = Convert.ToInt32(findRow["SECTION_NO"]); int section_no = Convert.ToInt32(findRow["SECTION_NO"]);
int start_pos = Convert.ToInt32(findRow["START_POS"]); int start_pos = Convert.ToInt32(findRow["START_POS"]);
int item_len = Convert.ToInt32(findRow["ITEM_LEN"]); int item_len = Convert.ToInt32(findRow["ITEM_LEN"]);
int numeric_indicator = Convert.ToInt32(findRow["NUMERIC_INDICATOR"]); int numeric_indicator = Convert.ToInt32(findRow["NUMERIC_INDICATOR"]);
int fee_indicator = Convert.ToInt32(findRow["FEE_INDICATOR"]); int fee_indicator = Convert.ToInt32(findRow["FEE_INDICATOR"]);
string item_name = findRow["ITEM_NAME"].ToString(); string item_name = findRow["ITEM_NAME"].ToString();
#endregion #endregion
#region 读卡操作 #region 读卡操作
itemName = "ACCOUNT_INFO_SECTION".ToUpper(); itemName = "ACCOUNT_INFO_SECTION".ToUpper();
// 确保条件拼接时,字符串类型字段加引号,数字类型字段保持不变 // 确保条件拼接时,字符串类型字段加引号,数字类型字段保持不变
sqlCondition = $"WHERE ICCARD_TYPE = '{cardType}' AND ACCOUNT_TYPE = {accountType} AND ITEM_ID = '{itemName}'"; sqlCondition = $"WHERE ICCARD_TYPE = '{cardType}' AND ACCOUNT_TYPE = {accountType} AND ITEM_ID = '{itemName}'";
// 查询第一行数据 // 查询第一行数据
findRow = ExcelHelper.ReadExcel2(filePath, txtSheetName.Text.Trim(), sqlCondition)?.Tables[0]?.Rows[0]; findRow = ExcelHelper.ReadExcel2(filePath, txtSheetName.Text.Trim(), sqlCondition)?.Tables[0]?.Rows[0];
if (findRow == null) if (findRow == null)
{ {
MessageBox.Show("查询数据为null", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("查询数据为null", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
} }
section_no = Convert.ToInt32(findRow["SECTION_NO"]); section_no = Convert.ToInt32(findRow["SECTION_NO"]);
start_pos = Convert.ToInt32(findRow["START_POS"]); start_pos = Convert.ToInt32(findRow["START_POS"]);
item_len = Convert.ToInt32(findRow["ITEM_LEN"]); item_len = Convert.ToInt32(findRow["ITEM_LEN"]);
numeric_indicator = Convert.ToInt32(findRow["NUMERIC_INDICATOR"]); numeric_indicator = Convert.ToInt32(findRow["NUMERIC_INDICATOR"]);
fee_indicator = Convert.ToInt32(findRow["FEE_INDICATOR"]); fee_indicator = Convert.ToInt32(findRow["FEE_INDICATOR"]);
item_name = findRow["ITEM_NAME"].ToString(); item_name = findRow["ITEM_NAME"].ToString();
// 初始长度 // 初始长度
dataLength = (uint)managedBuffer.Length; dataLength = (uint)managedBuffer.Length;
// 分配非托管内存 // 分配非托管内存
recData = Marshal.AllocHGlobal(bufferSize); recData = Marshal.AllocHGlobal(bufferSize);
// 初始化非托管内存 // 初始化非托管内存
Marshal.Copy(managedBuffer, 0, recData, bufferSize); Marshal.Copy(managedBuffer, 0, recData, bufferSize);
dynamic result = new ExpandoObject(); dynamic result = new ExpandoObject();
if (!DllImport.ReadCard((uint)section_no, (uint)start_pos, (uint)item_len, recData, ref dataLength).Equals(0)) if (!DllImport.ReadCard((uint)section_no, (uint)start_pos, (uint)item_len, recData, ref dataLength).Equals(0))
{ {
MessageBox.Show("读取卡片失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("读取卡片失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
} }
else else
{ {
// 从非托管内存读取数据到托管缓冲区 // 从非托管内存读取数据到托管缓冲区
byte[] dataBytes = new byte[dataLength]; byte[] dataBytes = new byte[dataLength];
Marshal.Copy(recData, dataBytes, 0, (int)dataLength); Marshal.Copy(recData, dataBytes, 0, (int)dataLength);
result.InsuranceNo = ReadItem(0, "INSURANCE_NO", dataBytes); result.InsuranceNo = ReadItem(0, "INSURANCE_NO", dataBytes);
result.CardNo = ReadItem(0, "CARD_NO", dataBytes); result.CardNo = ReadItem(0, "CARD_NO", dataBytes);
result.PatientId = ReadItem(0, "PATIENT_ID", dataBytes); result.PatientId = ReadItem(0, "PATIENT_ID", dataBytes);
result.Name = ReadItem(0, "NAME", dataBytes); result.Name = ReadItem(0, "NAME", dataBytes);
result.Sex= ReadItem(0,"SEX", dataBytes); result.Sex= ReadItem(0,"SEX", dataBytes);
result.Birthday = ReadItem(0, "DATE_OF_BIRTH", dataBytes); result.Birthday = ReadItem(0, "DATE_OF_BIRTH", dataBytes);
// 解析出生日期字符串并转换为日期时间类型 // 解析出生日期字符串并转换为日期时间类型
//result.Birthday = $"{birth.Substring(0, 4)}-{birth.Substring(4, 2)}-{birth.Substring(6, 2)}"; //result.Birthday = $"{birth.Substring(0, 4)}-{birth.Substring(4, 2)}-{birth.Substring(6, 2)}";
result.BirthPlace = ReadItem(0, "BIRTH_PLACE", dataBytes); result.BirthPlace = ReadItem(0, "BIRTH_PLACE", dataBytes);
result.Nation = ReadItem(0, "NATION", dataBytes); result.Nation = ReadItem(0, "NATION", dataBytes);
result.MaritalStatus = ReadItem(0, "MARITAL_STATUS", dataBytes); result.MaritalStatus = ReadItem(0, "MARITAL_STATUS", dataBytes);
result.IdentityClass = ReadItem(0, "IDENTITY_CLASS", dataBytes); result.IdentityClass = ReadItem(0, "IDENTITY_CLASS", dataBytes);
// 行政职位 // 行政职位
result.GradeOfDuty = ReadItem(0, "GRADE_OF_DUTY", dataBytes); result.GradeOfDuty = ReadItem(0, "GRADE_OF_DUTY", dataBytes);
// 技术级别 // 技术级别
result.GradeOfTechnic = ReadItem(0, "GRADE_OF_TECHNIC", dataBytes); result.GradeOfTechnic = ReadItem(0, "GRADE_OF_TECHNIC", dataBytes);
// 技术职务 // 技术职务
result.GradeOfTitle = ReadItem(0, "GRADE_OF_TITLE", dataBytes); result.GradeOfTitle = ReadItem(0, "GRADE_OF_TITLE", dataBytes);
result.WorkingStatus = ReadItem(0, "WORKING_STATUS", dataBytes); result.WorkingStatus = ReadItem(0, "WORKING_STATUS", dataBytes);
// 人员基本标准经费 // 人员基本标准经费
result.FundType = ReadItem(0, "FUND_TYPE", dataBytes); result.FundType = ReadItem(0, "FUND_TYPE", dataBytes);
// 人员补助标准经费 // 人员补助标准经费
result.SubsidyType = ReadItem(0, "SUBSIDY_TYPE", dataBytes); result.SubsidyType = ReadItem(0, "SUBSIDY_TYPE", dataBytes);
result.InsuranceType = ReadItem(0, "INSURANCE_TYPE", dataBytes); result.InsuranceType = ReadItem(0, "INSURANCE_TYPE", dataBytes);
result.Unit = ReadItem(0, "unit", dataBytes); result.Unit = ReadItem(0, "unit", dataBytes);
result.DesignatedHospital = ReadItem(0, "DESIGNATED_HOSPITAL", dataBytes); result.DesignatedHospital = ReadItem(0, "DESIGNATED_HOSPITAL", dataBytes);
result.DesignatedPoliclinic = ReadItem(0, "DESIGNATED_POLICLINIC", dataBytes); result.DesignatedPoliclinic = ReadItem(0, "DESIGNATED_POLICLINIC", dataBytes);
result.RelatedInsuranceNo = ReadItem(0, "RELATED_INSURANCE_NO_1", dataBytes); result.RelatedInsuranceNo = ReadItem(0, "RELATED_INSURANCE_NO_1", dataBytes);
result.Relationship = ReadItem(0, "RELATIONSHIP_1", dataBytes); result.Relationship = ReadItem(0, "RELATIONSHIP_1", dataBytes);
result.ExpirationDate = ReadItem(0, "EXPIRATION_DATE", dataBytes); result.ExpirationDate = ReadItem(0, "EXPIRATION_DATE", dataBytes);
// 解析日期字符串并转换为日期时间类型 // 解析日期字符串并转换为日期时间类型
//result.ExpirationDate = $"{expiration.Substring(0, 4)}-{expiration.Substring(4, 2)}-{expiration.Substring(6, 2)}"; //result.ExpirationDate = $"{expiration.Substring(0, 4)}-{expiration.Substring(4, 2)}-{expiration.Substring(6, 2)}";
result.AccountRatedAmount = ReadItem(0, "ACCOUNT_RATED_AMOUNT", dataBytes); result.AccountRatedAmount = ReadItem(0, "ACCOUNT_RATED_AMOUNT", dataBytes);
result.AccountInitialAmount = ReadItem(0, "ACCOUNT_INITIAL_AMOUNT", dataBytes); result.AccountInitialAmount = ReadItem(0, "ACCOUNT_INITIAL_AMOUNT", dataBytes);
result.AccountBalance = ReadItem(0, "ACCOUNT_BALANCE", dataBytes); result.AccountBalance = ReadItem(0, "ACCOUNT_BALANCE", dataBytes);
result.SettleDate = ReadItem(0, "SETTLE_DATE", dataBytes); result.SettleDate = ReadItem(0, "SETTLE_DATE", dataBytes);
// 解析日期字符串并转换为日期时间类型 // 解析日期字符串并转换为日期时间类型
//result.SettleDate = $"{settle.Substring(0, 4)}-{settle.Substring(4, 2)}-{settle.Substring(6, 2)}"; //result.SettleDate = $"{settle.Substring(0, 4)}-{settle.Substring(4, 2)}-{settle.Substring(6, 2)}";
result.AssignCenter = ReadItem(0, "ASSIGN_CENTER", dataBytes); result.AssignCenter = ReadItem(0, "ASSIGN_CENTER", dataBytes);
result.AssignDate = ReadItem(0, "ASSIGN_DATE", dataBytes); result.AssignDate = ReadItem(0, "ASSIGN_DATE", dataBytes);
// 解析日期字符串并转换为日期时间类型 // 解析日期字符串并转换为日期时间类型
//result.AssignDate = $"{assign.Substring(0, 4)}-{assign.Substring(4, 2)}-{assign.Substring(6, 2)}"; //result.AssignDate = $"{assign.Substring(0, 4)}-{assign.Substring(4, 2)}-{assign.Substring(6, 2)}";
} }
rtbOutput.Text=JsonConvert.SerializeObject(result); rtbOutput.Text=JsonConvert.SerializeObject(result);
#endregion #endregion
} }
else else
{ {
MessageBox.Show("设备通讯未打开", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("设备通讯未打开", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Instance.ErrorLogs($"读取卡片函数发生异常", ex); Logger.Instance.ErrorLogs($"读取卡片函数发生异常", ex);
} }
} }
/// <summary> /// <summary>
/// 读取节点字段 /// 读取节点字段
/// </summary> /// </summary>
/// <param name="accountType">账户类型</param> /// <param name="accountType">账户类型</param>
/// <param name="itemName">字段</param> /// <param name="itemName">字段</param>
/// <param name="strData">数据</param> /// <param name="strData">数据</param>
/// <returns></returns> /// <returns></returns>
private String ReadItem(int accountType,string itemName, byte[] strData) private String ReadItem(int accountType,string itemName, byte[] strData)
{ {
String itemValue = String.Empty; String itemValue = String.Empty;
try try
{ {
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"PLA", $"{txtExcelName.Text.Trim()}.xls"); string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"PLA", $"{txtExcelName.Text.Trim()}.xls");
string cardType = "AT88SC1608"; string cardType = "AT88SC1608";
// 确保条件拼接时,字符串类型字段加引号,数字类型字段保持不变 // 确保条件拼接时,字符串类型字段加引号,数字类型字段保持不变
string sqlCondition = $"WHERE ICCARD_TYPE = '{cardType}' AND ACCOUNT_TYPE = {accountType.ToString()} AND ITEM_ID = '{itemName.ToUpper()}'"; string sqlCondition = $"WHERE ICCARD_TYPE = '{cardType}' AND ACCOUNT_TYPE = {accountType.ToString()} AND ITEM_ID = '{itemName.ToUpper()}'";
// 查询第一行数据 // 查询第一行数据
DataRow findRow = ExcelHelper.ReadExcel2(filePath, txtSheetName.Text.Trim(), sqlCondition)?.Tables[0]?.Rows[0]; DataRow findRow = ExcelHelper.ReadExcel2(filePath, txtSheetName.Text.Trim(), sqlCondition)?.Tables[0]?.Rows[0];
if (findRow == null) if (findRow == null)
{ {
MessageBox.Show("查询数据为null", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("查询数据为null", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return itemValue; return itemValue;
} }
int section_no = Convert.ToInt32(findRow["SECTION_NO"]); int section_no = Convert.ToInt32(findRow["SECTION_NO"]);
int start_pos = Convert.ToInt32(findRow["START_POS"]); int start_pos = Convert.ToInt32(findRow["START_POS"]);
int item_len = Convert.ToInt32(findRow["ITEM_LEN"]); int item_len = Convert.ToInt32(findRow["ITEM_LEN"]);
int numeric_indicator = Convert.ToInt32(findRow["NUMERIC_INDICATOR"]); int numeric_indicator = Convert.ToInt32(findRow["NUMERIC_INDICATOR"]);
int fee_indicator = Convert.ToInt32(findRow["FEE_INDICATOR"]); int fee_indicator = Convert.ToInt32(findRow["FEE_INDICATOR"]);
string item_name = findRow["ITEM_NAME"].ToString(); string item_name = findRow["ITEM_NAME"].ToString();
// 创建一个新的字节数组来存放截取的数据 // 创建一个新的字节数组来存放截取的数据
byte[] subArray = new byte[item_len]; byte[] subArray = new byte[item_len];
// 使用 Array.Copy 截取子数组 // 使用 Array.Copy 截取子数组
Array.Copy(strData, start_pos, subArray, 0, item_len); Array.Copy(strData, start_pos, subArray, 0, item_len);
byte[] ls_ttc = new byte[4]; byte[] ls_ttc = new byte[4];
if (numeric_indicator.Equals(1)) if (numeric_indicator.Equals(1))
{ {
for (int i = 0; i < ls_ttc.Length; i++) for (int i = 0; i < ls_ttc.Length; i++)
{ {
if (i < item_len) if (i < item_len)
{ {
ls_ttc[i] = subArray[i]; ls_ttc[i] = subArray[i];
continue; continue;
} }
} }
ulong temp = 0; ulong temp = 0;
if (DllImport.HexByteToLong(ls_ttc, ref temp) < 0) if (DllImport.HexByteToLong(ls_ttc, ref temp) < 0)
{ {
itemValue = string.Empty; itemValue = string.Empty;
} }
if (fee_indicator.Equals(1)) if (fee_indicator.Equals(1))
{ {
decimal ldItem = temp / 100m; // 将长整型转换为Decimal并除以100 decimal ldItem = temp / 100m; // 将长整型转换为Decimal并除以100
itemValue = ldItem.ToString("F2"); // 格式化为两位小数的字符串 itemValue = ldItem.ToString("F2"); // 格式化为两位小数的字符串
} }
else else
{ {
itemValue = temp.ToString(); itemValue = temp.ToString();
} }
} }
else else
{ {
itemValue = Encoding.GetEncoding("GB2312").GetString(subArray).TrimEnd('\0').Trim(); itemValue = Encoding.GetEncoding("GB2312").GetString(subArray).TrimEnd('\0').Trim();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Instance.ErrorLogs($"ReadItem函数发生异常", ex); Logger.Instance.ErrorLogs($"ReadItem函数发生异常", ex);
} }
return itemValue; return itemValue;
} }
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata"> <xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="data"> <xsd:element name="data">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:schema> </xsd:schema>
<resheader name="resmimetype"> <resheader name="resmimetype">
<value>text/microsoft-resx</value> <value>text/microsoft-resx</value>
</resheader> </resheader>
<resheader name="version"> <resheader name="version">
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
</root> </root>
\ No newline at end of file
using System; using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using log4net; using log4net;
using log4net.Config; using log4net.Config;
using log4net.Repository; using log4net.Repository;
namespace MilitaryGuaranteeCard namespace MilitaryGuaranteeCard
{ {
/// <summary> /// <summary>
/// 日志 /// 日志
/// </summary> /// </summary>
public class Logger public class Logger
{ {
#region LazyLoading #region LazyLoading
private static readonly Lazy<Logger> Lazy = new Lazy<Logger>(() => new Logger()); private static readonly Lazy<Logger> Lazy = new Lazy<Logger>(() => new Logger());
public static Logger Instance => Lazy.Value; public static Logger Instance => Lazy.Value;
#endregion #endregion
#region Define #region Define
/// <summary> /// <summary>
/// 将消息记录到 log4net 框架中 /// 将消息记录到 log4net 框架中
/// </summary> /// </summary>
private ILog _logger; private ILog _logger;
/// <summary> /// <summary>
/// 存储库 /// 存储库
/// </summary> /// </summary>
private readonly ILoggerRepository _repository; private readonly ILoggerRepository _repository;
#endregion #endregion
/// <summary> /// <summary>
/// 构造器 /// 构造器
/// </summary> /// </summary>
public Logger() public Logger()
{ {
// 日志目录 // 日志目录
String logDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"); String logDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
// 手动创建各个子文件夹 // 手动创建各个子文件夹
string[] subDirectories = { "NormalLogs", "ServiceLogs", "WarnLogs", "ErrorLogs" }; string[] subDirectories = { "NormalLogs", "ServiceLogs", "WarnLogs", "ErrorLogs" };
foreach (var subDir in subDirectories) foreach (var subDir in subDirectories)
{ {
string fullPath = Path.Combine(logDirectory, subDir); string fullPath = Path.Combine(logDirectory, subDir);
if (!Directory.Exists(fullPath)) if (!Directory.Exists(fullPath))
{ {
Directory.CreateDirectory(fullPath); Directory.CreateDirectory(fullPath);
} }
} }
// 获取当前应用程序的log4net日志存储库 // 获取当前应用程序的log4net日志存储库
_repository = LogManager.CreateRepository("PLA"); _repository = LogManager.CreateRepository("PLA");
// 使用指定的配置文件配置 // 使用指定的配置文件配置
XmlConfigurator.Configure(_repository, new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config"))); XmlConfigurator.Configure(_repository, new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config")));
} }
#region Methods #region Methods
/// <summary> /// <summary>
/// 普通日志 /// 普通日志
/// </summary> /// </summary>
/// <param name="message">消息</param> /// <param name="message">消息</param>
/// <param name="exception">执行过程中发生的错误</param> /// <param name="exception">执行过程中发生的错误</param>
public void NormalLogs(String message, Exception exception) public void NormalLogs(String message, Exception exception)
{ {
//检索或创建命名记录器 //检索或创建命名记录器
_logger = LogManager.GetLogger(_repository.Name, "NormalLogs"); _logger = LogManager.GetLogger(_repository.Name, "NormalLogs");
if (exception != null) if (exception != null)
{ {
_logger.Info(message, exception); _logger.Info(message, exception);
} }
else else
{ {
_logger.Info(message); _logger.Info(message);
} }
} }
/// <summary> /// <summary>
/// 服务日志 /// 服务日志
/// </summary> /// </summary>
/// <param name="message">消息</param> /// <param name="message">消息</param>
/// <param name="exception">执行过程中发生的错误</param> /// <param name="exception">执行过程中发生的错误</param>
public void ServiceLogs(String message, Exception exception) public void ServiceLogs(String message, Exception exception)
{ {
//检索或创建命名记录器 //检索或创建命名记录器
_logger = LogManager.GetLogger(_repository.Name, "ServiceLogs"); _logger = LogManager.GetLogger(_repository.Name, "ServiceLogs");
if (exception != null) if (exception != null)
{ {
_logger.Info(message, exception); _logger.Info(message, exception);
} }
else else
{ {
_logger.Info(message); _logger.Info(message);
} }
} }
/// <summary> /// <summary>
/// 警告日志 /// 警告日志
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
/// <param name="exception"></param> /// <param name="exception"></param>
public void WarnLogs(String message, Exception exception) public void WarnLogs(String message, Exception exception)
{ {
// 检索或创建命名记录器 // 检索或创建命名记录器
_logger = LogManager.GetLogger(_repository.Name, "WarnLogs"); _logger = LogManager.GetLogger(_repository.Name, "WarnLogs");
if (exception!=null) if (exception!=null)
{ {
_logger.Warn(message,exception); _logger.Warn(message,exception);
} }
else else
{ {
_logger.Warn(message); _logger.Warn(message);
} }
} }
/// <summary> /// <summary>
/// 错误日志 /// 错误日志
/// </summary> /// </summary>
/// <param name="message">消息</param> /// <param name="message">消息</param>
/// <param name="exception">执行过程中发生的错误</param> /// <param name="exception">执行过程中发生的错误</param>
public void ErrorLogs(String message, Exception exception) public void ErrorLogs(String message, Exception exception)
{ {
//检索或创建命名记录器 //检索或创建命名记录器
_logger = LogManager.GetLogger(_repository.Name, "ErrorLogs"); _logger = LogManager.GetLogger(_repository.Name, "ErrorLogs");
if (exception != null) if (exception != null)
{ {
_logger.Error(message, exception); _logger.Error(message, exception);
} }
else else
{ {
_logger.Error(message); _logger.Error(message);
} }
} }
#endregion #endregion
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EC8375E3-F9F7-4486-B856-D4515B2286A6}</ProjectGuid> <ProjectGuid>{EC8375E3-F9F7-4486-B856-D4515B2286A6}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>MilitaryGuaranteeCard</RootNamespace> <RootNamespace>MilitaryGuaranteeCard</RootNamespace>
<AssemblyName>MilitaryGuaranteeCard</AssemblyName> <AssemblyName>MilitaryGuaranteeCard</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks> <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ClosedXML, Version=0.64.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b, processorArchitecture=MSIL"> <Reference Include="ClosedXML, Version=0.64.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b, processorArchitecture=MSIL">
<HintPath>..\packages\ClosedXML.0.64.0\lib\net40-client\ClosedXML.dll</HintPath> <HintPath>..\packages\ClosedXML.0.64.0\lib\net40-client\ClosedXML.dll</HintPath>
</Reference> </Reference>
<Reference Include="DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.1.0\lib\DocumentFormat.OpenXml.dll</HintPath> <HintPath>..\packages\DocumentFormat.OpenXml.1.0\lib\DocumentFormat.OpenXml.dll</HintPath>
</Reference> </Reference>
<Reference Include="log4net, Version=2.0.17.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.17.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.17\lib\net40\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.17\lib\net40\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Deployment" /> <Reference Include="System.Deployment" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DllImport.cs" /> <Compile Include="DllImport.cs" />
<Compile Include="ExcelHelper.cs" /> <Compile Include="ExcelHelper.cs" />
<Compile Include="Form1.cs"> <Compile Include="Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Form1.Designer.cs"> <Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Logger.cs" /> <Compile Include="Logger.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<None Include="app.config" /> <None Include="app.config" />
<None Include="log4net.config"> <None Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="PLA\medical_card_schedule.xls"> <None Include="PLA\medical_card_schedule.xls">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
<Compile Include="Properties\Settings.Designer.cs"> <Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<ItemGroup> <ItemGroup>
<Content Include="PLA\RW_VC_MMSC.dll"> <Content Include="PLA\RW_VC_MMSC.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="PLA\RW_VC_MMSC.pdb"> <Content Include="PLA\RW_VC_MMSC.pdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
namespace MilitaryGuaranteeCard namespace MilitaryGuaranteeCard
{ {
internal static class Program internal static class Program
{ {
/// <summary> /// <summary>
/// 应用程序的主入口点。 /// 应用程序的主入口点。
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); Application.Run(new Form1());
} }
} }
} }
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下 // 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改 // 控制。更改这些特性值可修改
// 与程序集关联的信息。 // 与程序集关联的信息。
[assembly: AssemblyTitle("MilitaryGuaranteeCard")] [assembly: AssemblyTitle("MilitaryGuaranteeCard")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("P R C")] [assembly: AssemblyCompany("P R C")]
[assembly: AssemblyProduct("MilitaryGuaranteeCard")] [assembly: AssemblyProduct("MilitaryGuaranteeCard")]
[assembly: AssemblyCopyright("Copyright © P R C 2024")] [assembly: AssemblyCopyright("Copyright © P R C 2024")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型 // 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。 //请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("ec8375e3-f9f7-4486-b856-d4515b2286a6")] [assembly: Guid("ec8375e3-f9f7-4486-b856-d4515b2286a6")]
// 程序集的版本信息由下列四个值组成: // 程序集的版本信息由下列四个值组成:
// //
// 主版本 // 主版本
// 次版本 // 次版本
// 生成号 // 生成号
// 修订号 // 修订号
// //
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
// 运行时版本:4.0.30319.42000 // 运行时版本:4.0.30319.42000
// //
// 对此文件的更改可能会导致不正确的行为,并且如果 // 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。 // 重新生成代码,这些更改将会丢失。
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace MilitaryGuaranteeCard.Properties { namespace MilitaryGuaranteeCard.Properties {
using System; using System;
/// <summary> /// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。 /// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary> /// </summary>
// 此类是由 StronglyTypedResourceBuilder // 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。 // (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() { internal Resources() {
} }
/// <summary> /// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。 /// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MilitaryGuaranteeCard.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MilitaryGuaranteeCard.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
} }
} }
/// <summary> /// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对 /// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。 /// 使用此强类型资源类的所有资源查找执行重写。
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { internal static global::System.Globalization.CultureInfo Culture {
get { get {
return resourceCulture; return resourceCulture;
} }
set { set {
resourceCulture = value; resourceCulture = value;
} }
} }
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter : System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata"> <xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="data"> <xsd:element name="data">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:schema> </xsd:schema>
<resheader name="resmimetype"> <resheader name="resmimetype">
<value>text/microsoft-resx</value> <value>text/microsoft-resx</value>
</resheader> </resheader>
<resheader name="version"> <resheader name="version">
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
</root> </root>
\ No newline at end of file
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
// 运行时版本:4.0.30319.42000 // 运行时版本:4.0.30319.42000
// //
// 对此文件的更改可能会导致不正确的行为,并且如果 // 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。 // 重新生成代码,这些更改将会丢失。
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace MilitaryGuaranteeCard.Properties { namespace MilitaryGuaranteeCard.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default { public static Settings Default {
get { get {
return defaultInstance; return defaultInstance;
} }
} }
} }
} }
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles> <Profiles>
<Profile Name="(Default)" /> <Profile Name="(Default)" />
</Profiles> </Profiles>
<Settings /> <Settings />
</SettingsFile> </SettingsFile>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections> </configSections>
<!-- This section contains the log4net configuration settings --> <!-- This section contains the log4net configuration settings -->
<log4net> <log4net>
<appender name="NormalAppender" type="log4net.Appender.RollingFileAppender"> <appender name="NormalAppender" type="log4net.Appender.RollingFileAppender">
<!--日志文件路径,会自动创建--> <!--日志文件路径,会自动创建-->
<file value="Logs/NormalLogs/" /> <file value="Logs/NormalLogs/" />
<!--编码格式:UTF-8 --> <!--编码格式:UTF-8 -->
<param name="Encoding" value="utf-8" /> <param name="Encoding" value="utf-8" />
<!--是否是向文件中追加日志--> <!--是否是向文件中追加日志-->
<param name="AppendToFile" value="true" /> <param name="AppendToFile" value="true" />
<!--log备份文件最大数量,超过设置数量会滚动覆盖之前的日志--> <!--log备份文件最大数量,超过设置数量会滚动覆盖之前的日志-->
<param name="MaxSizeRollBackups" value="5" /> <param name="MaxSizeRollBackups" value="5" />
<!--最大文件大小(KB/MB/GB)--> <!--最大文件大小(KB/MB/GB)-->
<param name="MaximumFileSize" value="1GB" /> <param name="MaximumFileSize" value="1GB" />
<!--日志文件名是否是固定不变的--> <!--日志文件名是否是固定不变的-->
<param name="StaticLogFileName" value="false" /> <param name="StaticLogFileName" value="false" />
<!--日志文件名格式为:2018-08-31.log--> <!--日志文件名格式为:2018-08-31.log-->
<datePattern value="yyyy-MM-dd'.log'" /> <datePattern value="yyyy-MM-dd'.log'" />
<!--日志滚动方式:混合方式(文件大小和日期)--> <!--日志滚动方式:混合方式(文件大小和日期)-->
<param name="RollingStyle" value="Composite" /> <param name="RollingStyle" value="Composite" />
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %message%newline" /> <conversionPattern value="%date [%thread] %-5level %message%newline" />
</layout> </layout>
</appender> </appender>
<appender name="ServiceAppender" type="log4net.Appender.RollingFileAppender"> <appender name="ServiceAppender" type="log4net.Appender.RollingFileAppender">
<!--日志文件路径,会自动创建--> <!--日志文件路径,会自动创建-->
<file value="Logs/ServiceLogs/" /> <file value="Logs/ServiceLogs/" />
<param name="Encoding" value="utf-8" /> <param name="Encoding" value="utf-8" />
<!--是否是向文件中追加日志--> <!--是否是向文件中追加日志-->
<param name="AppendToFile" value="true" /> <param name="AppendToFile" value="true" />
<!--log备份文件最大数量,超过设置数量会滚动覆盖之前的日志--> <!--log备份文件最大数量,超过设置数量会滚动覆盖之前的日志-->
<param name="MaxSizeRollBackups" value="5" /> <param name="MaxSizeRollBackups" value="5" />
<!--最大文件大小(KB/MB/GB)--> <!--最大文件大小(KB/MB/GB)-->
<param name="MaximumFileSize" value="1GB" /> <param name="MaximumFileSize" value="1GB" />
<!--日志文件名是否是固定不变的--> <!--日志文件名是否是固定不变的-->
<param name="StaticLogFileName" value="false" /> <param name="StaticLogFileName" value="false" />
<!--日志文件名格式为:2018-08-31.log--> <!--日志文件名格式为:2018-08-31.log-->
<datePattern value="yyyy-MM-dd'.log'" /> <datePattern value="yyyy-MM-dd'.log'" />
<!--日志滚动方式:混合方式(文件大小和日期)--> <!--日志滚动方式:混合方式(文件大小和日期)-->
<param name="RollingStyle" value="Composite" /> <param name="RollingStyle" value="Composite" />
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %message%newline" /> <conversionPattern value="%date [%thread] %-5level %message%newline" />
</layout> </layout>
</appender> </appender>
<appender name="WarnAppender" type="log4net.Appender.RollingFileAppender"> <appender name="WarnAppender" type="log4net.Appender.RollingFileAppender">
<!--日志文件路径,会自动创建--> <!--日志文件路径,会自动创建-->
<file value="Logs/WarnLogs/" /> <file value="Logs/WarnLogs/" />
<!--编码:UTF-8--> <!--编码:UTF-8-->
<param name="Encoding" value="utf-8" /> <param name="Encoding" value="utf-8" />
<!--是否是向文件中追加日志--> <!--是否是向文件中追加日志-->
<param name="AppendToFile" value="true" /> <param name="AppendToFile" value="true" />
<!--log备份文件最大数量,超过设置数量会滚动覆盖之前的日志--> <!--log备份文件最大数量,超过设置数量会滚动覆盖之前的日志-->
<param name="MaxSizeRollBackups" value="5" /> <param name="MaxSizeRollBackups" value="5" />
<!--最大文件大小(KB/MB/GB)--> <!--最大文件大小(KB/MB/GB)-->
<param name="MaximumFileSize" value="1GB" /> <param name="MaximumFileSize" value="1GB" />
<!--日志文件名是否是固定不变的--> <!--日志文件名是否是固定不变的-->
<param name="StaticLogFileName" value="false" /> <param name="StaticLogFileName" value="false" />
<!--日志文件名格式为:2018-08-31.log--> <!--日志文件名格式为:2018-08-31.log-->
<datePattern value="yyyy-MM-dd'.log'" /> <datePattern value="yyyy-MM-dd'.log'" />
<!--日志滚动方式:混合方式(文件大小和日期)--> <!--日志滚动方式:混合方式(文件大小和日期)-->
<param name="RollingStyle" value="Composite" /> <param name="RollingStyle" value="Composite" />
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %message%newline" /> <conversionPattern value="%date [%thread] %-5level %message%newline" />
</layout> </layout>
</appender> </appender>
<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender"> <appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender">
<!--日志文件路径,会自动创建--> <!--日志文件路径,会自动创建-->
<file value="Logs/ErrorLogs/" /> <file value="Logs/ErrorLogs/" />
<!--编码:UTF-8--> <!--编码:UTF-8-->
<param name="Encoding" value="utf-8" /> <param name="Encoding" value="utf-8" />
<!--是否是向文件中追加日志--> <!--是否是向文件中追加日志-->
<param name="AppendToFile" value="true" /> <param name="AppendToFile" value="true" />
<!--log备份文件最大数量,超过设置数量会滚动覆盖之前的日志--> <!--log备份文件最大数量,超过设置数量会滚动覆盖之前的日志-->
<param name="MaxSizeRollBackups" value="5" /> <param name="MaxSizeRollBackups" value="5" />
<!--最大文件大小(KB/MB/GB)--> <!--最大文件大小(KB/MB/GB)-->
<param name="MaximumFileSize" value="1GB" /> <param name="MaximumFileSize" value="1GB" />
<!--日志文件名是否是固定不变的--> <!--日志文件名是否是固定不变的-->
<param name="StaticLogFileName" value="false" /> <param name="StaticLogFileName" value="false" />
<!--日志文件名格式为:2018-08-31.log--> <!--日志文件名格式为:2018-08-31.log-->
<datePattern value="yyyy-MM-dd'.log'" /> <datePattern value="yyyy-MM-dd'.log'" />
<!--日志滚动方式:混合方式(文件大小和日期)--> <!--日志滚动方式:混合方式(文件大小和日期)-->
<param name="RollingStyle" value="Composite" /> <param name="RollingStyle" value="Composite" />
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %message%newline" /> <conversionPattern value="%date [%thread] %-5level %message%newline" />
</layout> </layout>
</appender> </appender>
<!-- Setup the root category, add the appenders and set the default level --> <!-- Setup the root category, add the appenders and set the default level -->
<logger name="NormalLogs"> <logger name="NormalLogs">
<level value="ALL" /> <level value="ALL" />
<appender-ref ref="NormalAppender" /> <appender-ref ref="NormalAppender" />
</logger> </logger>
<logger name="ServiceLogs"> <logger name="ServiceLogs">
<level value="ALL" /> <level value="ALL" />
<appender-ref ref="ServiceAppender" /> <appender-ref ref="ServiceAppender" />
</logger> </logger>
<logger name="WarnLogs"> <logger name="WarnLogs">
<level value="ALL" /> <level value="ALL" />
<appender-ref ref="WarnAppender" /> <appender-ref ref="WarnAppender" />
</logger> </logger>
<logger name="ErrorLogs"> <logger name="ErrorLogs">
<level value="ALL" /> <level value="ALL" />
<appender-ref ref="ErrorAppender" /> <appender-ref ref="ErrorAppender" />
</logger> </logger>
</log4net> </log4net>
</configuration> </configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="ClosedXML" version="0.64.0" targetFramework="net40" /> <package id="ClosedXML" version="0.64.0" targetFramework="net40" />
<package id="DocumentFormat.OpenXml" version="1.0" targetFramework="net40" /> <package id="DocumentFormat.OpenXml" version="1.0" targetFramework="net40" />
<package id="log4net" version="2.0.17" targetFramework="net40" /> <package id="log4net" version="2.0.17" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" /> <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
</packages> </packages>
\ No newline at end of file
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.12.35506.116 VisualStudioVersion = 17.12.35506.116
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MilitaryGuaranteeCard", "MilitaryGuaranteeCard\MilitaryGuaranteeCard.csproj", "{EC8375E3-F9F7-4486-B856-D4515B2286A6}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MilitaryGuaranteeCard", "MilitaryGuaranteeCard\MilitaryGuaranteeCard.csproj", "{EC8375E3-F9F7-4486-B856-D4515B2286A6}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC8375E3-F9F7-4486-B856-D4515B2286A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EC8375E3-F9F7-4486-B856-D4515B2286A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC8375E3-F9F7-4486-B856-D4515B2286A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC8375E3-F9F7-4486-B856-D4515B2286A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC8375E3-F9F7-4486-B856-D4515B2286A6}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC8375E3-F9F7-4486-B856-D4515B2286A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC8375E3-F9F7-4486-B856-D4515B2286A6}.Release|Any CPU.Build.0 = Release|Any CPU {EC8375E3-F9F7-4486-B856-D4515B2286A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment