diff --git a/NDSD-Screwdriver/AppTool.cs b/NDSD-Screwdriver/AppTool.cs deleted file mode 100644 index 3345b40..0000000 --- a/NDSD-Screwdriver/AppTool.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace NDSD_Screwdriver -{ - using System.Configuration; - public class AppTool - { - public static string GetIp() - { - return ConfigurationManager.AppSettings["ip"].ToString(); - } - - public static string GetDb() - { - return ConfigurationManager.AppSettings["db"].ToString(); - } - - public static String GetCom=> ConfigurationManager.AppSettings["com"].ToString(); - - } -} \ No newline at end of file diff --git a/NDSD-Screwdriver/FrmSetting.cs b/NDSD-Screwdriver/FrmSetting.cs index 8c5f6fd..0c73e3a 100644 --- a/NDSD-Screwdriver/FrmSetting.cs +++ b/NDSD-Screwdriver/FrmSetting.cs @@ -34,7 +34,8 @@ namespace NDSD_Screwdriver public void Init() { dataGridView1.AutoGenerateColumns = false; - var ctx = SqlLiteTool.GetDb(AppTool.GetDb()); + var memorySetting = MemorySetting.Current; + var ctx = SqlLiteTool.GetDb(memorySetting.DB); var list = ctx.Query().Where(x => x.IsEnable == true).ToList(); // dataGridView1.DataSource = list;//DataGridView的行可以添加删除(只有允许添加行、删除行) @@ -44,7 +45,7 @@ namespace NDSD_Screwdriver dataGridView1.AllowUserToDeleteRows = true; - var memorySetting = MemorySetting.Current; + ServerIPTextbox.Text = memorySetting.ServerIP; ServerPortTextbox.Text=memorySetting.ServerPort; AlarmTimeValueTextBox.Text = memorySetting.AlarmTimeValue.ToString(); @@ -178,7 +179,8 @@ namespace NDSD_Screwdriver if (list.Count > 0) { - var ctx = SqlLiteTool.GetDb(AppTool.GetDb()); + var memorySetting = MemorySetting.Current; + var ctx = SqlLiteTool.GetDb(memorySetting.DB); ctx.Update(a => a.IsEnable == true, a => new RFIDConfigEntity() { IsEnable = false diff --git a/NDSD-Screwdriver/MainForm.cs b/NDSD-Screwdriver/MainForm.cs index 1af43c8..6c71001 100644 --- a/NDSD-Screwdriver/MainForm.cs +++ b/NDSD-Screwdriver/MainForm.cs @@ -75,12 +75,15 @@ namespace NDSD_Screwdriver public MainForm() { - SqlLiteTool.CreateTable(AppTool.GetDb()); + + + InitializeComponent(); var memorySetting = MemorySetting.Current; - LogContext = SqlLiteTool.GetDb(AppTool.GetDb()); + SqlLiteTool.CreateTable(memorySetting.DB); + LogContext = SqlLiteTool.GetDb(memorySetting.DB); RFIDLogsEntitys = LogContext.Query().OrderByDesc(a => a.CreateTime).Take(200).ToList(); LogDataGridView.AutoGenerateColumns = false; LogDataGridView.DataSource = null; @@ -94,7 +97,7 @@ namespace NDSD_Screwdriver try { - serialPort = new SerialPortFactory(AppTool.GetCom); + serialPort = new SerialPortFactory(memorySetting.Com); StartLongRunningTask(); } catch (Exception e) @@ -165,10 +168,11 @@ namespace NDSD_Screwdriver // flashThread.Abort(); //} //FlashThread(); - - + + + var memorySetting = MemorySetting.Current; //读取rfid数据 - var ctx = SqlLiteTool.GetDb(AppTool.GetDb()); + var ctx = SqlLiteTool.GetDb(memorySetting.DB); var list = ctx.Query().Where(x => x.IsEnable == true).ToList(); var strs = list.Select(x => x.RfidNo).ToArray(); RFIDStatesEntities = new List(); diff --git a/NDSD-Screwdriver/MemorySetting.cs b/NDSD-Screwdriver/MemorySetting.cs index 35185b9..bc38438 100644 --- a/NDSD-Screwdriver/MemorySetting.cs +++ b/NDSD-Screwdriver/MemorySetting.cs @@ -14,6 +14,15 @@ namespace NDSD_Screwdriver [Config("MemorySetting")] public class MemorySetting : Config { + + public MemorySetting() + { + + } + + + public string DB { get; set; }= "Data Source=ndsd.db;Version=3;" + /// /// 服务端IP /// diff --git a/NDSD-Screwdriver/NDSD_Screwdriver.csproj b/NDSD-Screwdriver/NDSD_Screwdriver.csproj index fa75ce9..419daa6 100644 --- a/NDSD-Screwdriver/NDSD_Screwdriver.csproj +++ b/NDSD-Screwdriver/NDSD_Screwdriver.csproj @@ -98,7 +98,6 @@ - Form