2025-08-15 16:34:31 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using SWS.CAD.ViewModels.myViewModelBase;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using Telerik.Windows.Controls;
|
2025-09-04 18:28:02 +08:00
|
|
|
|
using Prism.Services.Dialogs;
|
|
|
|
|
using SWS.Commons;
|
|
|
|
|
using SWS.Model;
|
2025-09-22 10:02:17 +08:00
|
|
|
|
using SWS.Service;
|
|
|
|
|
using Unity;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Telerik.Windows.Controls.MaskedInput.Tokens.Numeric;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
|
|
|
|
|
namespace SWS.CAD.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class DialogCablePreAssignResultViewModel : DialogBase, IDialogAware
|
|
|
|
|
{
|
|
|
|
|
#region 字段
|
2025-09-22 10:02:17 +08:00
|
|
|
|
private ObservableCollection<PreAllocationResult> _PreAllocationResultls = new ObservableCollection<PreAllocationResult>();
|
2025-08-15 16:34:31 +08:00
|
|
|
|
/// <summary>
|
2025-09-22 10:02:17 +08:00
|
|
|
|
/// 预分配结果表格源
|
2025-08-15 16:34:31 +08:00
|
|
|
|
/// </summary>
|
2025-09-22 10:02:17 +08:00
|
|
|
|
public ObservableCollection<PreAllocationResult> PreAllocationResultls
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
get { return _PreAllocationResultls; }
|
2025-08-15 16:34:31 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
_PreAllocationResultls = value;
|
|
|
|
|
RaisePropertyChanged(nameof(PreAllocationResultls));
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-09-22 10:02:17 +08:00
|
|
|
|
private string _SuccessOrFailure = "分配成功";
|
2025-08-15 16:34:31 +08:00
|
|
|
|
/// <summary>
|
2025-09-22 10:02:17 +08:00
|
|
|
|
/// 选择成功还是选择失败
|
2025-08-15 16:34:31 +08:00
|
|
|
|
/// </summary>
|
2025-09-22 10:02:17 +08:00
|
|
|
|
public string SuccessOrFailure
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
get { return _SuccessOrFailure; }
|
2025-08-15 16:34:31 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
_SuccessOrFailure = value;
|
|
|
|
|
RaisePropertyChanged(nameof(SuccessOrFailure));
|
|
|
|
|
UpdataPreAssignCables();
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-22 10:02:17 +08:00
|
|
|
|
|
|
|
|
|
private ObservableCollection<ec_Cable> _PreAssignCables = new ObservableCollection<ec_Cable>();
|
2025-08-15 16:34:31 +08:00
|
|
|
|
/// <summary>
|
2025-09-22 10:02:17 +08:00
|
|
|
|
/// 左侧预分配电缆列表
|
2025-08-15 16:34:31 +08:00
|
|
|
|
/// </summary>
|
2025-09-22 10:02:17 +08:00
|
|
|
|
public ObservableCollection<ec_Cable> PreAssignCables
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
get { return _PreAssignCables; }
|
2025-08-15 16:34:31 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
_PreAssignCables = value;
|
|
|
|
|
RaisePropertyChanged(nameof(PreAssignCables));
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-22 10:02:17 +08:00
|
|
|
|
|
|
|
|
|
private ec_Cable _SelectedPreAssignCable;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
/// <summary>
|
2025-09-22 10:02:17 +08:00
|
|
|
|
/// 选择的预分配电缆
|
2025-08-15 16:34:31 +08:00
|
|
|
|
/// </summary>
|
2025-09-22 10:02:17 +08:00
|
|
|
|
public ec_Cable SelectedPreAssignCable
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
get { return _SelectedPreAssignCable; }
|
2025-08-15 16:34:31 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
_SelectedPreAssignCable = value;
|
|
|
|
|
RaisePropertyChanged(nameof(SelectedPreAssignCable));
|
|
|
|
|
UpdataPreAllocationResultls(_SelectedPreAssignCable);
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2025-09-22 10:02:17 +08:00
|
|
|
|
IOModuleService _iOModuleService;
|
|
|
|
|
public DialogCablePreAssignResultViewModel()
|
|
|
|
|
{
|
|
|
|
|
_iOModuleService = GlobalObject.container.Resolve<IOModuleService>();
|
|
|
|
|
}
|
2025-09-04 18:28:02 +08:00
|
|
|
|
public string Title => "";
|
|
|
|
|
|
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
public bool CanCloseDialog()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnDialogClosed()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-22 10:02:17 +08:00
|
|
|
|
//全部预分配电缆
|
|
|
|
|
private List<ec_Cable> AllPreAssignCables;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
public async void OnDialogOpened(IDialogParameters parameters)
|
|
|
|
|
{
|
|
|
|
|
//title = parameters.GetValue<string>(GlobalObject.dialogPar.title.ToString());
|
|
|
|
|
title = "信号预分配结果";
|
2025-09-22 10:02:17 +08:00
|
|
|
|
AllPreAssignCables = await _iOModuleService.AutoAssignCable2channel_step2();
|
|
|
|
|
UpdataPreAssignCables();
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-09-22 10:02:17 +08:00
|
|
|
|
public override async void ExecuteOKCommandAsync(object para)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
var Cables = new List<ec_Cable>();
|
|
|
|
|
if (AllPreAssignCables != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var PreAssignCable in AllPreAssignCables)
|
|
|
|
|
{
|
|
|
|
|
if (PreAssignCable.Sets != null && !string.IsNullOrEmpty(PreAssignCable.Sets.FirstOrDefault().ConnectionInfo))
|
|
|
|
|
{
|
|
|
|
|
Cables.Add(PreAssignCable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var resHttp = await _iOModuleService.AutoAssignCable2channel_step3(Cables);
|
2025-08-15 16:34:31 +08:00
|
|
|
|
//返回结果
|
2025-09-04 18:28:02 +08:00
|
|
|
|
IDialogParameters res = new Prism.Services.Dialogs.DialogParameters();
|
2025-08-15 16:34:31 +08:00
|
|
|
|
//res.Add(GlobalObject.dialogPar.para1.ToString(), SelectedStripParametersInfo);
|
2025-09-04 18:28:02 +08:00
|
|
|
|
RequestClose.Invoke(new DialogResult(ButtonResult.Yes, res));
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
public override void ExecuteCloseCommand(object parameter)
|
|
|
|
|
{
|
|
|
|
|
if (parameter as string == "ClickNo")
|
|
|
|
|
{
|
2025-09-04 18:28:02 +08:00
|
|
|
|
DialogResult res = new DialogResult(ButtonResult.No);
|
|
|
|
|
RequestClose.Invoke(res);
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-09-04 18:28:02 +08:00
|
|
|
|
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
this.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 方法
|
2025-09-22 10:02:17 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改预分配电缆列表,成功或者失败的电缆列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void UpdataPreAssignCables()
|
|
|
|
|
{
|
|
|
|
|
PreAssignCables = new ObservableCollection<ec_Cable>();
|
|
|
|
|
if (AllPreAssignCables != null)
|
|
|
|
|
{
|
|
|
|
|
if (SuccessOrFailure.Equals("分配成功"))
|
|
|
|
|
{
|
|
|
|
|
foreach (var PreAssignCable in AllPreAssignCables)
|
|
|
|
|
{
|
|
|
|
|
if (PreAssignCable.Sets != null && !string.IsNullOrEmpty(PreAssignCable.Sets.FirstOrDefault().ConnectionInfo))
|
|
|
|
|
{
|
|
|
|
|
PreAssignCables.Add(PreAssignCable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var PreAssignCable in AllPreAssignCables)
|
|
|
|
|
{
|
|
|
|
|
if (PreAssignCable.Sets == null || string.IsNullOrEmpty(PreAssignCable.Sets.FirstOrDefault().ConnectionInfo))
|
|
|
|
|
{
|
|
|
|
|
PreAssignCables.Add(PreAssignCable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改表格显示数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void UpdataPreAllocationResultls(ec_Cable cable)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
PreAllocationResultls = new ObservableCollection<PreAllocationResult>();
|
|
|
|
|
if (cable == null) return;
|
|
|
|
|
if (cable.Sets != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var Set in cable.Sets)
|
|
|
|
|
{
|
|
|
|
|
PreAllocationResult preAllocationResult = new PreAllocationResult();
|
|
|
|
|
preAllocationResult.CablePair = Set.CableSetName;
|
|
|
|
|
preAllocationResult.IOType = cable.PreAssignIOType;
|
|
|
|
|
preAllocationResult.ToPanel_TagNumber = cable.ToPanel == null ? "" : cable.ToPanel.TagNumber;
|
|
|
|
|
preAllocationResult.Panel_TagNumber = string.IsNullOrEmpty(Set.ConnectionInfo) ? "" : Set.ConnectionInfo.Split('/')[0].Split(':')[1].Trim();
|
|
|
|
|
preAllocationResult.StripName = string.IsNullOrEmpty(Set.ConnectionInfo) ? "" : Set.ConnectionInfo.Split('/')[1].Split(':')[1].Trim();
|
|
|
|
|
preAllocationResult.Terms = new ObservableCollection<ec_PanelStripTerm>(Set.AssignedTerms);
|
|
|
|
|
PreAllocationResultls.Add(preAllocationResult);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-15 16:34:31 +08:00
|
|
|
|
public ICommand EditEndCmd => new DelegateCommand(EditEnd);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑结束事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parameter"></param>
|
|
|
|
|
public virtual void EditEnd(object parameter)
|
|
|
|
|
{
|
|
|
|
|
//做个标记表示该项修改过
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
2025-09-22 10:02:17 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 预分配结果类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class PreAllocationResult : DialogBase
|
|
|
|
|
{
|
|
|
|
|
private string _CablePair;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 电缆对
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string CablePair
|
|
|
|
|
{
|
|
|
|
|
get { return _CablePair; }
|
|
|
|
|
set { _CablePair = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _IOType;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// IO类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string IOType
|
|
|
|
|
{
|
|
|
|
|
get { return _IOType; }
|
|
|
|
|
set { _IOType = value; }
|
|
|
|
|
}
|
2025-08-15 16:34:31 +08:00
|
|
|
|
|
|
|
|
|
|
2025-09-22 10:02:17 +08:00
|
|
|
|
private string _ToPanel_TagNumber;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 预分配的系统柜
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ToPanel_TagNumber
|
|
|
|
|
{
|
|
|
|
|
get { return _ToPanel_TagNumber; }
|
|
|
|
|
set { _ToPanel_TagNumber = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _Panel_TagNumber;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 实际分配的系统柜
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Panel_TagNumber
|
|
|
|
|
{
|
|
|
|
|
get { return _Panel_TagNumber; }
|
|
|
|
|
set { _Panel_TagNumber = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _StripName;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 实际分配的端子排
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string StripName
|
|
|
|
|
{
|
|
|
|
|
get { return _StripName; }
|
|
|
|
|
set { _StripName = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<ec_PanelStripTerm> _Terms;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 实际端子
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<ec_PanelStripTerm> Terms
|
|
|
|
|
{
|
|
|
|
|
get { return _Terms; }
|
|
|
|
|
set { _Terms = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-08-15 16:34:31 +08:00
|
|
|
|
|
|
|
|
|
}
|