diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs index af3ed28..4f1de30 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs @@ -43,8 +43,8 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl DataTable ParametersWithPCTable = new DataTable(); DataTable AllAlarmTable = new DataTable(); - DataTable LogAlarmTable = new DataTable(); - DataTable NowAlarmTable = new DataTable(); + //DataTable LogAlarmTable = new DataTable(); + //DataTable NowAlarmTable = new DataTable(); DataTable TempTable = new DataTable(); byte[] b2; @@ -103,18 +103,18 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl ParametersWithPCTable.Columns.Add("currnet", typeof(float)); ParametersWithPCTable.Columns.Add("pressure", typeof(float)); - LogAlarmTable.Columns.Add("Equip_Name", typeof(string)); - LogAlarmTable.Columns.Add("Alarm_ID", typeof(int)); - LogAlarmTable.Columns.Add("Alarm_Cn_Info", typeof(string)); - LogAlarmTable.Columns.Add("Alarm_Other_Info", typeof(string)); - LogAlarmTable.Columns.Add("Alarm_Occur_Time", typeof(string)); - LogAlarmTable.Columns.Add("Alarm_Claer_Time", typeof(string)); - LogAlarmTable.Columns.Add("Alarm_Status", typeof(int)); - LogAlarmTable.Columns.Add("Alarm_GUID", typeof(string)); + //LogAlarmTable.Columns.Add("Equip_Name", typeof(string)); + //LogAlarmTable.Columns.Add("Alarm_ID", typeof(int)); + //LogAlarmTable.Columns.Add("Alarm_Cn_Info", typeof(string)); + //LogAlarmTable.Columns.Add("Alarm_Other_Info", typeof(string)); + //LogAlarmTable.Columns.Add("Alarm_Occur_Time", typeof(string)); + //LogAlarmTable.Columns.Add("Alarm_Claer_Time", typeof(string)); + //LogAlarmTable.Columns.Add("Alarm_Status", typeof(int)); + //LogAlarmTable.Columns.Add("Alarm_GUID", typeof(string)); - NowAlarmTable.Columns.Add("报警设备", typeof(string)); - NowAlarmTable.Columns.Add("报警内容", typeof(string)); - NowAlarmTable.Columns.Add("报警时间", typeof(string)); + //NowAlarmTable.Columns.Add("报警设备", typeof(string)); + //NowAlarmTable.Columns.Add("报警内容", typeof(string)); + //NowAlarmTable.Columns.Add("报警时间", typeof(string)); TempTable.Columns.Add("报警设备", typeof(string)); TempTable.Columns.Add("报警内容", typeof(string)); @@ -259,6 +259,7 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl private void AlarmControl() { + //DataTable TempTable = DBHelp.GetTable(@"SELECT // t2.Alarm_Other_Info, // t2.Alarm_Cn_Info, @@ -284,24 +285,24 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl if ((int)rows["Alarm_Block"] == 2102 && b2[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true) { DataRow dr = TempTable.NewRow(); - dr[0] = rows["Alarm_Cn_Info"]; - dr[1] = rows["Alarm_Other_Info"]; + dr[0] = rows["Alarm_Other_Info"]; + dr[1] = rows["Alarm_Cn_Info"]; dr[2] = nowtime; TempTable.Rows.Add(dr); } else if ((int)rows["Alarm_Block"] == 2107 && b7[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true) { DataRow dr = TempTable.NewRow(); - dr[0] = rows["Alarm_Cn_Info"]; - dr[1] = rows["Alarm_Other_Info"]; + dr[0] = rows["Alarm_Other_Info"]; + dr[1] = rows["Alarm_Cn_Info"]; dr[2] = nowtime; TempTable.Rows.Add(dr); } else if ((int)rows["Alarm_Block"] == 2103 && b3[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true) { DataRow dr = TempTable.NewRow(); - dr[0] = rows["Alarm_Cn_Info"]; - dr[1] = rows["Alarm_Other_Info"]; + dr[0] = rows["Alarm_Other_Info"]; + dr[1] = rows["Alarm_Cn_Info"]; dr[2] = nowtime; TempTable.Rows.Add(dr); } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs index be447db..4b13955 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs @@ -178,14 +178,16 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl #region 配置文件加载 - SetWaterValue1.MCValue = Setting.Default.SetWaterValue1; - SetWaterValue2.MCValue = Setting.Default.SetWaterValue2; - SetWaterValue3.MCValue = Setting.Default.SetWaterValue3; - SetWaterValue4.MCValue = Setting.Default.SetWaterValue4; - SetSpiralValue1.MCValue = Setting.Default.SetSpiralValue1; - SetSpiralValue2.MCValue = Setting.Default.SetSpiralValue2; - SetSpiralValue3.MCValue = Setting.Default.SetSpiralValue3; - SetSpiralValue4.MCValue = Setting.Default.SetSpiralValue4; + var table = FreeSqlUnit.Instance.Select().Where("1 = 1").ToList(); + + SetWaterValue1.MCValue = table.Where(x => x.SettingName == "WaterValue1").LastOrDefault().Value; + SetWaterValue2.MCValue = table.Where(x => x.SettingName == "WaterValue2").LastOrDefault().Value; + SetWaterValue3.MCValue = table.Where(x => x.SettingName == "WaterValue3").LastOrDefault().Value; + SetWaterValue4.MCValue = table.Where(x => x.SettingName == "WaterValue4").LastOrDefault().Value; + SetSpiralValue1.MCValue = table.Where(x => x.SettingName == "SpiralValue1").LastOrDefault().Value; + SetSpiralValue2.MCValue = table.Where(x => x.SettingName == "SpiralValue2").LastOrDefault().Value; + SetSpiralValue3.MCValue = table.Where(x => x.SettingName == "SpiralValue3").LastOrDefault().Value; + SetSpiralValue4.MCValue = table.Where(x => x.SettingName == "SpiralValue4").LastOrDefault().Value; MesnacServiceManager.Instance.LoggingService.Info("配置已加载"); ManualLogControl("配置已加载 "); diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs index b9e9064..6338a54 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs @@ -1220,15 +1220,43 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { return; } - - Setting.Default.SetWaterValue1 = value1; - Setting.Default.SetWaterValue2 = value2; - Setting.Default.SetWaterValue3 = value3; - Setting.Default.SetWaterValue4 = value4; - Setting.Default.SetSpiralValue1 = value5; - Setting.Default.SetSpiralValue2 = value6; - Setting.Default.SetSpiralValue3 = value7; - Setting.Default.SetSpiralValue4 = value8; + + FreeSqlUnit.Instance.Delete().Where("1 = 1").ExecuteAffrows(); + + ManualControlSetting[] settings = new ManualControlSetting[8]; + + for(int i = 0; i < 8; i++) + { + settings[i] = new ManualControlSetting(); + } + + settings[0].SettingName = "WaterValue1"; + settings[1].SettingName = "WaterValue2"; + settings[2].SettingName = "WaterValue3"; + settings[3].SettingName = "WaterValue4"; + settings[4].SettingName = "SpiralValue1"; + settings[5].SettingName = "SpiralValue2"; + settings[6].SettingName = "SpiralValue3"; + settings[7].SettingName = "SpiralValue4"; + + settings[0].Value = value1; + settings[1].Value = value2; + settings[2].Value = value3; + settings[3].Value = value4; + settings[4].Value = value5; + settings[5].Value = value6; + settings[6].Value = value7; + settings[7].Value = value8; + + FreeSqlUnit.Instance.Insert(settings).ExecuteAffrows(); + //Setting.Default.SetWaterValue1 = value1; + //Setting.Default.SetWaterValue2 = value2; + //Setting.Default.SetWaterValue3 = value3; + //Setting.Default.SetWaterValue4 = value4; + //Setting.Default.SetSpiralValue1 = value5; + //Setting.Default.SetSpiralValue2 = value6; + //Setting.Default.SetSpiralValue3 = value7; + //Setting.Default.SetSpiralValue4 = value8; MesnacServiceManager.Instance.LoggingService.Info("配置已保存"); ManualLogControl("配置已保存 " + value1 + value2 + value3 + value4 + value5 + value6 + value7 + value8); } @@ -1240,14 +1268,17 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { return; } - SetWaterValue1.MCValue = Setting.Default.SetWaterValue1; - SetWaterValue2.MCValue = Setting.Default.SetWaterValue2; - SetWaterValue3.MCValue = Setting.Default.SetWaterValue3; - SetWaterValue4.MCValue = Setting.Default.SetWaterValue4; - SetSpiralValue1.MCValue = Setting.Default.SetSpiralValue1; - SetSpiralValue2.MCValue = Setting.Default.SetSpiralValue2; - SetSpiralValue3.MCValue = Setting.Default.SetSpiralValue3; - SetSpiralValue4.MCValue = Setting.Default.SetSpiralValue4; + + var table = FreeSqlUnit.Instance.Select().Where("1 = 1").ToList(); + + SetWaterValue1.MCValue = table.Where(x => x.SettingName == "WaterValue1").LastOrDefault().Value; + SetWaterValue2.MCValue = table.Where(x => x.SettingName == "WaterValue2").LastOrDefault().Value; + SetWaterValue3.MCValue = table.Where(x => x.SettingName == "WaterValue3").LastOrDefault().Value; + SetWaterValue4.MCValue = table.Where(x => x.SettingName == "WaterValue4").LastOrDefault().Value; + SetSpiralValue1.MCValue = table.Where(x => x.SettingName == "SpiralValue1").LastOrDefault().Value; + SetSpiralValue2.MCValue = table.Where(x => x.SettingName == "SpiralValue2").LastOrDefault().Value; + SetSpiralValue3.MCValue = table.Where(x => x.SettingName == "SpiralValue3").LastOrDefault().Value; + SetSpiralValue4.MCValue = table.Where(x => x.SettingName == "SpiralValue4").LastOrDefault().Value; MesnacServiceManager.Instance.LoggingService.Info("配置已加载"); ManualLogControl("配置已加载 "); } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlSettingEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlSettingEntity.cs new file mode 100644 index 0000000..0729954 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlSettingEntity.cs @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// Website: http://www.freesql.net +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using FreeSql.DataAnnotations; + +namespace Mesnac.Action.ChemicalWeighing.ManualControl +{ + + + public partial class ManualControlSetting + { + + [Column(IsPrimary = true, IsIdentity = true)] + public int ID { get; set; } + + [Column(DbType = "nvarchar(50)")] + public string SettingName { get; set; } = string.Empty; + + + public int? Value { get; set; } + + } + +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 0617c9d..eb1c511 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -515,6 +515,7 @@ +