diff --git a/BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs b/BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs index f7bec624..f4203e0c 100644 --- a/BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs +++ b/BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs @@ -5,12 +5,12 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.ObjectModel; -using AlarmDetection.Model; using Microsoft.Toolkit.Mvvm.Input; -using AlarmDetection.View; -using AlarmDetection.TypeEnum; +using BPASmart.VariableManager.Views; using System.Windows; -using AlarmDetection.Server; +using BPASmartClient.Helper; +using BPASmart.VariableManager.Models; +using BPASmart.VariableManager.Enums; namespace BPASmart.VariableManager.ViewModels { @@ -21,17 +21,17 @@ namespace BPASmart.VariableManager.ViewModels NewConnectCommand = new RelayCommand(() => { NewConnect(); }); SaveConnectSetCommand = new RelayCommand(() => { - Json.GetInstance.Base.communicationSets.Clear(); + Json.Data.communicationSets.Clear(); foreach (var item in communicationSets) { item.RemoveAction = null; - Json.GetInstance.Base.communicationSets.Add(item); + Json.Data.communicationSets.Add(item); } - Json.GetInstance.Save(); + Json.Save(); }); - Json.GetInstance.Read(); - foreach (var item in Json.GetInstance.Base.communicationSets) + Json.Read(); + foreach (var item in Json.Data.communicationSets) { item.RemoveAction = RemoveDevice; communicationSets.Add(item); @@ -43,7 +43,7 @@ namespace BPASmart.VariableManager.ViewModels }); } - public ObservableCollection communicationSets { get; set; } = new ObservableCollection(); + public ObservableCollection communicationSets { get; set; } = new ObservableCollection(); public RelayCommand NewConnectCommand { get; set; } @@ -64,7 +64,7 @@ namespace BPASmart.VariableManager.ViewModels var obj = communicationSets.FirstOrDefault(p => p.DeviceName == ResultTag.DeviceName); if (obj == null) { - CommunicationSet communicationObj = new CommunicationSet(); + CommunicationModel communicationObj = new CommunicationModel(); EDeviceType eDeviceType = (EDeviceType)Enum.Parse(typeof(EDeviceType), ResultTag.DeviceType); switch (eDeviceType) { diff --git a/BPASmart.VariableManager/ViewModels/DeviceManagermentSetViewModel.cs b/BPASmart.VariableManager/ViewModels/DeviceManagermentSetViewModel.cs index 53ac490b..69d3a0ee 100644 --- a/BPASmart.VariableManager/ViewModels/DeviceManagermentSetViewModel.cs +++ b/BPASmart.VariableManager/ViewModels/DeviceManagermentSetViewModel.cs @@ -6,12 +6,11 @@ using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.Concurrent; using System.Collections.ObjectModel; -using AlarmDetection.TypeEnum; using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Mvvm.Messaging; using System.Diagnostics; -using AlarmDetection.Model; -using AlarmDetection.Server; +using BPASmart.VariableManager.Models; +using BPASmart.VariableManager.Enums; namespace BPASmart.VariableManager.ViewModels { diff --git a/BPASmart.VariableManager/ViewModels/VariableConfig.cs b/BPASmart.VariableManager/ViewModels/VariableConfig.cs index 3da975b6..0111daeb 100644 --- a/BPASmart.VariableManager/ViewModels/VariableConfig.cs +++ b/BPASmart.VariableManager/ViewModels/VariableConfig.cs @@ -45,25 +45,25 @@ namespace BPASmart.VariableManager.ViewModels { //SqlHelper.GetInstance.Database.EnsureCreated(); ////多表查询 - var DataList = SqlHelper.GetInstance.DbObj.ToList(); - App.Current.Dispatcher.Invoke(new Action(() => { varialeInfos.Clear(); })); - foreach (var item in DataList) - { - PropBindInfo propBindInfo = new PropBindInfo(); - propBindInfo.ID = item.ID; - propBindInfo.VarName = item.VarName; - propBindInfo.Address = item.Address; - propBindInfo.DataType = item.DataType; - propBindInfo.IsEnableAlarm = item.IsEnableAlarm; - propBindInfo.CurrentValue = item.CurrentValue; - var result = item.AlarmSetProp.AnalogAlarmModels.Where(p => p.AlarmSetId == item.ID).ToList(); - result = result?.OrderBy(p => p.SortTag).ToList(); - propBindInfo.AlarmSetProp.AnalogAlarmModels.Clear(); - result?.ForEach(p => { propBindInfo.AlarmSetProp.AnalogAlarmModels.Add(p); }); - propBindInfo.AlarmSetProp.DiscreteAlarmInfoSet = item.AlarmSetProp.DiscreteAlarmInfoSet; - App.Current?.Dispatcher.Invoke(new Action(() => { varialeInfos.Add(propBindInfo); })); - } - if (varialeInfos.Count <= 0) AddRow(); + //var DataList = SqlHelper.GetInstance.DbObj.ToList(); + //App.Current.Dispatcher.Invoke(new Action(() => { varialeInfos.Clear(); })); + //foreach (var item in DataList) + //{ + // PropBindInfo propBindInfo = new PropBindInfo(); + // propBindInfo.ID = item.ID; + // propBindInfo.VarName = item.VarName; + // propBindInfo.Address = item.Address; + // propBindInfo.DataType = item.DataType; + // propBindInfo.IsEnableAlarm = item.IsEnableAlarm; + // propBindInfo.CurrentValue = item.CurrentValue; + // var result = item.AlarmSetProp.AnalogAlarmModels.Where(p => p.AlarmSetId == item.ID).ToList(); + // result = result?.OrderBy(p => p.SortTag).ToList(); + // propBindInfo.AlarmSetProp.AnalogAlarmModels.Clear(); + // result?.ForEach(p => { propBindInfo.AlarmSetProp.AnalogAlarmModels.Add(p); }); + // propBindInfo.AlarmSetProp.DiscreteAlarmInfoSet = item.AlarmSetProp.DiscreteAlarmInfoSet; + // App.Current?.Dispatcher.Invoke(new Action(() => { varialeInfos.Add(propBindInfo); })); + //} + //if (varialeInfos.Count <= 0) AddRow(); return Task.FromResult(true); } @@ -73,22 +73,22 @@ namespace BPASmart.VariableManager.ViewModels /// private Task SaveDataAsync() { - SqlHelper.GetInstance.DbObj.RemoveRange(SqlHelper.GetInstance.DbObj.ToArray()); - foreach (var item in varialeInfos) - { - SqlHelper.GetInstance.Add(new VariableInfo() - { - ID = item.ID, - VarName = item.VarName, - Address = item.Address, - DataType = item.DataType, - IsEnableAlarm = item.IsEnableAlarm, - CurrentValue = item.CurrentValue, - AlarmSetProp = item.AlarmSetProp, + //SqlHelper.GetInstance.DbObj.RemoveRange(SqlHelper.GetInstance.DbObj.ToArray()); + //foreach (var item in varialeInfos) + //{ + // SqlHelper.GetInstance.Add(new VariableInfo() + // { + // ID = item.ID, + // VarName = item.VarName, + // Address = item.Address, + // DataType = item.DataType, + // IsEnableAlarm = item.IsEnableAlarm, + // CurrentValue = item.CurrentValue, + // AlarmSetProp = item.AlarmSetProp, - }); - } - SqlHelper.GetInstance.Save(); + // }); + //} + //SqlHelper.GetInstance.Save(); return Task.FromResult(true); } diff --git a/BPASmart.VariableManager/ViewModels/VariableMonitorViewModel.cs b/BPASmart.VariableManager/ViewModels/VariableMonitorViewModel.cs index 4ec01131..2d54582d 100644 --- a/BPASmart.VariableManager/ViewModels/VariableMonitorViewModel.cs +++ b/BPASmart.VariableManager/ViewModels/VariableMonitorViewModel.cs @@ -1,5 +1,4 @@ -using AlarmDetection.Model; -using AlarmDetection.Server; +using BPASmart.VariableManager.Models; using Microsoft.EntityFrameworkCore; using Microsoft.Toolkit.Mvvm.ComponentModel; using System; @@ -23,21 +22,21 @@ namespace BPASmart.VariableManager.ViewModels /// private Task GetLocalDataAsync() { - var DataList = SqlHelper.GetInstance.DbObj.ToList(); - App.Current.Dispatcher.Invoke(new Action(() => { varialeInfos.Clear(); })); - foreach (var item in DataList) - { - if (item.VarName?.Length > 0) - { - VarMonitorPropInfo varMonitorPropInfo = new VarMonitorPropInfo(); - varMonitorPropInfo.ID = item.ID; - varMonitorPropInfo.VarName = item.VarName; - varMonitorPropInfo.Address = item.Address; - varMonitorPropInfo.DataType = item.DataType; - varMonitorPropInfo.DataDisplayFormat = TypeEnum.DisplayFormat.十进制.ToString(); - App.Current?.Dispatcher.Invoke(new Action(() => { varialeInfos.Add(varMonitorPropInfo); })); - } - } + //var DataList = SqlHelper.GetInstance.DbObj.ToList(); + //App.Current.Dispatcher.Invoke(new Action(() => { varialeInfos.Clear(); })); + //foreach (var item in DataList) + //{ + // if (item.VarName?.Length > 0) + // { + // VarMonitorPropInfo varMonitorPropInfo = new VarMonitorPropInfo(); + // varMonitorPropInfo.ID = item.ID; + // varMonitorPropInfo.VarName = item.VarName; + // varMonitorPropInfo.Address = item.Address; + // varMonitorPropInfo.DataType = item.DataType; + // varMonitorPropInfo.DataDisplayFormat = TypeEnum.DisplayFormat.十进制.ToString(); + // App.Current?.Dispatcher.Invoke(new Action(() => { varialeInfos.Add(varMonitorPropInfo); })); + // } + //} return Task.FromResult(true); } @@ -47,22 +46,22 @@ namespace BPASmart.VariableManager.ViewModels /// private Task SaveDataAsync() { - SqlHelper.GetInstance.DbObj.RemoveRange(SqlHelper.GetInstance.DbObj.ToArray()); - foreach (var item in varialeInfos) - { - SqlHelper.GetInstance.Add(new VariableInfo() - { - ID = item.ID, - VarName = item.VarName, - Address = item.Address, - DataType = item.DataType, - IsEnableAlarm = item.IsEnableAlarm, - CurrentValue = item.CurrentValue, - AlarmSetProp = item.AlarmSetProp, + //SqlHelper.GetInstance.DbObj.RemoveRange(SqlHelper.GetInstance.DbObj.ToArray()); + //foreach (var item in varialeInfos) + //{ + // SqlHelper.GetInstance.Add(new VariableInfo() + // { + // ID = item.ID, + // VarName = item.VarName, + // Address = item.Address, + // DataType = item.DataType, + // IsEnableAlarm = item.IsEnableAlarm, + // CurrentValue = item.CurrentValue, + // AlarmSetProp = item.AlarmSetProp, - }); - } - SqlHelper.GetInstance.Save(); + // }); + //} + //SqlHelper.GetInstance.Save(); return Task.FromResult(true); } diff --git a/BPASmart.VariableManager/Views/CommunicationSetView.xaml b/BPASmart.VariableManager/Views/CommunicationSetView.xaml index a3124d6e..344cae6b 100644 --- a/BPASmart.VariableManager/Views/CommunicationSetView.xaml +++ b/BPASmart.VariableManager/Views/CommunicationSetView.xaml @@ -1,11 +1,10 @@  - + StrokeThickness="2" />--> - + + + @@ -87,9 +88,9 @@ FontSize="18" Template="{StaticResource NewButtonTemp}"> - - - + + + @@ -100,11 +101,11 @@ Content="保存" FontFamily="楷体" FontSize="18" - Template="{StaticResource SaveButtonTemp}" > + Template="{StaticResource SaveButtonTemp}"> - - - + + + @@ -134,7 +135,7 @@ - + /// CommunicationSetView.xaml 的交互逻辑 diff --git a/BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml b/BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml index 88397f97..d075d0e8 100644 --- a/BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml +++ b/BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml @@ -1,9 +1,9 @@  - + + Text="{Binding LogInfo}" + TextWrapping="Wrap" /> -