|
@@ -1,5 +1,6 @@
|
|
using AutoMapper;
|
|
using AutoMapper;
|
|
using BizService;
|
|
using BizService;
|
|
|
|
+using ImTools;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging;
|
|
using Model.Dto;
|
|
using Model.Dto;
|
|
using Model.Entities;
|
|
using Model.Entities;
|
|
@@ -13,6 +14,8 @@ using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Net.NetworkInformation;
|
|
|
|
+using System.Security.Cryptography.Xml;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
@@ -28,6 +31,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
|
|
private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
|
|
private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
|
|
private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
|
|
private string schNameAgo = String.Empty;
|
|
private string schNameAgo = String.Empty;
|
|
|
|
+
|
|
|
|
+
|
|
public CopySchViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IMapper mapper, ILogger logger)
|
|
public CopySchViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IMapper mapper, ILogger logger)
|
|
{
|
|
{
|
|
|
|
|
|
@@ -36,6 +41,70 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
_mapper = mapper;
|
|
_mapper = mapper;
|
|
_logger = logger;
|
|
_logger = logger;
|
|
SureCommand = new DelegateCommand<string>(Sure);
|
|
SureCommand = new DelegateCommand<string>(Sure);
|
|
|
|
+ UpCommand = new DelegateCommand<object>(DataUp);
|
|
|
|
+ DownCommand = new DelegateCommand<object>(DataDown);
|
|
|
|
+ SelectAllCommand = new DelegateCommand<object>(SelectAll);
|
|
|
|
+ UnSelectAllCommand = new DelegateCommand<object>(UnSelecttAll);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void UnSelecttAll(object obj)
|
|
|
|
+ {
|
|
|
|
+ SchProjectList.ToList().FindAll(p => p.IsSelected = false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void SelectAll(object obj)
|
|
|
|
+ {
|
|
|
|
+ SchProjectList.ToList().FindAll(p => p.IsSelected = true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 下移
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="obj"></param>
|
|
|
|
+ private void DataDown(object obj)
|
|
|
|
+ {
|
|
|
|
+ int id = Convert.ToInt32(obj);
|
|
|
|
+ var findScheExist = SchProjectList.FirstOrDefault(x => x.Id == id);
|
|
|
|
+ if (findScheExist != null)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ int index = SchProjectList.IndexOf(findScheExist);
|
|
|
|
+ if(index!=-1)
|
|
|
|
+ {
|
|
|
|
+ if (index == SchProjectList.Count - 1)
|
|
|
|
+ return;
|
|
|
|
+ SchProjectList.RemoveAt(index);
|
|
|
|
+ index = index + 1;
|
|
|
|
+ SchProjectList.Insert(index, findScheExist);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 上移
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="obj"></param>
|
|
|
|
+ private void DataUp(object obj)
|
|
|
|
+ {
|
|
|
|
+ int id = Convert.ToInt32(obj);
|
|
|
|
+ var findScheExist = SchProjectList.FirstOrDefault(x=>x.Id==id);
|
|
|
|
+ if (findScheExist != null)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ int index = SchProjectList.IndexOf(findScheExist);
|
|
|
|
+ if(index!=-1)
|
|
|
|
+ {
|
|
|
|
+ if (index == 0)
|
|
|
|
+ return;
|
|
|
|
+ SchProjectList.RemoveAt(index);
|
|
|
|
+ index = index - 1;
|
|
|
|
+ SchProjectList.Insert(index, findScheExist);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private void Sure(string obj)
|
|
private void Sure(string obj)
|
|
@@ -64,28 +133,38 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
long schID = finsSche.scheme_id;
|
|
long schID = finsSche.scheme_id;
|
|
//查找此方案下的所有的测试项,并增加到测试项详细表中
|
|
//查找此方案下的所有的测试项,并增加到测试项详细表中
|
|
long? schINewID = _basicPlcTestSchemeService.FindByName(ScheduleName)?.scheme_id;
|
|
long? schINewID = _basicPlcTestSchemeService.FindByName(ScheduleName)?.scheme_id;
|
|
- var schDtls = _basicPlcTestSchemeDtlService.QueryList()?.FindAll(x => x.scheme_id == schID);
|
|
|
|
- foreach (var unit in schDtls)
|
|
|
|
|
|
+ //这里要注意顺序,所以用了SchProjectList循环
|
|
|
|
+ foreach (var sch in SchProjectList)
|
|
{
|
|
{
|
|
- bas_plc_test_scheme_dtl schDtlDto = new bas_plc_test_scheme_dtl();
|
|
|
|
- schDtlDto.scheme_id = schINewID;
|
|
|
|
- schDtlDto.item_name = unit.item_name;
|
|
|
|
-
|
|
|
|
- schDtlDto.item_type = unit.item_type;
|
|
|
|
- schDtlDto.precondition = unit.precondition;
|
|
|
|
- schDtlDto.precondition_describe = unit.precondition_describe;
|
|
|
|
- schDtlDto.action = unit.action;
|
|
|
|
- schDtlDto.action_describe = unit.action_describe;
|
|
|
|
- schDtlDto.judgement_result = unit.judgement_result;
|
|
|
|
- schDtlDto.judgement_result_describe = unit.judgement_result_describe;
|
|
|
|
- schDtlDto.create_by = Appsession.UserName;
|
|
|
|
- schDtlDto.create_time = DateTime.Now;
|
|
|
|
- schDtlDto.update_time = DateTime.Now;
|
|
|
|
- schDtlDto.update_by = Appsession.UserName;
|
|
|
|
- bool isAddSucc = _basicPlcTestSchemeDtlService.Add(schDtlDto);
|
|
|
|
- _logger.LogInformation($"复制方案成功。方案名{ScheduleName}");
|
|
|
|
|
|
+ if(sch.IsSelected)
|
|
|
|
+ {
|
|
|
|
+ int dtlId = Convert.ToInt32(sch.Id);
|
|
|
|
+ var unit = _basicPlcTestSchemeDtlService.Find(dtlId);
|
|
|
|
+ if (unit != null)
|
|
|
|
+ {
|
|
|
|
+ bas_plc_test_scheme_dtl schDtlDto = new bas_plc_test_scheme_dtl();
|
|
|
|
+ schDtlDto.scheme_id = schINewID;
|
|
|
|
+ schDtlDto.item_name = unit.item_name;
|
|
|
|
+
|
|
|
|
+ schDtlDto.item_type = unit.item_type;
|
|
|
|
+ schDtlDto.precondition = unit.precondition;
|
|
|
|
+ schDtlDto.precondition_describe = unit.precondition_describe;
|
|
|
|
+ schDtlDto.action = unit.action;
|
|
|
|
+ schDtlDto.action_describe = unit.action_describe;
|
|
|
|
+ schDtlDto.judgement_result = unit.judgement_result;
|
|
|
|
+ schDtlDto.judgement_result_describe = unit.judgement_result_describe;
|
|
|
|
+ schDtlDto.create_by = Appsession.UserName;
|
|
|
|
+ schDtlDto.create_time = DateTime.Now;
|
|
|
|
+ schDtlDto.update_time = DateTime.Now;
|
|
|
|
+ schDtlDto.update_by = Appsession.UserName;
|
|
|
|
+ bool isAddSucc = _basicPlcTestSchemeDtlService.Add(schDtlDto);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ _logger.LogInformation($"复制方案成功。方案名{ScheduleName}");
|
|
}
|
|
}
|
|
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
|
|
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
|
|
}
|
|
}
|
|
@@ -140,10 +219,10 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
}
|
|
}
|
|
SchProjectList.Add(new SelectItemModel
|
|
SchProjectList.Add(new SelectItemModel
|
|
{
|
|
{
|
|
|
|
+ Id = unit.scheme_dtl_id,
|
|
ItemName = unit.item_name,
|
|
ItemName = unit.item_name,
|
|
-
|
|
|
|
- ItemType= itemType,
|
|
|
|
- }) ;
|
|
|
|
|
|
+ ItemType = itemType,
|
|
|
|
+ }); ;
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -152,6 +231,13 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
}
|
|
}
|
|
#region 命令绑定
|
|
#region 命令绑定
|
|
public DelegateCommand<string> SureCommand { set; get; }
|
|
public DelegateCommand<string> SureCommand { set; get; }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public DelegateCommand<object> DownCommand { set; get; }
|
|
|
|
+ public DelegateCommand<object> UpCommand { set; get; }
|
|
|
|
+ public DelegateCommand<object> SelectAllCommand { set; get; }
|
|
|
|
+ public DelegateCommand<object> UnSelectAllCommand { set; get; }
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
#region 数据绑定
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -172,12 +258,16 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
|
|
get { return deviceName; }
|
|
get { return deviceName; }
|
|
set { deviceName = value; RaisePropertyChanged(); }
|
|
set { deviceName = value; RaisePropertyChanged(); }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
private ObservableCollection<SelectItemModel> schProjectList = new ObservableCollection<SelectItemModel>();
|
|
private ObservableCollection<SelectItemModel> schProjectList = new ObservableCollection<SelectItemModel>();
|
|
public ObservableCollection<SelectItemModel> SchProjectList
|
|
public ObservableCollection<SelectItemModel> SchProjectList
|
|
{
|
|
{
|
|
get { return schProjectList; }
|
|
get { return schProjectList; }
|
|
set { SetProperty(ref schProjectList, value); }
|
|
set { SetProperty(ref schProjectList, value); }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|