2025-08-15 16:34:31 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using SWS.CAD.ViewModels.myViewModelBase;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using Telerik.Windows.Controls;
|
|
|
|
|
using Prism.Ioc;
|
|
|
|
|
using SWS.CAD.Views.Dialog;
|
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 System.Windows;
|
|
|
|
|
using SWS.Service;
|
|
|
|
|
using Unity;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
|
|
|
|
|
namespace SWS.CAD.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class DialogCablePreAssignPreviewViewModel : DialogBase, IDialogAware
|
|
|
|
|
{
|
|
|
|
|
#region 字段
|
|
|
|
|
private ObservableCollection<PreAssignCable> _PreAssignCables = new ObservableCollection<PreAssignCable>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 端子排参数信息列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<PreAssignCable> PreAssignCables
|
|
|
|
|
{
|
|
|
|
|
get { return _PreAssignCables; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_PreAssignCables = value;
|
|
|
|
|
RaisePropertyChanged(nameof(PreAssignCables));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2025-09-22 10:02:17 +08:00
|
|
|
|
IOModuleService _iOModuleService;
|
|
|
|
|
public DialogCablePreAssignPreviewViewModel()
|
|
|
|
|
{
|
|
|
|
|
_iOModuleService = GlobalObject.container.Resolve<IOModuleService>();
|
|
|
|
|
}
|
2025-08-15 16:34:31 +08:00
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ec_Cable> CablePreAssigns;
|
|
|
|
|
public async void OnDialogOpened(IDialogParameters parameters)
|
|
|
|
|
{
|
|
|
|
|
//title = parameters.GetValue<string>(GlobalObject.dialogPar.title.ToString());
|
|
|
|
|
title = "待分配的信号预览和统计";
|
|
|
|
|
_PreAssignCables = parameters.GetValue<ObservableCollection<PreAssignCable>>(GlobalObject.dialogPar.para1.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-22 10:02:17 +08:00
|
|
|
|
public override async void ExecuteOKCommandAsync(object parameter)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
bool isShowDialog = false;
|
|
|
|
|
List<string> cableids = new List<string>();
|
|
|
|
|
foreach (var preAssignCable in PreAssignCables)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
if (preAssignCable.IsChecked)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
cableids.Add(preAssignCable.CableId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (cableids != null && cableids.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
bool AcceptNearbyPanel;
|
|
|
|
|
MessageBoxResult result = System.Windows.MessageBox.Show($"遇到I/O类型不合适的采集箱,是否需要自动更换就近的采集箱", "KunHengCAD", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
|
|
|
|
if (result == MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
AcceptNearbyPanel = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AcceptNearbyPanel = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ResHttp = await _iOModuleService.AutoAssignCable2channel_step1(cableids, AcceptNearbyPanel) as learunHttpRes<object>;
|
|
|
|
|
if (ResHttp.code == 200)
|
|
|
|
|
{
|
|
|
|
|
isShowDialog = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (AcceptNearbyPanel)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
result = System.Windows.MessageBox.Show($"{ResHttp.info}", "KunHengCAD", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
|
|
|
|
if (result == MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isShowDialog = true;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
|
2025-09-22 10:02:17 +08:00
|
|
|
|
}
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
2025-09-22 10:02:17 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var info = ResHttp.info;
|
|
|
|
|
// 找到第一个句号的位置
|
|
|
|
|
int firstPeriodIndex = info.IndexOf('。');
|
|
|
|
|
if (firstPeriodIndex >= 0)
|
|
|
|
|
{
|
|
|
|
|
// 从第一个句号后开始找第二个句号
|
|
|
|
|
int secondPeriodIndex = info.IndexOf('。', firstPeriodIndex + 1);
|
|
|
|
|
if (secondPeriodIndex >= 0)
|
|
|
|
|
{
|
|
|
|
|
// 截取到第二个句号(包括句号)
|
|
|
|
|
info = info.Substring(0, secondPeriodIndex + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.Windows.MessageBox.Show($"{info}", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isShowDialog)
|
|
|
|
|
{
|
|
|
|
|
//打开窗体
|
|
|
|
|
IDialogParameters para = new Prism.Services.Dialogs.DialogParameters();
|
|
|
|
|
para.Add(GlobalObject.dialogPar.para1.ToString(), PreAssignCables);
|
|
|
|
|
var _dialogService = GlobalObject._prismContainer.Resolve<IDialogService>();
|
|
|
|
|
_dialogService.ShowDialog(nameof(DialogCablePreAssignResult), para, async (RES) =>
|
|
|
|
|
{
|
|
|
|
|
if (RES.Result == ButtonResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (RES.Result == ButtonResult.No)
|
|
|
|
|
{ }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
2025-09-22 10:02:17 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
System.Windows.MessageBox.Show("未勾选预分配电缆", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-15 16:34:31 +08:00
|
|
|
|
//返回的结果
|
2025-09-22 10:02:17 +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-22 10:02:17 +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 方法
|
|
|
|
|
public ICommand EditEndCmd => new DelegateCommand(EditEnd);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑结束事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parameter"></param>
|
|
|
|
|
public virtual void EditEnd(object parameter)
|
|
|
|
|
{
|
|
|
|
|
//做个标记表示该项修改过
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 按钮
|
|
|
|
|
public ICommand ButtonCommand => new DelegateCommand(Button_Click);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 页面左侧按钮
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parameter"></param>
|
|
|
|
|
public virtual async void Button_Click(object parameter)
|
|
|
|
|
{
|
|
|
|
|
if (parameter.ToString().Equals("全选"))
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in PreAssignCables)
|
|
|
|
|
{
|
|
|
|
|
item.IsChecked = true;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-09-22 10:02:17 +08:00
|
|
|
|
if (parameter.ToString().Equals("清空"))
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
|
|
|
|
foreach (var item in PreAssignCables)
|
|
|
|
|
{
|
|
|
|
|
item.IsChecked = false;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-22 10:02:17 +08:00
|
|
|
|
public class PreAssignCable : DialogBase
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
|
|
|
|
#region 页面渲染字段
|
2025-09-22 10:02:17 +08:00
|
|
|
|
private string _CableId;
|
|
|
|
|
|
|
|
|
|
public string CableId
|
|
|
|
|
{
|
|
|
|
|
get { return _CableId; }
|
|
|
|
|
set { _CableId = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-08-15 16:34:31 +08:00
|
|
|
|
private int _Index;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 序号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Index
|
|
|
|
|
{
|
|
|
|
|
get { return _Index; }
|
|
|
|
|
set { _Index = value; }
|
|
|
|
|
}
|
|
|
|
|
private bool _IsChecked;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsChecked
|
|
|
|
|
{
|
|
|
|
|
get { return _IsChecked; }
|
2025-09-22 10:02:17 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_IsChecked = value;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
RaisePropertyChanged(nameof(IsChecked));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _TagNumber;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 电缆位号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string TagNumber
|
|
|
|
|
{
|
|
|
|
|
get { return _TagNumber; }
|
|
|
|
|
set { _TagNumber = value; }
|
|
|
|
|
}
|
|
|
|
|
private string _PreAssignIOType;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 预分配的信号类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string PreAssignIOType
|
|
|
|
|
{
|
|
|
|
|
get { return _PreAssignIOType; }
|
|
|
|
|
set { _PreAssignIOType = value; }
|
|
|
|
|
}
|
|
|
|
|
private string _CableClass;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否为母线
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string CableClass
|
|
|
|
|
{
|
|
|
|
|
get { return _CableClass; }
|
|
|
|
|
set { _CableClass = value; }
|
|
|
|
|
}
|
|
|
|
|
private string _ToPanel_TagNumber;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 预分配的系统柜
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ToPanel_TagNumber
|
|
|
|
|
{
|
|
|
|
|
get { return _ToPanel_TagNumber; }
|
|
|
|
|
set { _ToPanel_TagNumber = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PreAssignCable()
|
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
public PreAssignCable(ec_Cable ec_Cable)
|
|
|
|
|
{
|
2025-09-22 10:02:17 +08:00
|
|
|
|
CableId = ec_Cable.CableID;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
TagNumber = ec_Cable.TagNumber;
|
|
|
|
|
PreAssignIOType = ec_Cable.PreAssignIOType;
|
2025-09-22 10:02:17 +08:00
|
|
|
|
CableClass = ec_Cable.CableClass.Equals("homerun") ? "是" : "否";
|
|
|
|
|
ToPanel_TagNumber = ec_Cable.ToPanel != null ? ec_Cable.ToPanel.TagNumber : null;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|