|
@@ -27,6 +27,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
|
public class DeviceKindViewModel : BindableBase
|
|
|
{
|
|
|
private readonly IBasicDeviceKindService _iBasicDeviceKindService;
|
|
|
+ private readonly IBasicPlcTestSchemeService _iBasicPlcTestSchemeService;
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly IDialogService _dialog;
|
|
|
private readonly ILogger _logger;
|
|
@@ -34,9 +35,11 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
|
private List<BasDeviceKindDto> allDeviceKindList = new List<BasDeviceKindDto>();//所有方案
|
|
|
private List<BasDeviceKindDto> conditionDeviceKind = new List<BasDeviceKindDto>();//符合条件的方案
|
|
|
private List<CrumbViewModel> breadCrumbs = new List<CrumbViewModel>();
|
|
|
- public DeviceKindViewModel(IBasicDeviceKindService iBasicDeviceKindService, IMapper mapper, IEventAggregator aggregator, IDialogService dialog, ILogger logger)
|
|
|
+ private string deviceKindBefore;//修改前的设备方案名称
|
|
|
+ public DeviceKindViewModel(IBasicDeviceKindService iBasicDeviceKindService, IBasicPlcTestSchemeService iBasicPlcTestSchemeService, IMapper mapper, IEventAggregator aggregator, IDialogService dialog, ILogger logger)
|
|
|
{
|
|
|
_iBasicDeviceKindService = iBasicDeviceKindService;
|
|
|
+ _iBasicPlcTestSchemeService= iBasicPlcTestSchemeService;
|
|
|
_mapper = mapper;
|
|
|
_dialog = dialog;
|
|
|
_logger = logger;
|
|
@@ -48,7 +51,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
|
DeleteCommand = new DelegateCommand<object>(Delete);
|
|
|
ResetCommand = new DelegateCommand<object>(Reset);
|
|
|
OnLoadCommand = new DelegateCommand(OnLoad);
|
|
|
- GetPprojectConfig();
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -75,6 +78,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
|
breadCrumbs.Add(new CrumbViewModel { Name = "设备类型管理" });
|
|
|
_aggregator.GetEvent<BreadEvent>().Publish(breadCrumbs);
|
|
|
// DeviceKindNameList= _iBasicDeviceKindService.FindAllDeviceKind();
|
|
|
+ //获取数据
|
|
|
+ GetPprojectConfig();
|
|
|
}
|
|
|
private void Reset(object obj)
|
|
|
{
|
|
@@ -91,9 +96,9 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
|
private void Edit(object obj)
|
|
|
{
|
|
|
int id = Convert.ToInt32(obj);
|
|
|
- var finrProject = allDeviceKindList.FirstOrDefault(x => (x.DeviceKindId == id));
|
|
|
+ var findDeviceKind = allDeviceKindList.FirstOrDefault(x => (x.DeviceKindId == id));
|
|
|
DialogParameters parm = new DialogParameters();
|
|
|
- parm.Add("Key", finrProject);
|
|
|
+ parm.Add("Key", findDeviceKind);
|
|
|
//蒙层显示
|
|
|
_aggregator.GetEvent<MaskEvent>().Publish(true);
|
|
|
//弹出详情对话框
|
|
@@ -109,8 +114,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
|
returnValue.UpdateTime = DateTime.Now;
|
|
|
returnValue.UpdateBy = Appsession.UserName;
|
|
|
//创建时间
|
|
|
- returnValue.CreateTime = finrProject.CreateTime;
|
|
|
- returnValue.CreateBy = finrProject?.CreateBy;
|
|
|
+ returnValue.CreateTime = findDeviceKind.CreateTime;
|
|
|
+ returnValue.CreateBy = findDeviceKind?.CreateBy;
|
|
|
|
|
|
var deviceKindCon = _mapper.Map<BasDeviceKindDto, bas_device_kind>(returnValue);
|
|
|
var findPlcs = allDeviceKindList.FindAll(x => (x.DeviceKindName == returnValue.DeviceKindName) || (x.DeviceKindNo == returnValue.DeviceKindNo));
|
|
@@ -128,12 +133,20 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
|
bool isSucc = _iBasicDeviceKindService.Edit(deviceKindCon);
|
|
|
if (isSucc)
|
|
|
{
|
|
|
+ //更改测试方案表中的设备类型命令
|
|
|
+ var tests = _iBasicPlcTestSchemeService.FindAllByKind(findDeviceKind.DeviceKindName);
|
|
|
+ foreach (var item in tests)
|
|
|
+ {
|
|
|
+ item.devicekind_name = returnValue.DeviceKindName;
|
|
|
+ _iBasicPlcTestSchemeService.Edit(item);
|
|
|
+ }
|
|
|
//重新读取PLC
|
|
|
GetPprojectConfig();
|
|
|
_logger.LogInformation($"修改设备类型成功,类型为{deviceKindCon}");
|
|
|
SendLogToDis($"修改设备类型成功,类型为{deviceKindCon}");
|
|
|
MessageBox.Show("修改设备类型成功", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|