417 lines
11 KiB
C#
417 lines
11 KiB
C#
|
|
|
|
using SWS.CAD.ViewModels.myViewModelBase;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Windows.Input;
|
|
using Telerik.Windows.Controls;
|
|
using Unity;
|
|
using SWS.CAD.Views.SignalManagementViews;
|
|
using Prism.Services.Dialogs;
|
|
using SWS.Commons;
|
|
using SWS.Model;
|
|
using SWS.Service;
|
|
using System;
|
|
|
|
namespace SWS.CAD.ViewModels
|
|
{
|
|
public class DialogSignalNoticeViewModel : DialogBase, IDialogAware
|
|
{
|
|
#region 属性
|
|
private ObservableCollection<SignalNotice> _MySignalNotices = new ObservableCollection<SignalNotice>();
|
|
/// <summary>
|
|
/// 表格数据源
|
|
/// </summary>
|
|
public ObservableCollection<SignalNotice> MySignalNotices
|
|
{
|
|
get { return _MySignalNotices; }
|
|
set { _MySignalNotices = value; RaisePropertyChanged(nameof(MySignalNotices)); }
|
|
}
|
|
private SignalNotice _SelectedSignalNotice;
|
|
/// <summary>
|
|
/// 选中行
|
|
/// </summary>
|
|
public SignalNotice SelectedSignalNotice
|
|
{
|
|
get { return _SelectedSignalNotice; }
|
|
set { _SelectedSignalNotice = value; RaisePropertyChanged(nameof(SelectedSignalNotice)); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 信号接口服务
|
|
/// </summary>
|
|
WireGroupService _wireGroupService;
|
|
|
|
public DialogSignalNotice SignalNoticeView { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public DialogSignalNoticeViewModel()
|
|
{
|
|
title = "通知信息";
|
|
_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_notice> SignalNotices;
|
|
public async void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
SignalNotices = await _wireGroupService.GetNotification();
|
|
int index = 0;
|
|
foreach (var item in SignalNotices)
|
|
{
|
|
index++;
|
|
SignalNotice s= new SignalNotice(item);
|
|
s.ID = index;
|
|
MySignalNotices.Add(s);
|
|
}
|
|
|
|
}
|
|
public override void ExecuteOKCommandAsync(object para)
|
|
{
|
|
IDialogParameters res = new Prism.Services.Dialogs.DialogParameters();
|
|
//res.Add(GlobalObject.dialogPar.info.ToString(), $"{TextInfo}");
|
|
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 状态按钮
|
|
public ICommand StatusButtonCmd => new DelegateCommand(StatusButton_Click);
|
|
/// <summary>
|
|
/// 显示状态按钮
|
|
/// </summary>
|
|
/// <param name="parameter"></param>
|
|
public virtual async void StatusButton_Click(object parameter)
|
|
{
|
|
MySignalNotices = new ObservableCollection<SignalNotice>();
|
|
|
|
SignalNotices = await _wireGroupService.GetNotification();
|
|
if (!parameter.Equals("All"))
|
|
{
|
|
SignalNotices = SignalNotices.Where(s => s.CheckFLG.ToString().Equals(parameter)).ToList();
|
|
}
|
|
|
|
int index = 0;
|
|
foreach (var item in SignalNotices)
|
|
{
|
|
index++;
|
|
SignalNotice s = new SignalNotice(item);
|
|
s.ID = index;
|
|
MySignalNotices.Add(s);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#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("确定"))
|
|
{
|
|
List<string> noticeIds = new List<string>();
|
|
foreach (var item in MySignalNotices)
|
|
{
|
|
noticeIds = MySignalNotices.Where(e => e.IsModified == true).Select(e => e.WireGroupNoticeID).ToList();
|
|
}
|
|
List<ec_wire_group_notice> ReNotices = await _wireGroupService.ReadNotification(noticeIds);
|
|
foreach (var item in ReNotices)
|
|
{
|
|
var ent = MySignalNotices.FirstOrDefault(x => x.WireGroupNoticeID == item.WireGroupNoticeID);
|
|
if (ent != null)
|
|
{
|
|
ent.UpdateTime = item.UpdateTime;
|
|
}
|
|
}
|
|
|
|
|
|
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
|
|
this.Dispose();
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 取消
|
|
if (parameter.Equals("取消"))
|
|
{
|
|
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
|
|
this.Dispose();
|
|
}
|
|
#endregion
|
|
|
|
#region 已阅
|
|
if (parameter.Equals("已阅"))
|
|
{
|
|
|
|
if (SelectedSignalNotice == null)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (!SelectedSignalNotice.CheckFLG)
|
|
{
|
|
SelectedSignalNotice.CheckFLG = true;
|
|
SelectedSignalNotice.IsModified = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 全部已阅
|
|
if (parameter.Equals("全部已阅"))
|
|
{
|
|
foreach (var item in MySignalNotices)
|
|
{
|
|
if (!item.CheckFLG)
|
|
{
|
|
item.CheckFLG = true;
|
|
item.IsModified = true;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
public class SignalNotice: DialogBase
|
|
{
|
|
#region 属性
|
|
private int _ID;
|
|
/// <summary>
|
|
/// 序号
|
|
/// </summary>
|
|
public int ID
|
|
{
|
|
get { return _ID; }
|
|
set { _ID = value; }
|
|
}
|
|
|
|
private string _WireGroupNoticeID;
|
|
/// <summary>
|
|
/// 信号通知ID
|
|
/// </summary>
|
|
public string WireGroupNoticeID
|
|
{
|
|
get { return _WireGroupNoticeID; }
|
|
set { _WireGroupNoticeID = value; }
|
|
}
|
|
|
|
private string _Group_Name;
|
|
/// <summary>
|
|
/// CH.NO
|
|
/// </summary>
|
|
public string Group_Name
|
|
{
|
|
get { return _Group_Name; }
|
|
set { _Group_Name = value; }
|
|
}
|
|
private string _Group_Desc;
|
|
/// <summary>
|
|
/// z中文描述
|
|
/// </summary>
|
|
public string Group_Desc
|
|
{
|
|
get { return _Group_Desc; }
|
|
set { _Group_Desc = value; }
|
|
}
|
|
|
|
|
|
private string _Group_Desc_EN;
|
|
/// <summary>
|
|
/// 英文描述
|
|
/// </summary>
|
|
public string Group_Desc_EN
|
|
{
|
|
get { return _Group_Desc_EN; }
|
|
set { _Group_Desc_EN = value; }
|
|
}
|
|
|
|
private string _IO_Type;
|
|
/// <summary>
|
|
/// 信号类型
|
|
/// </summary>
|
|
public string IO_Type
|
|
{
|
|
get { return _IO_Type; }
|
|
set { _IO_Type = value; }
|
|
}
|
|
|
|
private Model.Action _ActionID;
|
|
/// <summary>
|
|
/// 操作ID
|
|
/// </summary>
|
|
public Model.Action ActionID
|
|
{
|
|
get { return _ActionID; }
|
|
set { _ActionID = value; }
|
|
}
|
|
|
|
private string _Action;
|
|
/// <summary>
|
|
/// 操作
|
|
/// </summary>
|
|
public string Action
|
|
{
|
|
get { return _Action; }
|
|
set { _Action = 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; }
|
|
}
|
|
|
|
private string _UpdateUserName;
|
|
/// <summary>
|
|
/// 已阅人
|
|
/// </summary>
|
|
public string UpdateUserName
|
|
{
|
|
get { return _UpdateUserName; }
|
|
set { _UpdateUserName = value; }
|
|
}
|
|
|
|
private DateTime? _UpdateTime;
|
|
/// <summary>
|
|
/// 已阅时间
|
|
/// </summary>
|
|
public DateTime? UpdateTime
|
|
{
|
|
get { return _UpdateTime; }
|
|
set { _UpdateTime = value; }
|
|
}
|
|
|
|
private string _Message;
|
|
/// <summary>
|
|
/// 操作信息
|
|
/// </summary>
|
|
public string Message
|
|
{
|
|
get { return _Message; }
|
|
set { _Message = value; }
|
|
}
|
|
|
|
private bool _CheckFLG;
|
|
/// <summary>
|
|
/// 是否已读
|
|
/// </summary>
|
|
public bool CheckFLG
|
|
{
|
|
get { return _CheckFLG; }
|
|
set { _CheckFLG = value; }
|
|
}
|
|
|
|
private bool _IsModified;
|
|
/// <summary>
|
|
/// 是否修改
|
|
/// </summary>
|
|
public bool IsModified
|
|
{
|
|
get { return _IsModified; }
|
|
set { _IsModified = value; RaisePropertyChanged(nameof(IsModified)); }
|
|
}
|
|
|
|
private bool _IsReadOnly;
|
|
/// <summary>
|
|
/// 是否可编辑
|
|
/// </summary>
|
|
public bool IsReadOnly
|
|
{
|
|
get { return _IsReadOnly; }
|
|
set { _IsReadOnly = value; RaisePropertyChanged(nameof(IsReadOnly)); }
|
|
}
|
|
#endregion
|
|
|
|
#region 方法
|
|
public SignalNotice()
|
|
{
|
|
|
|
}
|
|
public SignalNotice(ec_wire_group_notice ec_Notice)
|
|
{
|
|
#region 前端表格对应列
|
|
this.Group_Name = ec_Notice.Group_Name;
|
|
this.Group_Desc = ec_Notice.Group_Desc;
|
|
this.Group_Desc_EN = ec_Notice.Group_Desc_EN;
|
|
this.IO_Type = ec_Notice.IO_Type;
|
|
this.Action = ec_Notice.Action;
|
|
this.CreateUserName = ec_Notice.CreateUserName;
|
|
this.CreateTime = ec_Notice.CreateTime;
|
|
this.UpdateUserName = ec_Notice.UpdateUserName;
|
|
this.UpdateTime = ec_Notice.UpdateTime;
|
|
this.Message = ec_Notice.Message;
|
|
#endregion
|
|
|
|
this.WireGroupNoticeID = ec_Notice.WireGroupNoticeID;
|
|
this.CheckFLG = ec_Notice.CheckFLG;
|
|
this.IsReadOnly = ec_Notice.CheckFLG;
|
|
}
|
|
/// <summary>
|
|
/// 设置数据
|
|
/// </summary>
|
|
public void setData()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
}
|