using DTS.Common.Base; using DTS.Common.Interface.Graphs; using System.ComponentModel.DataAnnotations; using System.Data; namespace DTS.Common.Classes.TestSetups { /// /// Implementation of a graph record in the database /// /// public class GraphRecord : BasePropertyChanged, IGraphRecord { private int _graphId; /// /// database key for graph /// public int GraphId { get => _graphId; set => SetProperty(ref _graphId, value, "GraphId"); } private int _testSetupId; /// /// test setup key for graph /// public int TestSetupId { get => _testSetupId; set => SetProperty(ref _testSetupId, value, "TestSetupId"); } private string _graphName; /// /// name of graph /// [MaxLength(50)] public string GraphName { get => _graphName; set => SetProperty(ref _graphName, value, "GraphName"); } private string _graphDescription; /// /// description of graph /// [MaxLength(50)] public string GraphDescription { get => _graphDescription; set => SetProperty(ref _graphDescription, value, "GraphDescription"); } private string _channelsString; /// /// all the channels in the graph /// [MaxLength(2048)] public string ChannelsString { get => _channelsString; set => SetProperty(ref _channelsString, value, "ChannelsString"); } private bool _useDomainMin; /// /// whether to restrict domain axis to a min value /// public bool UseDomainMin { get => _useDomainMin; set => SetProperty(ref _useDomainMin, value, "UseDomainMin"); } private double _domainMin = double.MinValue; /// /// the minimum value to show on domain axis /// (only valid when UseDomainMin is true) /// public double DomainMin { get => _domainMin; set => SetProperty(ref _domainMin, value, "DomainMin"); } private bool _useDomainMax; /// /// whether to restrict domain axis to a max value /// public bool UseDomainMax { get => _useDomainMax; set => SetProperty(ref _useDomainMax, value, "UseDomainMax"); } private double _domainMax = double.MaxValue; /// /// maximum value to show on domain axis /// (only valid when UseDomainMax is true) /// public double DomainMax { get => _domainMax; set => SetProperty(ref _domainMax, value, "DomainMax"); } private bool _useRangeMin; /// /// whether to restrict range axis to a min value /// public bool UseRangeMin { get => _useRangeMin; set => SetProperty(ref _useRangeMin, value, "UseRangeMin"); } private double _rangeMin = double.MinValue; /// /// minimum value to show on range axis /// (only valid when UseRangeMin is true) /// public double RangeMin { get => _rangeMin; set => SetProperty(ref _rangeMin, value, "RangeMin"); } private bool _useRangeMax; /// /// whether to restrict range axis to a max value /// public bool UseRangeMax { get => _useRangeMax; set => SetProperty(ref _useRangeMax, value, "UseRangeMax"); } private double _rangeMax = double.MaxValue; /// /// the maximum value to show on the range axis /// (only valid when UseRangeMax is true) /// public double RangeMax { get => _rangeMax; set => SetProperty(ref _rangeMax, value, "RangeMax"); } private string _thresholdsString; /// /// any thresholds/lines to show on the graph /// [MaxLength(2048)] public string ThresholdsString { get => _thresholdsString; set => SetProperty(ref _thresholdsString, value, "ThresholdsString"); } private bool _localOnly = false; /// /// whether to synchronize record with central db /// [deprecated] /// public bool LocalOnly { get => _localOnly; set => SetProperty(ref _localOnly, value, "LocalOnly"); } public GraphRecord() { } public GraphRecord(IGraphRecord copy) { DomainMax = copy.DomainMax; DomainMin = copy.DomainMin; ChannelsString = copy.ChannelsString; ThresholdsString = copy.ThresholdsString; GraphDescription = copy.GraphDescription; GraphId = copy.GraphId; GraphName = copy.GraphName; RangeMax = copy.RangeMax; RangeMin = copy.RangeMin; TestSetupId = copy.TestSetupId; UseDomainMax = copy.UseDomainMax; UseDomainMin = copy.UseDomainMin; UseRangeMax = copy.UseRangeMax; UseRangeMin = copy.UseRangeMin; } public GraphRecord(IDataReader reader) { GraphId = Utility.GetInt(reader, "GraphId", -1); TestSetupId = Utility.GetInt(reader, "TestSetupId", -1); GraphName = Utility.GetString(reader, "GraphName"); GraphDescription = Utility.GetString(reader, "GraphDescription"); ChannelsString = Utility.GetString(reader, "Channels"); DomainMax = Utility.GetDouble(reader, "DomainMax", double.MaxValue); DomainMin = Utility.GetDouble(reader, "DomainMin", double.MinValue); RangeMax = Utility.GetDouble(reader, "RangeMax", double.MaxValue); RangeMin = Utility.GetDouble(reader, "RangeMin", double.MinValue); ThresholdsString = Utility.GetString(reader, "Thresholds"); UseDomainMax = Utility.GetBool(reader, "UseDomainMax"); UseDomainMin = Utility.GetBool(reader, "UseDomainMin"); UseRangeMax = Utility.GetBool(reader, "UseRangeMax"); UseRangeMin = Utility.GetBool(reader, "UseRangeMin"); } } }