diff --git a/MaterialTraceability.Entity/DTO/ParamValueDto.cs b/MaterialTraceability.Entity/DTO/ParamValueDto.cs
new file mode 100644
index 0000000..3143d8a
--- /dev/null
+++ b/MaterialTraceability.Entity/DTO/ParamValueDto.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MaterialTraceability.Entity.DTO
+{
+ public class ParamValueDto
+ {
+ public string paramName { get; set; }
+
+ public string paramValue { get; set; }
+ }
+}
diff --git a/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj b/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj
index f310f0b..38d6c7c 100644
--- a/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj
+++ b/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj
@@ -62,6 +62,7 @@
+
diff --git a/MaterialTraceabilityUI/Common/IniFileHelper.cs b/MaterialTraceabilityUI/Common/IniFileHelper.cs
index 9870f61..5455c66 100644
--- a/MaterialTraceabilityUI/Common/IniFileHelper.cs
+++ b/MaterialTraceabilityUI/Common/IniFileHelper.cs
@@ -29,6 +29,8 @@ namespace MaterialTraceabilityUI.Common
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string defVal, Byte[] retVal, int size, string filePath);
+ [DllImport("kernel32", EntryPoint = "GetPrivateProfileString")]
+ private static extern uint GetPrivateProfileStringA(string section, string key,string def, Byte[] retVal, int size, string filePath);
///
/// 写INI文件
@@ -77,5 +79,25 @@ namespace MaterialTraceabilityUI.Common
{
IniWriteValue(Section, null, null);
}
+
+ public List ReadKeys(String SectionName)
+ {
+ return ReadKeys(SectionName, this.path);
+ }
+
+ public List ReadKeys(string SectionName, string iniFilename)
+ {
+ List result = new List();
+ Byte[] buf = new Byte[65536];
+ uint len = GetPrivateProfileStringA(SectionName, null, null, buf, buf.Length, iniFilename);
+ int j = 0;
+ for (int i = 0; i < len; i++)
+ if (buf[i] == 0)
+ {
+ result.Add(Encoding.Default.GetString(buf, j, i - j));
+ j = i + 1;
+ }
+ return result;
+ }
}
}
\ No newline at end of file
diff --git a/MaterialTraceabilityUI/ConfigInfo.xaml b/MaterialTraceabilityUI/ConfigInfo.xaml
index eebb8b0..ebd022f 100644
--- a/MaterialTraceabilityUI/ConfigInfo.xaml
+++ b/MaterialTraceabilityUI/ConfigInfo.xaml
@@ -171,40 +171,116 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MaterialTraceabilityUI/ConfigInfo.xaml.cs b/MaterialTraceabilityUI/ConfigInfo.xaml.cs
index 45be479..f9136bd 100644
--- a/MaterialTraceabilityUI/ConfigInfo.xaml.cs
+++ b/MaterialTraceabilityUI/ConfigInfo.xaml.cs
@@ -1,4 +1,5 @@
using MaterialTraceability.Business;
+using MaterialTraceability.Entity.DTO;
using MaterialTraceabilityUI.Common;
using System;
using System.Collections.Generic;
@@ -27,11 +28,26 @@ namespace MaterialTraceabilityUI
///
private IniFileHelper inifile = new IniFileHelper(System.Environment.CurrentDirectory + "/MesConfig/App.InI");
private IniFileHelper inifile2 = new IniFileHelper(System.Environment.CurrentDirectory + "/App.InI");
+ private AppConfigDto appConfig = AppConfigDto.Instance;
+ private string iniSection = "";
public ConfigInfo()
{
InitializeComponent();
-
+ switch(appConfig.processId)
+ {
+ case "TB":
+ iniSection = "TBPLcAddress";
+ break;
+ case "LY_A":
+ iniSection = "LYPLcAddress";
+ break;
+ case "MQ_A":
+ iniSection = "MQPLcAddress";
+ break;
+ default:
+ break;
+ }
}
private void SaveConfigInfo_Click(object sender, RoutedEventArgs e)
@@ -108,6 +124,15 @@ namespace MaterialTraceabilityUI
inifile2.IniWriteValue("SystemConfig", "isMesFlag", this.AppConfigParamIsMesFlag.Text);
inifile2.IniWriteValue("SystemConfig", "plcSingalReadTime", this.AppConfigParamPlcSingalReadTime.Text);
inifile2.IniWriteValue("SystemConfig", "MesWebServiceTimeOut", this.AppConfigParamMesWebServiceTimeOut.Text);
+
+
+ List plcParamValues = this.PlcParamValue.ItemsSource as List;
+
+ foreach(ParamValueDto item in plcParamValues)
+ {
+ inifile2.IniWriteValue(iniSection, item.paramName,item.paramValue);
+ }
+
MessageBox.Show("更新成功,重启生效");
}
catch(Exception ex)
@@ -188,6 +213,18 @@ namespace MaterialTraceabilityUI
this.AppConfigParamOperationByA.Text = inifile2.IniReadValue("SystemConfig", "operationByA");
this.AppConfigParamOperationByB.Text = inifile2.IniReadValue("SystemConfig", "operationByB");
this.AppConfigParamMesWebServiceTimeOut.Text = inifile2.IniReadValue("SystemConfig", "MesWebServiceTimeOut");
+
+ //获取PLC配置
+ List plcParamValues = inifile2.ReadKeys(iniSection);
+ List paramValues = new List();
+ foreach(string item in plcParamValues)
+ {
+ ParamValueDto paramValueDto = new ParamValueDto();
+ paramValueDto.paramName = item;
+ paramValueDto.paramValue = inifile2.IniReadValue(iniSection, item);
+ paramValues.Add(paramValueDto);
+ }
+ this.PlcParamValue.ItemsSource = paramValues;
}
}
}