using DTS.Common.Interface.Channels; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Data; namespace DTS.Common.Classes.Channels { /// /// represents a record of a channel in the db /// /// public class ChannelDbRecord : Base.BasePropertyChanged, IChannelDbRecord { protected long _id = -1; /// /// The database id of the Channel /// [Key] public long Id { get => _id; set => SetProperty(ref _id, value, "Id"); } private int _groupId = -1; public int GroupId { get => _groupId; set => SetProperty(ref _groupId, value, "GroupId"); } private string _isoCode = ""; public string IsoCode { get => _isoCode; set => SetProperty(ref _isoCode, value, "IsoCode"); } private string _isoChannelName = ""; public string IsoChannelName { get => _isoChannelName; set => SetProperty(ref _isoChannelName, value, "IsoChannelName"); } private string _userCode; public string UserCode { get => _userCode; set => SetProperty(ref _userCode, value, "UserCode"); } private string _userChannelName = ""; public string UserChannelName { get => _userChannelName; set => SetProperty(ref _userChannelName, value, "UserChannelName"); } private int _dasId = -1; public int DASId { get => _dasId; set => SetProperty(ref _dasId, value, "DASId"); } protected int _dasChannelIndex = -1; public int DASChannelIndex { get => _dasChannelIndex; set => SetProperty(ref _dasChannelIndex, value, "DASChannelIndex"); } private int _groupChannelOrder = -1; public int GroupChannelOrder { get => _groupChannelOrder; set => SetProperty(ref _groupChannelOrder, value, "GroupChannelOrder"); } private int _testSetupOrder = -1; public int TestSetupOrder { get => _testSetupOrder; set => SetProperty(ref _testSetupOrder, value, "TestSetupOrder"); } private int _sensorId = -1; public int SensorId { get => _sensorId; set => SetProperty(ref _sensorId, value, "SensorId"); } /// /// IsDisabled is declared here, and redirects to Disabled so that /// existing uses of IsDisabled do not need to be modified. /// public bool IsDisabled { get => Disabled; set { Disabled = value; OnPropertyChanged("IsDisabled"); } } public bool Disabled { get; set; } private DateTime _lastModified = DateTime.Today; public DateTime LastModified { get => _lastModified; set => SetProperty(ref _lastModified, value, "LastModified"); } private string _lastModifiedBy = ""; public string LastModifiedBy { get => _lastModifiedBy; set => SetProperty(ref _lastModifiedBy, value, "LastModifiedBy"); } public ChannelDbRecord() { } public ChannelDbRecord(IChannelDbRecord copy) { Id = copy.Id; GroupId = copy.GroupId; IsoCode = copy.IsoCode; IsoChannelName = copy.IsoChannelName; UserCode = copy.UserCode; UserChannelName = copy.UserChannelName; DASId = copy.DASId; DASChannelIndex = copy.DASChannelIndex; GroupChannelOrder = copy.GroupChannelOrder; TestSetupOrder = copy.TestSetupOrder; SensorId = copy.SensorId; Disabled = copy.Disabled; LastModified = copy.LastModified; LastModifiedBy = copy.LastModifiedBy; } public ChannelDbRecord(IDataReader reader) { Id = Utility.GetInt(reader, "Id", -1); GroupId = Utility.GetInt(reader, "GroupId", -1); IsoCode = Utility.GetString(reader, "IsoCode"); IsoChannelName = Utility.GetString(reader, "IsoChannelName"); UserCode = Utility.GetString(reader, "UserCode"); UserChannelName = Utility.GetString(reader, "UserChannelName"); DASId = Utility.GetInt(reader, "DASId", -1); DASChannelIndex = Utility.GetInt(reader, "DASChannelIndex", -1); GroupChannelOrder = Utility.GetInt(reader, "GroupChannelOrder", -1); TestSetupOrder = Utility.GetInt(reader, "TestSetupOrder", -1); SensorId = Utility.GetInt(reader, "SensorId", -1); Disabled = Utility.GetBool(reader, "Disabled"); LastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue); LastModifiedBy = Utility.GetString(reader, "LastModifiedBy"); } } }