using Prism.Dialogs; using SWS.CAD.Models; using SWS.CAD.Services; using SWS.CAD.ViewModels.myViewModelBase; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows.Input; using Telerik.Windows.Controls; using Unity; using SWS.CAD.Views.SignalManagementViews; using System; using Newtonsoft.Json.Converters; using Newtonsoft.Json; using Bricscad.EditorInput; namespace SWS.CAD.ViewModels { public class DialogSignalPropertyhisAndLogsViewModel : DialogBase, IDialogAware { #region 属性 private SignalManagementInfo _SignalInfo; /// /// 传入选中的信号对象 /// public SignalManagementInfo SignalInfo { get { return _SignalInfo; } set { _SignalInfo = value; RaisePropertyChanged(nameof(SignalInfo)); } } private ObservableCollection _MySignalLogs = new ObservableCollection(); /// /// 表格数据源 /// public ObservableCollection MySignalLogs { get { return _MySignalLogs; } set { _MySignalLogs = value; RaisePropertyChanged(nameof(MySignalLogs)); } } private SignalLog _SelectedSignalLog; /// /// 选中行 /// public SignalLog SelectedSignalLog { get { return _SelectedSignalLog; } set { _SelectedSignalLog = value; RaisePropertyChanged(nameof(SelectedSignalLog)); } } private ObservableCollection _MySingnalPropertyhis = new ObservableCollection(); /// /// 表格数据源 /// public ObservableCollection MySingnalPropertyhis { get { return _MySingnalPropertyhis; } set { _MySingnalPropertyhis = value; RaisePropertyChanged(nameof(MySingnalPropertyhis)); } } private SingnalPropertyhis _SelectedPropertyhi; /// /// 选中行 /// public SingnalPropertyhis SelectedPropertyhi { get { return _SelectedPropertyhi; } set { _SelectedPropertyhi = value; RaisePropertyChanged(nameof(SelectedPropertyhi)); } } /// /// 信号接口服务 /// WireGroupService _wireGroupService; #endregion public DialogSignalPropertyhisAndLogsViewModel() { _wireGroupService = GlobalObject.container.Resolve(); } public DialogCloseListener RequestClose { get; } public bool CanCloseDialog() { return true; } public void OnDialogClosed() { } private List SignalLogs; private List SignalPropertyhis; public async void OnDialogOpened(IDialogParameters parameters) { SignalInfo = parameters.GetValue(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) { Prism.Dialogs.DialogParameters res = new Prism.Dialogs.DialogParameters(); //res.Add(GlobalObject.dialogPar.info.ToString(), $"{TextInfo}"); RequestClose.Invoke(res, ButtonResult.Yes); } public override void ExecuteCloseCommand(object parameter) { if (parameter as string == "ClickNo") { RequestClose.Invoke(ButtonResult.No); } else { RequestClose.Invoke(ButtonResult.Cancel); } this.Dispose(); } #region 右侧按钮 public ICommand ButtonCmd => new DelegateCommand(Button_Click); /// /// 页面右侧按钮 /// /// public virtual async void Button_Click(object parameter) { #region 确定 if (parameter.Equals("确定")) { RequestClose.Invoke(ButtonResult.Cancel); this.Dispose(); } #endregion #region 取消 if (parameter.Equals("取消")) { RequestClose.Invoke(ButtonResult.Cancel); this.Dispose(); } #endregion } #endregion } public class SignalLog: DialogBase { #region 属性 private int _ID; /// /// 序号 /// 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 Models.Action _OperateType; /// /// 操作 /// public Models.Action OperateType { get { return _OperateType; } set { _OperateType = value; } } private string _ExtraMsg; /// /// 附加信息 /// public string ExtraMsg { get { return _ExtraMsg; } set { _ExtraMsg = value; } } private string _CreateUserID; public string CreateUserID { get { return _CreateUserID; } set { _CreateUserID = value; } } private string _CreateUserName; /// /// 操作人 /// public string CreateUserName { get { return _CreateUserName; } set { _CreateUserName = value; } } private DateTime? _CreateTime; /// /// 操作时间 /// /// 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 } /// /// 设置数据 /// public void setData() { } #endregion } public class SingnalPropertyhis : DialogBase { #region 属性 private int _ID; /// /// 序号 /// public int ID { get { return _ID; } set { _ID = value; } } private string _PropertyName; /// /// 属性 /// public string PropertyName { get { return _PropertyName; } set { _PropertyName = value; } } private string _PropertyNameDec; /// /// 属性名称描述 /// public string PropertyNameDec { get { return _PropertyNameDec; } set { _PropertyNameDec = value; } } private string _OldPropertyValue; /// /// 旧属性值 /// public string OldPropertyValue { get { return _OldPropertyValue; } set { _OldPropertyValue = value; } } private string _NewPropertyValue; /// /// 新属性值 /// public string NewPropertyValue { get { return _NewPropertyValue; } set { _NewPropertyValue = value; } } private string _CreateUserName; /// /// 修改人 /// public string CreateUserName { get { return _CreateUserName; } set { _CreateUserName = value; } } private DateTime? _CreateTime; /// /// 修改时间 /// 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 } }