init
This commit is contained in:
@@ -0,0 +1,373 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Classes
|
||||
{
|
||||
public class Tags
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// represents a single tag, which is composed of an ID and a string of text
|
||||
/// we don't currently let you obsolete, delete, or edit tags, just add
|
||||
/// </summary>
|
||||
public class Tag: ICloneable
|
||||
{
|
||||
public Tag(string tagText, int tagId)
|
||||
{
|
||||
ID = tagId;
|
||||
Text = tagText;
|
||||
IsObsolete = false;
|
||||
}
|
||||
public const int INVALID_ID = -1;
|
||||
public int ID { get; set; }
|
||||
public string Text { get; set; }
|
||||
public bool IsObsolete { get; set; }
|
||||
public Tag(Tag copy)
|
||||
{
|
||||
ID = copy.ID;
|
||||
Text = copy.Text;
|
||||
IsObsolete = copy.IsObsolete;
|
||||
}
|
||||
|
||||
public Tag(IDataRecord reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
ID = Convert.ToInt32(reader["TagId"]);
|
||||
IsObsolete = Convert.ToBoolean(reader["Obsolete"]);
|
||||
Text = Convert.ToString(reader["TagText"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Tag(DataRow dr)
|
||||
{
|
||||
try
|
||||
{
|
||||
IsObsolete = Convert.ToBoolean(dr["Obsolete"]);
|
||||
ID = Convert.ToInt32(dr["TagId"]);
|
||||
Text = Convert.ToString(dr["TagFields"]);
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log(ex); }
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
return new Tag(this);
|
||||
}
|
||||
}
|
||||
private static Tags _tagsInstance;
|
||||
//public static Tags TagsInstance
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (null == _tagsInstance) { _tagsInstance = new Tags(); }
|
||||
// return _tagsInstance;
|
||||
// }
|
||||
//}
|
||||
public static Tags GetTagsInstance(GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
if( null == _tagsInstance)
|
||||
{
|
||||
_tagsInstance = new Tags(getSqlCommand);
|
||||
}
|
||||
return _tagsInstance;
|
||||
}
|
||||
private static readonly object LOCK_OBJECT = new object();
|
||||
public Tags(GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
_tagsLookup = new Dictionary<string, Tag>();
|
||||
UpdateList(getSqlCommand);
|
||||
}
|
||||
/// <summary>
|
||||
/// holds a cached collection of tags. This collection however is currently only populated on startup
|
||||
/// and not updated except explicitly when a user adds a tag
|
||||
/// </summary>
|
||||
// ReSharper disable once RedundantDefaultMemberInitializer
|
||||
private readonly Dictionary<string, Tag> _tagsLookup = null;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a tag if not present in memory cache to db
|
||||
/// </summary>
|
||||
/// <param name="tagText"></param>
|
||||
/// <returns></returns>
|
||||
public static bool AddTag(string tagText, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tagText)) { return false; }
|
||||
|
||||
// is it already in the dictionary?
|
||||
var tags = Tags.GetTagsInstance(getSqlCommand);
|
||||
if (tags.ContainsTag(tagText)) return false;
|
||||
tags.Commit(new Tag(tagText, Tag.INVALID_ID), getSqlCommand);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Changes the ID of a tag during database migration
|
||||
/// </summary>
|
||||
/// <param name="tagText"></param>
|
||||
/// <returns></returns>
|
||||
public static bool MigrateTag(string tagText, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tagText)) { return false; }
|
||||
|
||||
Tags.GetTagsInstance(getSqlCommand).Commit(new Tag(tagText, Tag.INVALID_ID), getSqlCommand);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// commits a tag to db if doesn't already exist in db
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
private void Commit(Tag tag, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (-1 == GetIDFromTagText(tag.Text, getSqlCommand))
|
||||
{
|
||||
Insert(tag, getSqlCommand);
|
||||
}
|
||||
else { UpdateAll(tag, getSqlCommand); }
|
||||
|
||||
lock (LOCK_OBJECT)
|
||||
{
|
||||
_tagsLookup[tag.Text] = tag;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
private void UpdateAll(Tag tag, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
//nothing to do currently? (we don't let you rename or edit, or obsolete, or delete ...)
|
||||
tag.ID = GetTagIdFromText(tag.Text, getSqlCommand);
|
||||
}
|
||||
public delegate SqlCommand GetSqlCommandDelegate(bool bNewConnection);
|
||||
/// <summary>
|
||||
/// inserts a tag into the db
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
private void Insert(Tag tag, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
using (var cmd = getSqlCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = "sp_TagsInsert";
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@TagText", SqlDbType.NVarChar, 255) {Value = tag.Text});
|
||||
cmd.Parameters.Add(new SqlParameter("@Obsolete", SqlDbType.Bit) {Value = tag.IsObsolete});
|
||||
var newIdParam = new SqlParameter("@new_id", SqlDbType.Int) {Direction = ParameterDirection.Output};
|
||||
cmd.Parameters.Add(newIdParam);
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) {Direction = ParameterDirection.Output};
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
|
||||
|
||||
tag.ID = int.Parse(newIdParam.Value.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// retrieves a string text associated with an ID FROM CACHED copies
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
private string GetTagTextFromId(int id)
|
||||
{
|
||||
lock (LOCK_OBJECT)
|
||||
{
|
||||
if (_tagsLookup == null) return null;
|
||||
var e = _tagsLookup.GetEnumerator();
|
||||
while (e.MoveNext())
|
||||
{
|
||||
if (e.Current.Value.ID != id) continue;
|
||||
var returnText = e.Current.Value.Text;
|
||||
e.Dispose();
|
||||
return returnText;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets an ID for a given tag text FROM DB
|
||||
/// returns InvalidID if not found
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
private int GetTagIdFromText(string text, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
using (var cmd = getSqlCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = "sp_TagsGetId";
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@TagText", SqlDbType.NVarChar, 255) {Value = text});
|
||||
var tagIdParam = new SqlParameter("@TagId", SqlDbType.Int) {Direction = ParameterDirection.Output};
|
||||
cmd.Parameters.Add(tagIdParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
if (DBNull.Value.Equals(tagIdParam.Value))
|
||||
{
|
||||
return Tag.INVALID_ID;
|
||||
}
|
||||
var tagIdtemp = int.Parse(tagIdParam.Value.ToString());
|
||||
return tagIdtemp == 0 ? Tag.INVALID_ID : tagIdtemp;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns true if a given tag text is contained in cached in memory tags
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public bool ContainsTag(string text)
|
||||
{
|
||||
lock (LOCK_OBJECT)
|
||||
{
|
||||
return _tagsLookup.ContainsKey(text);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// adds multiple tags at once
|
||||
/// note that tags will have their start trimmed before commiting
|
||||
/// </summary>
|
||||
/// <param name="tagText"></param>
|
||||
/// <returns></returns>
|
||||
public static bool[] AddRange(string[] tagText, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
List<bool> rv = new List<bool>();
|
||||
if (null == tagText || 0 == tagText.Length) { return null; }
|
||||
foreach (string s in tagText)
|
||||
{
|
||||
var tag = s.TrimStart();
|
||||
rv.Add(AddTag(tag, getSqlCommand));
|
||||
}
|
||||
return rv.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// gets an ID for a given tag text FROM DB
|
||||
/// </summary>
|
||||
/// <param name="tagText"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetIDFromTagText(string tagText, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
return GetTagsInstance(getSqlCommand).GetTagIdFromText(tagText, getSqlCommand);
|
||||
}
|
||||
/// <summary>
|
||||
/// gets an array of ids given an array of tag texts
|
||||
/// </summary>
|
||||
/// <param name="tagText"></param>
|
||||
/// <returns></returns>
|
||||
public static int[] GetIDsFromTagText(string[] tagText, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
if (null == tagText || 0 == tagText.Length) { return null; }
|
||||
|
||||
return tagText.Select(s => s.TrimStart()).Select(text => GetIDFromTagText(text, getSqlCommand)).Where(id => id != Tag.INVALID_ID).ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a string for a given id from memory cache
|
||||
/// returns null if it doesn't exist or is an invalid id
|
||||
/// </summary>
|
||||
/// <param name="tagID"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetTagTextFromID(int tagID, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
if (0 > tagID || tagID == Tag.INVALID_ID)
|
||||
{
|
||||
// Not a valid ID
|
||||
return null;
|
||||
}
|
||||
return GetTagsInstance(getSqlCommand).GetTagTextFromId(tagID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns an array of tag text given an array of tag ids.
|
||||
/// skips invalid tags or tag text
|
||||
/// </summary>
|
||||
/// <param name="tagId"></param>
|
||||
/// <returns></returns>
|
||||
public static string[] GetTagTextFromIDs(int[] tagId, GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
if (null == tagId || 0 == tagId.Length) { return new string [0]; }
|
||||
|
||||
return tagId.Where(i => i != Tag.INVALID_ID).Select(i => GetTagTextFromID(i,getSqlCommand)).Where(tag => !string.IsNullOrWhiteSpace(tag)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieves all tags and updates the cached dictionary of tags
|
||||
/// </summary>
|
||||
public void UpdateList(GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
lock (LOCK_OBJECT)
|
||||
{
|
||||
_tagsLookup.Clear();
|
||||
using (var cmd = getSqlCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = "sp_TagsGet";
|
||||
cmd.Parameters.Add(new SqlParameter("@TagId", SqlDbType.Int) {Value = null});
|
||||
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
|
||||
var t = new Tag(reader);
|
||||
if (t.ID == 0) continue;
|
||||
_tagsLookup[t.Text] = t;
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// this interface describes a UI page, specifically datapro pages
|
||||
/// </summary>
|
||||
public interface IDataPROPage : INotifyPropertyChanged
|
||||
{
|
||||
Visibility TestSetupChangeButtonVisible { get; set; }
|
||||
Visibility AutomaticModeStatusVisible { get; set; }
|
||||
string PageName { get; set; }
|
||||
ImageSource PageImage { get; set; }
|
||||
bool IsAdd { get; set; }
|
||||
bool UsesModifyEnhancements { get; set; }
|
||||
string EditIDString { get; set; }
|
||||
string AddIDString { get; set; }
|
||||
string ModifiedObjectName { get; set; }
|
||||
bool AutomaticProgression { get; set; }
|
||||
bool RecoveryDownloadMode { get; set; }
|
||||
string UniqueId { get; }
|
||||
string GetName();
|
||||
long GetID();
|
||||
void SetID(long id);
|
||||
Color TileColor { get; }
|
||||
void SetTileColor(Color c);
|
||||
void SavePage(object obj);
|
||||
string CurrentSearchTerm { get; set; }
|
||||
void ClearSearchTerm();
|
||||
void SetEnabled(bool bEnable);
|
||||
bool UsesNAVControl{ get; set; }
|
||||
bool UsesSearchControl { get; set; }
|
||||
bool UsesSelectControl { get; set; }
|
||||
void VerifyProgress(object o);
|
||||
void SaveAndExit();
|
||||
void RefreshButtonPressed();
|
||||
void SetDoneButtonIsEnabled(bool bEnabled);
|
||||
void SetBackButtonIsEnabled(bool bEnabled);
|
||||
void DoneButtonPress();
|
||||
bool HasBackButton { get; set; }
|
||||
bool HasRefreshButton { get; set; }
|
||||
bool HasCancelButton { get; set; }
|
||||
bool HasSaveButton { get; set; }
|
||||
void SetCancelEnabled(bool bEnabled);
|
||||
bool HasNextButton { get; set; }
|
||||
Color ContentBackgroundColor { get; set; }
|
||||
object MainContent { get; set; }
|
||||
ContentControl GetMainContentControl();
|
||||
void SetReturning();
|
||||
bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
|
||||
bool OKToProceed();
|
||||
void FormClosing(Action OnComplete = null);
|
||||
bool ControlInOnSetActive { get; set; }
|
||||
void OnSetActive();
|
||||
void UnSet();
|
||||
void SetCurrentItem(object o);
|
||||
void SetupPageAvailable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// these are properties on the datapro page that change and may need to be acted on
|
||||
/// </summary>
|
||||
public enum DataProPageProperties
|
||||
{
|
||||
UsesModifyEnhancements,
|
||||
TestSetupChangeButtonVisible,
|
||||
AutomaticModeStatusVisible,
|
||||
PageName,
|
||||
PageImage,
|
||||
IsAdd,
|
||||
EditIDString,
|
||||
AddIDString,
|
||||
ModifiedObjectName,
|
||||
AutomaticProgression,
|
||||
RecoveryDownloadMode,
|
||||
UsesNAVControl,
|
||||
UsesSearchControl,
|
||||
UsesSelectControl,
|
||||
HasBackButton,
|
||||
HasRefreshButton,
|
||||
HasCancelButton,
|
||||
HasSaveButton,
|
||||
HasNextButton,
|
||||
ContentBackgroundColor,
|
||||
MainContent,
|
||||
GenerateReportsVisible
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Classes.Sensors
|
||||
{
|
||||
public class SquibDbRecord : BasePropertyChanged, ISquibDbRecord
|
||||
{
|
||||
private string _serialNumber = "";
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set => SetProperty(ref _serialNumber, value, "SerialNumber");
|
||||
}
|
||||
private int _id = -1;
|
||||
[Key]
|
||||
public int Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetProperty(ref _id, value, "Id");
|
||||
}
|
||||
private bool _bypassCurrentFilter = false;
|
||||
public bool BypassCurrentFilter
|
||||
{
|
||||
get => _bypassCurrentFilter;
|
||||
set => SetProperty(ref _bypassCurrentFilter, value, "BypassCurrentFilter");
|
||||
}
|
||||
private bool _bypassVoltageFilter = false;
|
||||
public bool BypassVoltageFilter
|
||||
{
|
||||
get => _bypassVoltageFilter;
|
||||
set => SetProperty(ref _bypassVoltageFilter, value, "BypassVoltageFilter");
|
||||
}
|
||||
private double _delayMS = 0D;
|
||||
[Column("DelayMS")]
|
||||
public double DelayMs
|
||||
{
|
||||
get => _delayMS;
|
||||
set => SetProperty(ref _delayMS, value, "DelayMs");
|
||||
}
|
||||
private double _durationMS = 10D;
|
||||
[Column("DurationMS")]
|
||||
public double DurationMs
|
||||
{
|
||||
get => _durationMS;
|
||||
set => SetProperty(ref _durationMS, value, "DurationMs");
|
||||
}
|
||||
private SquibFireMode _fireMode = SquibFireMode.NONE;
|
||||
public SquibFireMode FireMode
|
||||
{
|
||||
get => _fireMode;
|
||||
set => SetProperty(ref _fireMode, value, "FireMode");
|
||||
}
|
||||
private string _isoCode = "";
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string IsoCode
|
||||
{
|
||||
get => _isoCode;
|
||||
set => SetProperty(ref _isoCode, value, "IsoCode");
|
||||
}
|
||||
private string _isoChannelName = "";
|
||||
[Required]
|
||||
[StringLength(255)]
|
||||
public string IsoChannelName
|
||||
{
|
||||
get => _isoChannelName;
|
||||
set => SetProperty(ref _isoChannelName, value, "IsoChannelName");
|
||||
}
|
||||
private string _userCode = "";
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string UserCode
|
||||
{
|
||||
get => _userCode;
|
||||
set => SetProperty(ref _userCode, value, "UserCode");
|
||||
}
|
||||
private string _userChannelName = "";
|
||||
[Required]
|
||||
[StringLength(255)]
|
||||
public string UserChannelName
|
||||
{
|
||||
get => _userChannelName;
|
||||
set => SetProperty(ref _userChannelName, value, "UserChannelName");
|
||||
}
|
||||
private SquibMeasurementType _squibMeasurementType = SquibMeasurementType.VOLTAGE;
|
||||
public SquibMeasurementType MeasurementType
|
||||
{
|
||||
get => _squibMeasurementType;
|
||||
set => SetProperty(ref _squibMeasurementType, value, "MeasurementType");
|
||||
}
|
||||
private double _squibOutputCurrent = 1.5D;
|
||||
public double SquibOutputCurrent
|
||||
{
|
||||
get => _squibOutputCurrent;
|
||||
set => SetProperty(ref _squibOutputCurrent, value, "SquibOutputCurrent");
|
||||
}
|
||||
private double _squibToleranceLow = 1D;
|
||||
public double SquibToleranceLow
|
||||
{
|
||||
get => _squibToleranceLow;
|
||||
set => SetProperty(ref _squibToleranceLow, value, "SquibToleranceLow");
|
||||
}
|
||||
private double _squibToleranceHigh = 8D;
|
||||
public double SquibToleranceHigh
|
||||
{
|
||||
get => _squibToleranceHigh;
|
||||
set => SetProperty(ref _squibToleranceHigh, value, "SquibToleranceHigh");
|
||||
}
|
||||
private bool _limitDuration = true;
|
||||
public bool LimitDuration
|
||||
{
|
||||
get => _limitDuration;
|
||||
set => SetProperty(ref _limitDuration, value, "LimitDuration");
|
||||
}
|
||||
private string _articleId = "";
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string ArticleId
|
||||
{
|
||||
get => _articleId;
|
||||
set => SetProperty(ref _articleId, value, "ArticleId");
|
||||
}
|
||||
private int _version = 1;
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => SetProperty(ref _version, value, "Version");
|
||||
}
|
||||
private DateTime _lastModified = DateTime.MinValue;
|
||||
[Column(TypeName = "datetime")]
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => SetProperty(ref _lastModified, value, "LastModified");
|
||||
}
|
||||
private string _lastModifiedBy = "";
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => SetProperty(ref _lastModifiedBy, value, "LastModifiedBy");
|
||||
}
|
||||
private string _userValue1 = "";
|
||||
[StringLength(255)]
|
||||
public string UserValue1
|
||||
{
|
||||
get => _userValue1;
|
||||
set => SetProperty(ref _userValue1, value, "UserValue1");
|
||||
}
|
||||
private string _userValue2 = "";
|
||||
[StringLength(255)]
|
||||
public string UserValue2
|
||||
{
|
||||
get => _userValue2;
|
||||
set => SetProperty(ref _userValue2, value, "UserValue2");
|
||||
}
|
||||
private string _userValue3 = "";
|
||||
[StringLength(255)]
|
||||
public string UserValue3
|
||||
{
|
||||
get => _userValue3;
|
||||
set => SetProperty(ref _userValue3, value, "UserValue3");
|
||||
}
|
||||
private byte[] _userTags = new byte[0];
|
||||
public byte[] UserTags
|
||||
{
|
||||
get => _userTags;
|
||||
set => SetProperty(ref _userTags, value, "UserTags");
|
||||
}
|
||||
private bool _doNotUse = false;
|
||||
public bool DoNotUse
|
||||
{
|
||||
get => _doNotUse;
|
||||
set => SetProperty(ref _doNotUse, value, "DoNotUse");
|
||||
}
|
||||
private bool _broken = false;
|
||||
public bool Broken
|
||||
{
|
||||
get => _broken;
|
||||
set => SetProperty(ref _broken, value, "Broken");
|
||||
}
|
||||
private bool _defineDelayInTest = false;
|
||||
public bool DefineDelayInTest
|
||||
{
|
||||
get => _defineDelayInTest;
|
||||
set => SetProperty(ref _defineDelayInTest, value, "DefineDelayInTest");
|
||||
}
|
||||
public SquibDbRecord(ISensorData copy, bool defineDelayInTest, byte [] tags)
|
||||
{
|
||||
Id = copy.DatabaseId;
|
||||
IsoChannelName = copy.ISOChannelName;
|
||||
UserCode = copy.UserCode;
|
||||
UserChannelName = copy.UserChannelName;
|
||||
Broken = copy.Broken;
|
||||
DoNotUse = copy.DoNotUse;
|
||||
Version = copy.Version;
|
||||
SquibToleranceLow = copy.SquibToleranceLow;
|
||||
SquibToleranceHigh = copy.SquibToleranceHigh;
|
||||
SquibOutputCurrent = copy.SquibOutputCurrent;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
MeasurementType = copy.SquibMeasurementType;
|
||||
LimitDuration = copy.LimitDuration;
|
||||
DefineDelayInTest = defineDelayInTest;
|
||||
LastModifiedBy = copy.LastUpdatedBy;
|
||||
LastModified = copy.LastModified;
|
||||
IsoCode = copy.ISOCode;
|
||||
FireMode = copy.SquibFireMode;
|
||||
DurationMs = copy.SquibFireDurationMS;
|
||||
DelayMs = copy.SquibFireDelayMS;
|
||||
BypassVoltageFilter = copy.BypassVoltageFilter;
|
||||
BypassCurrentFilter = copy.BypassCurrentFilter;
|
||||
ArticleId = copy.EID;
|
||||
UserValue1 = copy.UserValue1;
|
||||
|
||||
UserValue2 = copy.UserValue2;
|
||||
UserValue3 = copy.UserValue3;
|
||||
if (null == tags) { UserTags = null; }
|
||||
else if (tags.Any())
|
||||
{
|
||||
var userTags = new byte[tags.Length];
|
||||
Array.Copy(tags, userTags, tags.Length);
|
||||
UserTags = userTags;
|
||||
}
|
||||
else { UserTags = new byte[0]; }
|
||||
}
|
||||
public SquibDbRecord() { }
|
||||
public SquibDbRecord(ISquibDbRecord copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
IsoChannelName = copy.IsoChannelName;
|
||||
UserCode = copy.UserCode;
|
||||
UserChannelName = copy.UserChannelName;
|
||||
Broken = copy.Broken;
|
||||
DoNotUse = copy.DoNotUse;
|
||||
Version = copy.Version;
|
||||
SquibToleranceLow = copy.SquibToleranceLow;
|
||||
SquibToleranceHigh = copy.SquibToleranceHigh;
|
||||
SquibOutputCurrent = copy.SquibOutputCurrent;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
MeasurementType = copy.MeasurementType;
|
||||
LimitDuration = copy.LimitDuration;
|
||||
DefineDelayInTest = copy.DefineDelayInTest;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LastModified = copy.LastModified;
|
||||
IsoCode = copy.IsoCode;
|
||||
FireMode = copy.FireMode;
|
||||
DurationMs = copy.DurationMs;
|
||||
DelayMs = copy.DelayMs;
|
||||
BypassVoltageFilter = copy.BypassVoltageFilter;
|
||||
BypassCurrentFilter = copy.BypassCurrentFilter;
|
||||
ArticleId = copy.ArticleId;
|
||||
UserValue1 = copy.UserValue1;
|
||||
//Comment = UserValue1;
|
||||
UserValue2 = copy.UserValue2;
|
||||
UserValue3 = copy.UserValue3;
|
||||
if( null == copy.UserTags) { UserTags = null; }
|
||||
else if(copy.UserTags.Any())
|
||||
{
|
||||
var userTags = new byte[copy.UserTags.Length];
|
||||
Array.Copy(copy.UserTags, userTags, copy.UserTags.Length);
|
||||
UserTags = userTags;
|
||||
}
|
||||
else { UserTags = new byte[0]; }
|
||||
}
|
||||
public SquibDbRecord(IDataReader reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
Id = Utility.GetInt(reader, "Id", -1);
|
||||
IsoChannelName = Utility.GetString(reader, "ISOChannelName", string.Empty);
|
||||
UserCode = Utility.GetString(reader, "UserCode", string.Empty);
|
||||
UserChannelName = Utility.GetString(reader, "UserChannelName", string.Empty);
|
||||
Broken = Utility.GetBool(reader, "Broken", false);
|
||||
DoNotUse = Utility.GetBool(reader, "DoNotUse", false);
|
||||
Version = Utility.GetInt(reader, "Version", -1);
|
||||
SquibToleranceLow = Utility.GetDouble(reader, "SquibToleranceLow", 0D);
|
||||
SquibToleranceHigh = Utility.GetDouble(reader, "SquibToleranceHigh", 8D);
|
||||
SquibOutputCurrent = Utility.GetDouble(reader, "SquibOutputCurrent", 1.5D);
|
||||
SerialNumber = Utility.GetString(reader, "SerialNumber", string.Empty);
|
||||
MeasurementType = (SquibMeasurementType)Utility.GetShort(reader, "MeasurementType");
|
||||
LimitDuration = Utility.GetBool(reader, "LimitDuration");
|
||||
DefineDelayInTest = Utility.GetBool(reader, "DefineDelayInTest");
|
||||
LastModifiedBy = Utility.GetString(reader, "LastModifiedBy", string.Empty);
|
||||
LastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue);
|
||||
IsoCode = Utility.GetString(reader, "ISOCode", string.Empty);
|
||||
FireMode = (SquibFireMode)Utility.GetShort(reader, "FireMode");
|
||||
DurationMs = Utility.GetDouble(reader, "DurationMS", 0D);
|
||||
DelayMs = Utility.GetDouble(reader, "DelayMS", 0D);
|
||||
BypassVoltageFilter = Utility.GetBool(reader, "BypassVoltageFilter", false);
|
||||
BypassCurrentFilter = Utility.GetBool(reader, "BypassCurrentFilter", false);
|
||||
ArticleId = Utility.GetString(reader, "ArticleId", string.Empty);
|
||||
UserValue1 = Utility.GetString(reader, "UserValue1");
|
||||
//Comment = UserValue1;
|
||||
UserValue2 = Utility.GetString(reader, "UserValue2", string.Empty);
|
||||
UserValue3 = Utility.GetString(reader, "UserValue3", string.Empty);
|
||||
var o = reader["UserTags"];
|
||||
UserTags = DBNull.Value.Equals(o)
|
||||
? new byte[0]
|
||||
: (byte[])o;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user