009_DI-Elec/newFront/c#前端/SWS.WPF/ViewModels/DialogSignalManagementVM/DialogSignalPropertyhisAndLogsViewModel.cs
2025-08-15 15:38:37 +08:00

380 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Prism.Services.Dialogs;
using Prism.Ioc;
using SWS.Commons;
using SWS.Model;
using SWS.Service;
using Telerik.Windows.Controls;
using Unity;
namespace SWS.WPF.ViewModels
{
public class DialogSignalPropertyhisAndLogsViewModel : DialogBase, IDialogAware
{
#region
private SignalManagementInfo _SignalInfo;
/// <summary>
/// 传入选中的信号对象
/// </summary>
public SignalManagementInfo SignalInfo
{
get { return _SignalInfo; }
set { _SignalInfo = value; RaisePropertyChanged(nameof(SignalInfo)); }
}
private ObservableCollection<SignalLog> _MySignalLogs = new ObservableCollection<SignalLog>();
/// <summary>
/// 表格数据源
/// </summary>
public ObservableCollection<SignalLog> MySignalLogs
{
get { return _MySignalLogs; }
set { _MySignalLogs = value; RaisePropertyChanged(nameof(MySignalLogs)); }
}
private SignalLog _SelectedSignalLog;
/// <summary>
/// 选中行
/// </summary>
public SignalLog SelectedSignalLog
{
get { return _SelectedSignalLog; }
set { _SelectedSignalLog = value; RaisePropertyChanged(nameof(SelectedSignalLog)); }
}
private ObservableCollection<SingnalPropertyhis> _MySingnalPropertyhis = new ObservableCollection<SingnalPropertyhis>();
/// <summary>
/// 表格数据源
/// </summary>
public ObservableCollection<SingnalPropertyhis> MySingnalPropertyhis
{
get { return _MySingnalPropertyhis; }
set { _MySingnalPropertyhis = value; RaisePropertyChanged(nameof(MySingnalPropertyhis)); }
}
private SingnalPropertyhis _SelectedPropertyhi;
/// <summary>
/// 选中行
/// </summary>
public SingnalPropertyhis SelectedPropertyhi
{
get { return _SelectedPropertyhi; }
set { _SelectedPropertyhi = value; RaisePropertyChanged(nameof(SelectedPropertyhi)); }
}
/// <summary>
/// 信号接口服务
/// </summary>
WireGroupService _wireGroupService;
#endregion
public DialogSignalPropertyhisAndLogsViewModel()
{
_wireGroupService =GlobalObject.container.Resolve<WireGroupService>();
}
public string Title => "";
public event Action<IDialogResult> RequestClose;
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
private List<ec_wire_group_log> SignalLogs;
private List<ec_wire_group_propertyhis> SignalPropertyhis;
public async void OnDialogOpened(IDialogParameters parameters)
{
SignalInfo = parameters.GetValue<SignalManagementInfo>(GlobalObject.dialogPar.para1.ToString());
title = SignalInfo.Group_Name + " 信号属性修改历史和操作记录";
SignalLogs = await _wireGroupService.GetSignalLogs(SignalInfo.Wire_Group_ID);
if(SignalLogs != null)
{
int index = 0;
foreach (var item in SignalLogs)
{
index++;
SignalLog s = new SignalLog(item);
s.ID = index;
MySignalLogs.Add(s);
}
}
SignalPropertyhis = await _wireGroupService.GetSignalPropertyhis(SignalInfo.Wire_Group_ID);
if (SignalPropertyhis != null)
{
int index = 0;
foreach (var item in SignalPropertyhis)
{
index++;
SingnalPropertyhis s = new SingnalPropertyhis(item);
s.ID = index;
MySingnalPropertyhis.Add(s);
}
}
}
public override void ExecuteOKCommandAsync(object para)
{
DialogResult result = new DialogResult(ButtonResult.Yes);
RequestClose.Invoke(result);
}
public override void ExecuteCloseCommand(object parameter)
{
if (parameter as string == "ClickNo")
{
DialogResult result = new DialogResult(ButtonResult.No);
RequestClose.Invoke(result);
}
else
{
DialogResult result = new DialogResult(ButtonResult.Cancel);
RequestClose.Invoke(result);
}
this.Dispose();
}
#region
public ICommand ButtonCmd => new DelegateCommand(Button_Click);
/// <summary>
/// 页面右侧按钮
/// </summary>
/// <param name="parameter"></param>
public virtual async void Button_Click(object parameter)
{
#region
if (parameter.Equals("确定"))
{
DialogResult result = new DialogResult(ButtonResult.Cancel);
RequestClose.Invoke(result);
this.Dispose();
}
#endregion
#region
if (parameter.Equals("取消"))
{
DialogResult result = new DialogResult(ButtonResult.Cancel);
RequestClose.Invoke(result);
this.Dispose();
}
#endregion
}
#endregion
}
public class SignalLog: DialogBase
{
#region
private int _ID;
/// <summary>
/// 序号
/// </summary>
public int ID
{
get { return _ID; }
set { _ID = value; }
}
private string _WireGroupLogID;
public string WireGroupLogID
{
get { return _WireGroupLogID; }
set { _WireGroupLogID = value; }
}
private string _WireGroupID;
public string WireGroupID
{
get { return _WireGroupID; }
set { _WireGroupID = value; }
}
[JsonConverter(typeof(StringEnumConverter))]
private Model.Action _OperateType;
/// <summary>
/// 操作
/// </summary>
public Model.Action OperateType
{
get { return _OperateType; }
set { _OperateType = value; }
}
private string _ExtraMsg;
/// <summary>
/// 附加信息
/// </summary>
public string ExtraMsg
{
get { return _ExtraMsg; }
set { _ExtraMsg = value; }
}
private string _CreateUserID;
public string CreateUserID
{
get { return _CreateUserID; }
set { _CreateUserID = value; }
}
private string _CreateUserName;
/// <summary>
/// 操作人
/// </summary>
public string CreateUserName
{
get { return _CreateUserName; }
set { _CreateUserName = value; }
}
private DateTime? _CreateTime;
/// <summary>
/// 操作时间
/// </summary>
/// <returns></returns>
public DateTime? CreateTime
{
get { return _CreateTime; }
set { _CreateTime = value; }
}
#endregion
#region
public SignalLog()
{
}
public SignalLog(ec_wire_group_log ec_Notice)
{
#region
this.OperateType = ec_Notice.OperateType;
this.ExtraMsg = ec_Notice.ExtraMsg;
this.CreateUserName = ec_Notice.CreateUserName;
this.CreateTime = ec_Notice.CreateTime;
#endregion
}
/// <summary>
/// 设置数据
/// </summary>
public void setData()
{
}
#endregion
}
public class SingnalPropertyhis : DialogBase
{
#region
private int _ID;
/// <summary>
/// 序号
/// </summary>
public int ID
{
get { return _ID; }
set { _ID = value; }
}
private string _PropertyName;
/// <summary>
/// 属性
/// </summary>
public string PropertyName
{
get { return _PropertyName; }
set { _PropertyName = value; }
}
private string _PropertyNameDec;
/// <summary>
/// 属性名称描述
/// </summary>
public string PropertyNameDec
{
get { return _PropertyNameDec; }
set { _PropertyNameDec = value; }
}
private string _OldPropertyValue;
/// <summary>
/// 旧属性值
/// </summary>
public string OldPropertyValue
{
get { return _OldPropertyValue; }
set { _OldPropertyValue = value; }
}
private string _NewPropertyValue;
/// <summary>
/// 新属性值
/// </summary>
public string NewPropertyValue
{
get { return _NewPropertyValue; }
set { _NewPropertyValue = value; }
}
private string _CreateUserName;
/// <summary>
/// 修改人
/// </summary>
public string CreateUserName
{
get { return _CreateUserName; }
set { _CreateUserName = value; }
}
private DateTime? _CreateTime;
/// <summary>
/// 修改时间
/// </summary>
public DateTime? CreateTime
{
get { return _CreateTime; }
set { _CreateTime = value; }
}
#endregion
#region
public SingnalPropertyhis(ec_wire_group_propertyhis ec_Wire_Group_Propertyhis)
{
#region
this.PropertyName = ec_Wire_Group_Propertyhis.PropertyName;
this.PropertyNameDec = ec_Wire_Group_Propertyhis.PropertyNameDec;
this.OldPropertyValue = ec_Wire_Group_Propertyhis.OldPropertyValue;
this.NewPropertyValue = ec_Wire_Group_Propertyhis.NewPropertyValue;
this.CreateUserName = ec_Wire_Group_Propertyhis.CreateUserName;
this._CreateTime = ec_Wire_Group_Propertyhis.CreateTime;
#endregion
}
#endregion
}
}