Sic.Framework-Nanjing-Baishi/MECF.Framework.UI.Client/CenterViews/Maintain/MaintainerInfo.cs

300 lines
8.3 KiB
C#
Raw Normal View History

2024-01-29 11:12:21 +08:00
using Aitex.Core.Util;
using Caliburn.Micro.Core;
using DocumentFormat.OpenXml.Wordprocessing;
using MECF.Framework.Common.Aitex.Core.RT.EMS;
using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace MECF.Framework.UI.Client.CenterViews.Maintain
{
public class MaintainerInfo : PropertyChangedBase, ICloneable
{
private string _type = "Plan";
public string Type
{
get { return _type; }
set { _type = value; NotifyOfPropertyChange(nameof(Type)); }
}
private string _name = string.Empty;
public string Name
{
get { return _name; }
set { _name = value; NotifyOfPropertyChange(nameof(Name)); }
}
private int _index = 0;
public int Index
{
get { return _index; }
set { _index = value; NotifyOfPropertyChange(nameof(Index)); }
}
public string DisplayName
{
get { return Type + ":" + Name + (Module == "" ? "" : "-" + Module); }
}
private string _module = string.Empty;
public string Module
{
get { return _module; }
set { _module = value; NotifyOfPropertyChange(nameof(Module)); }
}
private string _description = string.Empty;
public string Description
{
get { return _description; }
set { _description = value; NotifyOfPropertyChange(nameof(Description)); }
}
private bool _enable = true;
public bool Enable
{
get { return _enable; }
set { _enable = value; NotifyOfPropertyChange(nameof(Enable)); }
}
private bool _isHighLight = false;
[Subscription("IsTrigger")]
public bool IsHighLight
{
get { return _isHighLight; }
set
{
if (_isHighLight != value)
{
IsShowAllItem = _isHighLight;
_isHighLight = value;
NotifyOfPropertyChange(nameof(IsHighLight));
}
}
}
private bool _isprocess = false;
[Subscription("IsProcessing")]
public bool IsProcessing
{
get { return _isprocess; }
set
{
if (_isprocess != value)
{
IsShowAllItem = _isprocess;
_isprocess = value;
NotifyOfPropertyChange(nameof(IsProcessing));
}
}
}
private int _unmaintainedcount = 0;
[Subscription("UnMaintainedCount")]
public int UnMaintainedCount
{
get { return _unmaintainedcount; }
set { _unmaintainedcount = value; NotifyOfPropertyChange(nameof(UnMaintainedCount)); }
}
private string _startdate;
[Subscription("StartDate")]
public string StartDate
{
get { return _startdate; }
set { _startdate = value; NotifyOfPropertyChange(nameof(StartDate)); }
}
private double _threshold = 100;
[Subscription("Threshold")]
public double Threshold
{
get { return _threshold; }
set
{
if (Type == "Thickness")
{
_threshold = value;
}
else
{
_threshold = DateTimeHelper.SecondsTransform(value, TimeDisplayUnit);
}
NotifyOfPropertyChange(nameof(Threshold));
}
}
private double _value = 100;
[Subscription("Value")]
public double Value
{
get { return _value; }
set
{
if (Type == "Thickness")
{
_value = value;
}
else
{
_value = DateTimeHelper.SecondsTransform(value, TimeDisplayUnit);
}
NotifyOfPropertyChange(nameof(Value));
}
}
private string _enddate = "2020-1-1";
[Subscription("TrigDate")]
public string EndDate
{
get { return _enddate; }
set { _enddate = value; NotifyOfPropertyChange(nameof(EndDate)); }
}
private double _timeExceeded;
[Subscription("TimeExceeded")]
public double TimeExceeded
{
get { return _timeExceeded; }
set { _timeExceeded = value; NotifyOfPropertyChange(nameof(TimeExceeded)); }
}
private double _valueExceeded;
[Subscription("ValueExceeded")]
public double ValueExceeded
{
get { return _valueExceeded; }
set
{
if (Type == "Thickness")
{
_valueExceeded = value;
}
else
{
_valueExceeded = DateTimeHelper.SecondsTransform(value, TimeDisplayUnit);
}
NotifyOfPropertyChange(nameof(ValueExceeded));
}
}
private TimeUnit _timedisplayunit = TimeUnit.Hours;
public TimeUnit TimeDisplayUnit
{
get { return _timedisplayunit; }
set { _timedisplayunit = value; NotifyOfPropertyChange(nameof(TimeDisplayUnit)); }
}
private List<MaintainerItemInfo> _maintainanceitemlist = new();
private List<MaintainerItemInfo> _maintainanceitemsUIcollection = new();
public List<MaintainerItemInfo> MaintainanceItemsUIcollection
{
get { return _maintainanceitemsUIcollection; }
set { _maintainanceitemsUIcollection = value; NotifyOfPropertyChange(nameof(MaintainanceItemsUIcollection)); }
}
public void AddMaintainerItemInfo(MaintainerItemInfo item)
{
_maintainanceitemlist.Add(item);
item.IsMaintainedPropertyChanged += maintainedChanged;
maintainedChanged(null, null);
}
public List<MaintainerItemInfo> GetAllMaintainerItemInfoList()
{
return _maintainanceitemlist;
}
private bool _isshowallitem = true;
public bool IsShowAllItem
{
get { return _isshowallitem; }
set
{
_isshowallitem = value;
maintainedChanged(null, null);
NotifyOfPropertyChange(nameof(IsShowAllItem));
}
}
public void maintainedChanged(MaintainerItemInfo item, bool? newvalue)
{
var list = new List<MaintainerItemInfo>();
foreach (var i in _maintainanceitemlist)
{
i.ParentNameDisplay = "";
if (!i.Enable)
{
continue;
}
if (IsShowAllItem)
{
if (list.FindIndex(j => j.ParentName == i.ParentName) == -1)
{
i.ParentNameDisplay = i.ParentName;
}
list.Add(i);
}
else
{
if (!i.IsMaintained)
{
if (list.FindIndex(j => j.ParentName == i.ParentName) == -1)
{
i.ParentNameDisplay = i.ParentName;
}
list.Add(i);
}
}
}
MaintainanceItemsUIcollection = list;
}
public object Clone()
{
return new MaintainerInfo()
{
_name = this._name,
_type = this._type,
_module = this._module,
_index = this._index,
_description = this._description,
_enable = this._enable,
_startdate = this._startdate,
_threshold = this._threshold,
_enddate = this._enddate,
_timedisplayunit = this._timedisplayunit
};
}
}
}