This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
using System;
using System.Linq;
namespace DatabaseImport
{
public class DASHardwareList //: BasePropertyChanged
{
private static DASHardwareList _list;
public static DASHardwareList GetList()
{
if (null != _list) return _list;
_list = new DASHardwareList();
//_list.PopulateHardware();
return _list;
}
public void ReloadAll()
{
//_list = new DASHardwareList();
//_list.PopulateHardware();
}
private ICachedContainer _cachedHardware = null;
public DASHardware GetHardware(string id, bool bUseCache = true)
{
return GetHardware(id, true, out var bNotUsed, bUseCache);
}
public DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed, bool bUseCache = true)
{
if (null != _cachedHardware && bUseCache)
{
var tokens = id.Split('_');
var h = _cachedHardware.GetCachedHardware(tokens[0]);
if (null != h)
{
changed = false;
return h;
}
}
var hardware = Hardware.GetAllDAS(id, null);
changed = false;
if (null != hardware && hardware.Any())
{
return new DASHardware(hardware[0]);
}
return null;
/*if (_hardware.ContainsKey(id))
{
return _hardware[id];
}
var matchingSerial = from h in _hardware where h.Value.SerialNumber == id select h.Value;
var dasHardwares = matchingSerial as DASHardware[] ?? matchingSerial.ToArray();
if (dasHardwares.Any())
{
return dasHardwares.First();
}
//check to see if the type changed?
var index = id.IndexOf('_');
if (index >= 0)
{
id = id.Substring(0, index);
}
var match2 = from h in _hardware where h.Value.SerialNumber == id select h.Value;
if (match2.Any())
{
if (bThrowExceptionIfChanged)
{
throw new HardwareTypeChangedException();
}
changed = true;
}return null;*/
}
public class HardwareTypeChangedException : Exception
{
}
}
}