SVN r1134
SVN-Revision: r1134
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using Lskj.Business;
|
||||
using Lskj.Model;
|
||||
using Lskj.Util;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.PubGetChipInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// c#库被调用统一接口类
|
||||
/// </summary>
|
||||
public sealed class DllBaseClass : IForm
|
||||
{
|
||||
public DllBaseClass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DllBaseClass(string[] obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
DynamicGetChipInfoModel getChipInfoModel = new DynamicGetChipInfoModel(obj);
|
||||
FrmMain main = new FrmMain();
|
||||
this.SubForm = main;
|
||||
main.GetChipInfoModel = getChipInfoModel;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteError("Lskj.PubGetChipInfo.dll--参数错误-->" + obj.ToString(), ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 窗口
|
||||
/// </summary>
|
||||
public Form SubForm { get; set; }
|
||||
/// <summary>
|
||||
/// 入口模型
|
||||
/// </summary>
|
||||
public class DynamicGetChipInfoModel : DynamicModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 芯片类型,1:PRM芯片,2:授权芯片
|
||||
/// </summary>
|
||||
public string ChipType;
|
||||
/// <summary>
|
||||
/// 处理sql
|
||||
/// </summary>
|
||||
public string AfterSql;
|
||||
public override string[] OtherParams()
|
||||
{
|
||||
return this.Params;
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化默认参数(1.标题、2、用户ID、3.用户名、4.权限、5.模块编号、6.菜单ID)
|
||||
/// </summary>
|
||||
/// <param name="args">The arguments.</param>
|
||||
public DynamicGetChipInfoModel(string[] args)
|
||||
: base(args)
|
||||
{
|
||||
// 右键菜单打开的模块没有moduleId,部分特殊模块没有moduleId比如添加界面.
|
||||
if (!string.IsNullOrEmpty(args[5]))
|
||||
{
|
||||
base.ModuleId = Convert.ToInt32(args[5]);
|
||||
}
|
||||
if (args.Length > 6 && !string.IsNullOrWhiteSpace(args[6]))
|
||||
{
|
||||
base.ModuleCode = args[6];
|
||||
}
|
||||
if (args.Length > 7 && !string.IsNullOrWhiteSpace(args[7]))
|
||||
{
|
||||
this.ChipType = args[7];
|
||||
}
|
||||
if (args.Length > 8 && !string.IsNullOrWhiteSpace(args[8]))
|
||||
{
|
||||
this.AfterSql = ar
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
|
||||
namespace Lskj.PubGetChipInfo
|
||||
{
|
||||
partial class FrmMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btn_Read = new DevExpress.XtraEditors.SimpleButton();
|
||||
this.btn_Ok = new DevExpress.XtraEditors.SimpleButton();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.com_Bps = new DevExpress.XtraEditors.ComboBoxEdit();
|
||||
this.lb_Bps = new System.Windows.Forms.Label();
|
||||
this.com_PortNum = new DevExpress.XtraEditors.ComboBoxEdit();
|
||||
this.lb_PortNum = new System.Windows.Forms.Label();
|
||||
this.lb_info = new System.Windows.Forms.Label();
|
||||
this.txtEdit_info = new DevExpress.XtraEditors.TextEdit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.com_Bps.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.com_PortNum.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtEdit_info.Properties)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btn_Read
|
||||
//
|
||||
this.btn_Read.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btn_Read.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btn_Read.Appearance.Options.UseFont = true;
|
||||
this.btn_Read.Location = new System.Drawing.Point(280, 70);
|
||||
this.btn_Read.Name = "btn_Read";
|
||||
this.btn_Read.Size = new System.Drawing.Size(72, 26);
|
||||
this.btn_Read.TabIndex = 39;
|
||||
this.btn_Read.Text = "读取(E)";
|
||||
//
|
||||
// btn_Ok
|
||||
//
|
||||
this.btn_Ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btn_Ok.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btn_Ok.Appearance.Options.UseFont = true;
|
||||
this.btn_Ok.Location = new System.Drawing.Point(358, 70);
|
||||
this.btn_Ok.Name = "btn_Ok";
|
||||
this.btn_Ok.Size = new System.Drawing.Size(72, 26);
|
||||
this.btn_Ok.TabIndex = 38;
|
||||
this.btn_Ok.Text = "确认(Y)";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(407, 14);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(23, 12);
|
||||
this.label2.TabIndex = 6;
|
||||
this.label2.Text = "bps";
|
||||
//
|
||||
// com_Bps
|
||||
//
|
||||
this.com_Bps.Location = new System.Drawing.Point(276, 9);
|
||||
this.com_Bps.Name = "com_Bps";
|
||||
this.com_Bps.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
|
||||
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
|
||||
this.com_Bps.Properties.DropDownRows = 8;
|
||||
this.com_Bps.Properties.Items.AddRange(new object[] {
|
||||
"115200",
|
||||
"19200"});
|
||||
this.com_Bps.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
|
||||
this.com_Bps.Size = new System.Drawing.Size(125, 20);
|
||||
this.com_Bps.TabIndex = 5;
|
||||
//
|
||||
// lb_Bps
|
||||
//
|
||||
this.lb_Bps.AutoSize = true;
|
||||
this.lb_Bps.Location = new System.Drawing.Point(217, 14);
|
||||
this.lb_Bps.Name = "lb_Bps";
|
||||
this.lb_Bps.Size = new System.Drawing.Size(53, 12);
|
||||
this.lb_Bps.TabIndex = 4;
|
||||
this.lb_Bps.Text = "波特率:";
|
||||
//
|
||||
// com_PortNum
|
||||
//
|
||||
this.com_PortNum.Location = new System.Drawing.Point(71, 9);
|
||||
this.com_PortNum.Name = "com_PortNum";
|
||||
this.com_PortNum.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
|
||||
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
|
||||
this.com_PortNum.Properties.DropDownRows = 8;
|
||||
this.com_PortNum.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
|
||||
this.com_PortNum.Size = new System.Drawing.Size(125, 20);
|
||||
this.com_PortNum.TabIndex = 3;
|
||||
//
|
||||
// lb_PortNum
|
||||
//
|
||||
this.lb_PortNum.AutoSize = true;
|
||||
this.lb_PortNum.Location = new System.Drawing.Point(12, 14);
|
||||
this.lb_PortNum.Name = "lb_PortNum";
|
||||
this.lb_PortNum.Size = new System.Drawing.Size(53, 12);
|
||||
this.lb_PortNum.TabIndex = 2;
|
||||
this.lb_PortNum.Text = "串口号:";
|
||||
//
|
||||
// lb_info
|
||||
//
|
||||
this.lb_info.AutoSize = true;
|
||||
this.lb_info.Location = new System.Drawing.Point(12, 45);
|
||||
this.lb_info.Name = "lb_info";
|
||||
this.lb_info.Size = new System.Drawing.Size(77, 12);
|
||||
this.lb_info.TabIndex = 40;
|
||||
this.lb_info.Text = "授权芯片号:";
|
||||
//
|
||||
// txtEdit_info
|
||||
//
|
||||
this.txtEdit_info.Location = new System.Drawing.Point(95, 40);
|
||||
this.txtEdit_info.Name = "txtEdit_info";
|
||||
this.txtEdit_info.Properties.ReadOnly = true;
|
||||
this.txtEdit_info.Size = new System.Drawing.Size(335, 20);
|
||||
this.txtEdit_info.TabIndex = 41;
|
||||
//
|
||||
// FrmMain
|
||||
//
|
||||
this.Appearance.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.Appearance.Options.UseBackColor = true;
|
||||
this.Appearance.Options.UseFont = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(445, 104);
|
||||
this.Controls.Add(this.txtEdit_info);
|
||||
this.Controls.Add(this.lb_info);
|
||||
this.Controls.Add(this.btn_Read);
|
||||
this.Controls.Add(this.btn_Ok);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.com_Bps);
|
||||
this.Controls.Add(this.lb_Bps);
|
||||
this.Controls.Add(this.com_PortNum);
|
||||
this.Controls.Add(this.lb_PortNum);
|
||||
this.MaximizeBox = false
|
||||
@@ -0,0 +1,371 @@
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Control;
|
||||
using Lskj.Core;
|
||||
using Lskj.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using static Lskj.PubGetChipInfo.DllBaseClass;
|
||||
|
||||
namespace Lskj.PubGetChipInfo
|
||||
{
|
||||
public partial class FrmMain : BaseForm
|
||||
{
|
||||
public DynamicGetChipInfoModel GetChipInfoModel;
|
||||
public SerialPort oneSerialPort = new SerialPort();
|
||||
public Thread m_thread = null;
|
||||
public string m_strCom = "";
|
||||
public int m_nBaud = 0;
|
||||
public bool m_bQuit = false;
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Load += OnFrmMainLoad;
|
||||
this.btn_Read.Click += OnBtnReadClick;
|
||||
this.btn_Ok.Click += OnBtnOkClick;
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载数据
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnFrmMainLoad(object sender, EventArgs e)
|
||||
{
|
||||
if (GetChipInfoModel.ChipType.Equals("1"))
|
||||
{
|
||||
lb_info.Text = "PRM序列号:";
|
||||
}
|
||||
else if (GetChipInfoModel.ChipType.Equals("2"))
|
||||
{
|
||||
lb_info.Text = "授权芯片号:";
|
||||
}
|
||||
string[] arryPort = SerialPort.GetPortNames();
|
||||
foreach (string item in arryPort)
|
||||
{
|
||||
com_PortNum.Properties.Items.Add(item);
|
||||
}
|
||||
//设置串口
|
||||
string portNum = IniHelper.Read(string.Format("PubGetChipInfo_PortNum_{0}", this.GetChipInfoModel.ModuleCode));
|
||||
this.com_PortNum.Text = portNum;
|
||||
this.com_PortNum.SelectedIndexChanged += OnPortNumSelectedIndexChanged;
|
||||
//设置波特率
|
||||
string bps = IniHelper.Read(string.Format("PubGetChipInfo_Bps_{0}", this.GetChipInfoModel.ModuleCode));
|
||||
this.com_Bps.Text = bps;
|
||||
this.com_Bps.SelectedIndexChanged += OnBpsSelectedIndexChanged;
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取按钮点击
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBtnReadClick(object sender, EventArgs e)
|
||||
{
|
||||
if (GetChipInfoModel.ChipType.Equals("1"))
|
||||
{
|
||||
m_strCom = com_PortNum.Text;
|
||||
int.TryParse(com_Bps.Text, out m_nBaud);
|
||||
if (m_strCom.Length <= 0 || m_nBaud <= 0)
|
||||
{
|
||||
MessageUtil.Show("串口参数不全,请检查后重试!", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
if (m_thread != null && m_thread.IsAlive == true)
|
||||
{
|
||||
MessageUtil.Show("请倒计时结束后再重新读取!", MessageBoxButtons.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
txtEdit_info.Text = "";
|
||||
m_bQuit = false;
|
||||
m_thread = new Thread(DoPRMAction);
|
||||
m_thread.Start();
|
||||
}
|
||||
}
|
||||
else if (GetChipInfoModel.ChipType.Equals("2"))
|
||||
{
|
||||
m_strCom = com_PortNum.Text;
|
||||
int.TryParse(com_Bps.Text, out m_nBaud);
|
||||
if (m_strCom.Length <= 0 || m_nBaud <= 0)
|
||||
{
|
||||
MessageUtil.Show("串口参数不全,请检查后重试!", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
if (m_thread != null && m_bQuit == false)
|
||||
{
|
||||
MessageUtil.Show("请倒计时结束后再重新读取!", MessageBoxButtons.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
txtEdit_info.Text = "";
|
||||
m_bQuit = false;
|
||||
m_thread = new Thread(Do2H1Action);
|
||||
m_thread.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 确认按钮点击
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBtnOkClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtEdit_info.Text))
|
||||
{
|
||||
MessageUtil.Show("未获取到结果,无法保存");
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(GetChipInfoModel.AfterSql))
|
||||
{
|
||||
DataRow sourceRow = GetChipInfoModel.MaintabFocusedRow; ;
|
||||
string afterSql = GetChipInfoModel.AfterSql.TrimStart('!');
|
||||
string pattern = @"(\w+)\((.*?)\)";
|
||||
Regex regex = new Regex(pattern);
|
||||
Match match = regex.Match(afterSql);
|
||||
if (match.Success)
|
||||
{
|
||||
string functionName = match.Groups[1].Value;
|
||||
string parameters = match.Groups[2].Value;
|
||||
if (!string.IsNullOrEmpty(functionName))
|
||||
{
|
||||
DataTable sqlParametersTab = BaseImpl.GetDataTableResult($"SELECT PARAMETER_NAME,PARAMETER_MODE,CHARACTER_MAXIMUM_LENGTH,DATA_TYPE FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = '{functionName}' ORDER BY ORDINAL_POSITION;");
|
||||
using (SqlCommand command = new SqlCommand(functionName, SqlHelper._connection))
|
||||
{
|
||||
string[] parametersArray = parameters.Split(',');
|
||||
foreach (DataRow parameterRow in sqlParametersTab.Rows)
|
||||
{
|
||||
string parameterName = parameterRow["PARAMETER_NAME"] + "";
|
||||
string parameterMode = parameterRow["PARAMETER_MODE"] + "";
|
||||
int.TryParse(parameterRow["CHARACTER_MAXIMUM_LENGTH"] + "", out int dataLength);
|
||||
string dataType = parameterRow["DATA_TYPE"] + "";
|
||||
SqlParameter sqlParameter = null;
|
||||
if (parameterMode.Equals("int"))
|
||||
{
|
||||
sqlParameter = new SqlParameter(parameterName, SqlDbType.Int);
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlParameter = new SqlParameter(parameterName, SqlDbType.VarChar, dataLength);
|
||||
}
|
||||
if (parameterMode.Equals("IN"))
|
||||
{
|
||||
sqlParameter.Direction = ParameterDirection.Input;
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlParameter.Direction = ParameterDirection.Output;
|
||||
}
|
||||
command.Parameters.Add(sqlParameter);
|
||||
}
|
||||
for (int i = 0; i < command.Parameters.Count; i++)
|
||||
{
|
||||
SqlParameter sqlParameter = command.Parameters[i];
|
||||
if (parametersArray.Length > i)
|
||||
{
|
||||
string commandParameter = parametersArray[i];
|
||||
string field = commandParameter.Replace("@", "").Replace("{", "").Replace("}", "");
|
||||
string value = sourceRow.Table.Columns.Contains(field) ? sourceRow[field] + "" : commandParameter.Replace("@", "");
|
||||
value = value.Replace("{result}", txtEdit_info.Text);
|
||||
value = value.Replace("@", "").Replace("{", "").Replace("}", "");
|
||||
sqlParameter.Value = value;
|
||||
}
|
||||
}
|
||||
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
||||
returnValue.Direction = ParameterDirection.ReturnValue;
|
||||
command.Parameters.Add(returnValue);
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
command.ExecuteNonQuery();
|
||||
if ((returnValue.Value + "").Equals("1"))
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
SqlParameter outSqlParameter = command.Parameters.Cast<SqlParameter>().Where(n => n.Direction == ParameterDirection.Output).FirstOrDefault();
|
||||
if (outSqlParameter != null)
|
||||
{
|
||||
string outMessage = outSqlParameter.Value + "";
|
||||
if (!string.IsNullOrEmpty(outMessage))
|
||||
{
|
||||
MessageUtil.Show(outSqlParameter.Value + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show("保存逻辑配置错误");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show("保存逻辑配置错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取PRM芯片号
|
||||
/// </summary>
|
||||
public void DoPRMAction()
|
||||
{
|
||||
try
|
||||
{
|
||||
oneSerialPort.ReadTimeout = 200;
|
||||
oneSerialPort.PortName = m_strCom;
|
||||
oneSerialPort.BaudRate = m_nBaud;
|
||||
if (oneSerialPort.IsOpen == false)
|
||||
{
|
||||
oneSerialPort.Open();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
return;
|
||||
}
|
||||
long lCurTick = DateTime.Now.Ticks;
|
||||
int nCount = 10;
|
||||
SetCountDownText(nCount.ToString());
|
||||
while (!m_bQuit)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (nCount <= 0)
|
||||
{
|
||||
SetCountDownText("读取PRM序列号(&E)");
|
||||
break;
|
||||
}
|
||||
if ((DateTime.Now.Ticks - lCurTick) > 1.0e7)
|
||||
{
|
||||
nCount--;
|
||||
SetCountDownText(nCount.ToString());
|
||||
lCurTick = DateTime.Now.Ticks;
|
||||
}
|
||||
string message = oneSerialPort.ReadLine();
|
||||
if (message.Contains("$PGDGI")
|
||||
&& message.Contains("PRM")
|
||||
&& message.Contains("SN"))
|
||||
{
|
||||
int nStart = message.IndexOf(':');
|
||||
int nEnd = message.IndexOf('*');
|
||||
|
||||
SetInfoTxtEditText(message.Substring(nStart + 1, nEnd - nStart - 1));
|
||||
SetCountDownText("读取PRM序列号(&E)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
oneSerialPort.Close();
|
||||
m_bQuit = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取授权芯片号
|
||||
/// </summary>
|
||||
public void Do2H1Action()
|
||||
{
|
||||
try
|
||||
{
|
||||
oneSerialPort.ReadTimeout = 200;
|
||||
oneSerialPort.PortName = m_strCom;
|
||||
oneSerialPort.BaudRate = m_nBaud;
|
||||
if (oneSerialPort.IsOpen == false)
|
||||
{
|
||||
oneSerialPort.Open();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
return;
|
||||
}
|
||||
oneSerialPort.Write("$CCTST,888888*00\r\n");
|
||||
Thread.Sleep(100);
|
||||
long lCurTick = DateTime.Now.Ticks;
|
||||
int nCount = 10;
|
||||
SetCountDownText(nCount.ToString());
|
||||
while (!m_bQuit)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (nCount <= 0)
|
||||
{
|
||||
SetCountDownText("读取授权芯片号(&E)");
|
||||
break;
|
||||
}
|
||||
if ((DateTime.Now.Ticks - lCurTick) > 1.0e7)
|
||||
{
|
||||
nCount--;
|
||||
SetCountDownText(nCount.ToString());
|
||||
lCurTick = DateTime.Now.Ticks;
|
||||
oneSerialPort.Write("$CCRMO,ICN,2,0*00\r\n");
|
||||
}
|
||||
string message = oneSerialPort.ReadLine();
|
||||
if (message.Contains("$BDICN")
|
||||
&& message.Contains("*"))
|
||||
{
|
||||
int nStart = message.IndexOf(',');
|
||||
int nEnd = message.IndexOf('*');
|
||||
if (nEnd - nStart > 0)
|
||||
{
|
||||
SetInfoTxtEditText(message.Substring(nStart + 1, nEnd - nStart - 1));
|
||||
SetCountDownText("读取授权芯片号(&E)");
|
||||
m_bQuit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
oneSerialPort.Close();
|
||||
m_bQuit = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置倒计时文本值
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
private void SetCountDownText(string text)
|
||||
{
|
||||
if (btn_Read.InvokeRequired == true)
|
||||
{
|
||||
btn_Read.Invoke(new Action(() =>
|
||||
{
|
||||
btn_Read.Text = text;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_Read.Text = text;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置芯片文本值
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
private void SetInfoTxtEditText(string text)
|
||||
{
|
||||
if (txtEdit_info.InvokeRequired)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<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>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<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:sequence>
|
||||
<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="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{C8E55459-4410-4F15-9017-4EA560036E19}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Lskj.PubGetChipInfo</RootNamespace>
|
||||
<AssemblyName>Lskj.PubGetChipInfo</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Debug\Lib\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DevExpress.Data.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Utils.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.XtraEditors.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\Lskj.LserpAll\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\Lskj.LserpAll\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\Lskj.LserpAll\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\引用DLL\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\Lskj.LserpAll\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Runtime, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\Lskj.LserpAll\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\Lskj.LserpAll\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DllBaseClass.cs" />
|
||||
<Compile Include="FrmMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmMain.Designer.cs">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Lskj.Business\Lskj.Business.csproj">
|
||||
<Project>{7EAFCCC2-A18F-49E9-85C6-A984966CFD01}</Project>
|
||||
<Name>Lskj.Business</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Control\Lskj.Control.csproj">
|
||||
<Project>{447CDC40-659F-4CCA-9ED6-8E818B4CF8BF}</Project>
|
||||
<Name>Lskj.Control</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Core\Lskj.Core.csproj">
|
||||
<Project>{2A1BE6AC-1077-491B-A754-C5822FE8121E}</Project>
|
||||
<Name>Lskj.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Model\Lskj.Model.csproj">
|
||||
<Project>{52BC40E0-C0C6-4F78-996B-CAE028D209CA}</Project>
|
||||
<Name>Lskj.Model</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Util\Lskj.Util.csproj">
|
||||
<Project>{A51BF642-6543-4DE3-8948-83F558B72BD4}</Project>
|
||||
<Name>Lskj.Util</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="FrmMain.resx">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\Lskj.LserpAll\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\Lskj.LserpAll\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\Lskj.LserpAll\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\Lskj.LserpAll\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Lskj.PubGetChipInfo")]
|
||||
[assembly: AssemblyDesc
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NPOI" publicKeyToken="0df73ec7942b34e1" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.1.3.1" newVersion="2.1.3.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" />
|
||||
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net40" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user