126 lines
4.2 KiB
C#
126 lines
4.2 KiB
C#
///
|
|
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.IO;
|
|
|
|
namespace Results.Entities
|
|
{
|
|
public class Components
|
|
{
|
|
public virtual int Id { get; protected set; }
|
|
public virtual int TestBenchId { get; set; }
|
|
public virtual string TestBenchName { get; set; }
|
|
public virtual string Pump { get; set; }
|
|
public virtual string RegValve { get; set; }
|
|
public virtual string Flowmeter { get; set; }
|
|
public virtual string Diverter { get; set; }
|
|
public virtual string Scale { get; set; }
|
|
public virtual string Custom1 { get; set; }
|
|
public virtual string Custom2 { get; set; }
|
|
public virtual string Custom3 { get; set; }
|
|
|
|
public Components()
|
|
{
|
|
TestBenchId = 0;
|
|
TestBenchName = string.Empty;
|
|
Pump = string.Empty;
|
|
RegValve = string.Empty;
|
|
Flowmeter = string.Empty;
|
|
Diverter = string.Empty;
|
|
Scale = string.Empty;
|
|
Custom1 = string.Empty;
|
|
Custom2 = string.Empty;
|
|
Custom3 = string.Empty;
|
|
}
|
|
|
|
public Components(int benchId, string benchName, string pump, string flowmeter,
|
|
string scale, string regValve, string diverter)
|
|
{
|
|
TestBenchId = benchId;
|
|
TestBenchName = benchName;
|
|
Pump = pump;
|
|
RegValve = regValve;
|
|
Flowmeter = flowmeter;
|
|
Diverter = diverter;
|
|
Scale = scale;
|
|
Custom1 = string.Empty;
|
|
Custom2 = string.Empty;
|
|
Custom3 = string.Empty;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Method to compare the content of two entities
|
|
/// </summary>
|
|
/// <param name="wmd">Second entity to compare with</param>
|
|
/// <returns>first = two entities are equal (except of Id)</returns>
|
|
public virtual bool Equals(Components bc)
|
|
{
|
|
if (TestBenchId != bc.TestBenchId) return false;
|
|
if (!TestBenchName.Equals(bc.TestBenchName)) return false;
|
|
if (!Pump.Equals(bc.Pump)) return false;
|
|
if (!RegValve.Equals(bc.RegValve)) return false;
|
|
if (!Flowmeter.Equals(bc.Flowmeter)) return false;
|
|
if (!Diverter.Equals(bc.Diverter)) return false;
|
|
if (!Scale.Equals(bc.Scale)) return false;
|
|
if (!Custom1.Equals(bc.Custom1)) return false;
|
|
if (!Custom2.Equals(bc.Custom2)) return false;
|
|
if (!Custom3.Equals(bc.Custom3)) return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Adds an item to the list if it does not occur there
|
|
/// </summary>
|
|
/// <param name="list">List of items</param>
|
|
/// <param name="item">Item to add to the list or find there</param>
|
|
/// <returns>Item from the list (existing or added)</returns>
|
|
public static Components UpdateList(IList<Components> list, Components item)
|
|
{
|
|
if (item == null) return null; /// Null item is not stored in the list
|
|
|
|
Components found = list.FirstOrDefault<Components>(x => x.Equals(item));
|
|
|
|
if (found != null) return found; /// The same item found in the list, The found item returned
|
|
|
|
list.Add(item); /// Item not fund in the list, it is added to the list
|
|
return item;
|
|
}
|
|
|
|
public virtual void WriteBinary(BinaryWriter writer)
|
|
{
|
|
writer.Write(Id);
|
|
writer.Write(TestBenchId);
|
|
writer.Write((TestBenchName != null) ? TestBenchName : string.Empty);
|
|
writer.Write((Pump != null) ? Pump : string.Empty);
|
|
writer.Write((RegValve != null) ? RegValve : string.Empty);
|
|
writer.Write((Flowmeter != null) ? Flowmeter : string.Empty);
|
|
writer.Write((Diverter != null) ? Diverter : string.Empty);
|
|
writer.Write((Scale != null) ? Scale : string.Empty);
|
|
writer.Write((Custom1 != null) ? Custom1 : string.Empty);
|
|
writer.Write((Custom2 != null) ? Custom2 : string.Empty);
|
|
writer.Write((Custom3 != null) ? Custom3 : string.Empty);
|
|
}
|
|
|
|
public virtual void ReadBinary(BinaryReader reader)
|
|
{
|
|
Id = reader.ReadInt32();
|
|
TestBenchId = reader.ReadInt32();
|
|
TestBenchName = reader.ReadString();
|
|
Pump = reader.ReadString();
|
|
RegValve = reader.ReadString();
|
|
Flowmeter = reader.ReadString();
|
|
Diverter = reader.ReadString();
|
|
Scale = reader.ReadString();
|
|
Custom1 = reader.ReadString();
|
|
Custom2 = reader.ReadString();
|
|
Custom3 = reader.ReadString();
|
|
}
|
|
}
|
|
}
|