009_DI-Elec/newFront/c#前端/SWS.CAD/ViewModels/DialogIODistributionVM/DialogCablePreAssignResultViewModel.cs
CHEN-ZW\acer 8fa07593ac Merge branch 'main' of http://27.154.35.18:7053/yuxingheng/009_DI-Elec
# Conflicts:
#	Learun.Framework.Module/Learun.Db/Learun.DataBase.EF.Oracle/obj/Debug/Learun.DataBase.Oracle.csproj.AssemblyReference.cache
#	Learun.Framework.Module/Learun.Db/Learun.DataBase.EF.Sqlserver/obj/Debug/Learun.DataBase.SqlServer.csproj.AssemblyReference.cache
#	Learun.Framework.Module/Learun.Db/Learun.DataBase.MySql/obj/Debug/Learun.DataBase.MySqlEx.csproj.AssemblyReference.cache
2025-09-22 10:02:17 +08:00

281 lines
9.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using SWS.CAD.ViewModels.myViewModelBase;
using System.Windows.Input;
using Telerik.Windows.Controls;
using Prism.Services.Dialogs;
using SWS.Commons;
using SWS.Model;
using SWS.Service;
using Unity;
using System.Linq;
using Telerik.Windows.Controls.MaskedInput.Tokens.Numeric;
namespace SWS.CAD.ViewModels
{
public class DialogCablePreAssignResultViewModel : DialogBase, IDialogAware
{
#region
private ObservableCollection<PreAllocationResult> _PreAllocationResultls = new ObservableCollection<PreAllocationResult>();
/// <summary>
/// 预分配结果表格源
/// </summary>
public ObservableCollection<PreAllocationResult> PreAllocationResultls
{
get { return _PreAllocationResultls; }
set
{
_PreAllocationResultls = value;
RaisePropertyChanged(nameof(PreAllocationResultls));
}
}
private string _SuccessOrFailure = "分配成功";
/// <summary>
/// 选择成功还是选择失败
/// </summary>
public string SuccessOrFailure
{
get { return _SuccessOrFailure; }
set
{
_SuccessOrFailure = value;
RaisePropertyChanged(nameof(SuccessOrFailure));
UpdataPreAssignCables();
}
}
private ObservableCollection<ec_Cable> _PreAssignCables = new ObservableCollection<ec_Cable>();
/// <summary>
/// 左侧预分配电缆列表
/// </summary>
public ObservableCollection<ec_Cable> PreAssignCables
{
get { return _PreAssignCables; }
set
{
_PreAssignCables = value;
RaisePropertyChanged(nameof(PreAssignCables));
}
}
private ec_Cable _SelectedPreAssignCable;
/// <summary>
/// 选择的预分配电缆
/// </summary>
public ec_Cable SelectedPreAssignCable
{
get { return _SelectedPreAssignCable; }
set
{
_SelectedPreAssignCable = value;
RaisePropertyChanged(nameof(SelectedPreAssignCable));
UpdataPreAllocationResultls(_SelectedPreAssignCable);
}
}
#endregion
IOModuleService _iOModuleService;
public DialogCablePreAssignResultViewModel()
{
_iOModuleService = GlobalObject.container.Resolve<IOModuleService>();
}
public string Title => "";
public event Action<IDialogResult> RequestClose;
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
//全部预分配电缆
private List<ec_Cable> AllPreAssignCables;
public async void OnDialogOpened(IDialogParameters parameters)
{
//title = parameters.GetValue<string>(GlobalObject.dialogPar.title.ToString());
title = "信号预分配结果";
AllPreAssignCables = await _iOModuleService.AutoAssignCable2channel_step2();
UpdataPreAssignCables();
}
public override async void ExecuteOKCommandAsync(object para)
{
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);
//返回结果
IDialogParameters res = new Prism.Services.Dialogs.DialogParameters();
//res.Add(GlobalObject.dialogPar.para1.ToString(), SelectedStripParametersInfo);
RequestClose.Invoke(new DialogResult(ButtonResult.Yes, res));
}
public override void ExecuteCloseCommand(object parameter)
{
if (parameter as string == "ClickNo")
{
DialogResult res = new DialogResult(ButtonResult.No);
RequestClose.Invoke(res);
}
else
{
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
}
this.Dispose();
}
#region
/// <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);
}
}
}
public ICommand EditEndCmd => new DelegateCommand(EditEnd);
/// <summary>
/// 编辑结束事件
/// </summary>
/// <param name="parameter"></param>
public virtual void EditEnd(object parameter)
{
//做个标记表示该项修改过
}
#endregion
}
/// <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; }
}
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; }
}
}
}