Sic.Framework-Nanjing-Baishi/MECF.Framework.UI.Client/TrayThickness/PMCoatingThickness.cs

98 lines
2.5 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.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class PMCoatingThickness : ICloneable
{
private readonly List<CoatingData> _dataList;
#region Constructors
public PMCoatingThickness()
{
MinorCycle = new CoatingData();
MajorCycle = new CoatingData();
_dataList = new List<CoatingData>(
new[]
{
MinorCycle, MajorCycle
});
}
public PMCoatingThickness(string pmGuId)
{
PMGuid = pmGuId;//PM的默认数据库ID为MP
MinorCycle = new CoatingData($"{pmGuId}小周期", pmGuId);
MajorCycle = new CoatingData($"{pmGuId}大周期", pmGuId);
MinorCycle.PmOwned = pmGuId;
MajorCycle.PmOwned = pmGuId;
_dataList = new List<CoatingData>(
new[]
{
MinorCycle, MajorCycle
});
}
#endregion
#region Properties
public string PMGuid { get; set; }
/// <summary>
/// PM小周期厚度对象
/// </summary>
public CoatingData MinorCycle { get; set; }
/// <summary>
/// PM大周期厚度对象
/// </summary>
public CoatingData MajorCycle { get; set; }
#endregion
#region Methods
public bool Validate(out string reason)
{
if (!MinorCycle.Validate(out reason))
return false;
if (!MajorCycle.Validate(out reason))
return false;
//每个环Number数据是否存在相同Linq语句检查
if (_dataList.GroupBy(i => i.SerialNumber).Any(g => g.Count() > 1))
{
reason = $"some of components have same SN, please check.";
return false;
}
return true;
}
public void Update(PMCoatingThickness newData)
{
MinorCycle.Update(newData.MinorCycle);
MajorCycle.Update(newData.MajorCycle);
}
public object Clone()
{
var newObj = new PMCoatingThickness(PMGuid);
newObj.MinorCycle = (CoatingData)MinorCycle.Clone();
newObj.MajorCycle = (CoatingData)MajorCycle.Clone();
return newObj;
}
#endregion
}
}