init
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class CustomerDetails
|
||||
{
|
||||
private readonly ISO.CustomerDetails _customerDetails;
|
||||
public string Name
|
||||
{
|
||||
get => _customerDetails.Name;
|
||||
set => _customerDetails.Name = value;
|
||||
}
|
||||
public CustomerDetails()
|
||||
{
|
||||
_customerDetails = new ISO.CustomerDetails();
|
||||
_customerDetails.Name = "(none)";
|
||||
}
|
||||
public CustomerDetails(ISO.CustomerDetails customerDetails)
|
||||
{
|
||||
_customerDetails = new ISO.CustomerDetails(customerDetails);
|
||||
}
|
||||
public ISO.CustomerDetails GetISOCustomer()
|
||||
{
|
||||
return _customerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class CustomerDetailsList
|
||||
{
|
||||
private static readonly CustomerDetailsList _customerList = new CustomerDetailsList();
|
||||
public static CustomerDetailsList CustomerList => _customerList;
|
||||
|
||||
private void PopulateCustomers()
|
||||
{
|
||||
if (null != _customers) return;
|
||||
_customers = new Dictionary<string, CustomerDetails>();
|
||||
foreach (var c in _customerList.GetAllCustomers())
|
||||
{
|
||||
if (!_customers.ContainsKey(c.Name))
|
||||
{
|
||||
_customers.Add(c.Name, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static readonly object _customerLock = new object();
|
||||
private Dictionary<string, CustomerDetails> _customers = null;
|
||||
public CustomerDetails[] Customers
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_customerLock)
|
||||
{
|
||||
PopulateCustomers();
|
||||
}
|
||||
var customers = new List<CustomerDetails>(_customers.Values);
|
||||
customers.Sort(CompareCustomers);
|
||||
return customers.ToArray();
|
||||
}
|
||||
}
|
||||
private static int CompareCustomers(CustomerDetails a, CustomerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
return null == b ? 1 : String.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public CustomerDetails[] GetAllCustomers()
|
||||
{
|
||||
var list = new List<CustomerDetails>();
|
||||
list.Add(new CustomerDetails()); //This is the "(none)" entry
|
||||
list.AddRange(ISO.CustomerDetails.GetAllCustomerDetails().Select(cs => new CustomerDetails(cs)));
|
||||
return list.ToArray();
|
||||
}
|
||||
public CustomerDetails GetCustomerDetail(string name)
|
||||
{
|
||||
var customers = from c in Customers.AsParallel() where c.Name == name select c;
|
||||
return customers.Any() ? customers.First() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class LabratoryDetails
|
||||
{
|
||||
ISO.LabratoryDetails _lab = null;
|
||||
public string Name
|
||||
{
|
||||
get => _lab.Name;
|
||||
set => _lab.Name = value;
|
||||
}
|
||||
public LabratoryDetails()
|
||||
{
|
||||
_lab = new ISO.LabratoryDetails();
|
||||
_lab.Name = "(none)";
|
||||
}
|
||||
public LabratoryDetails(ISO.LabratoryDetails lab) { _lab = new ISO.LabratoryDetails(lab); }
|
||||
public ISO.LabratoryDetails GetIsoLab() { return _lab; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class LabratoryDetailsList
|
||||
{
|
||||
protected LabratoryDetailsList()
|
||||
{
|
||||
}
|
||||
private static LabratoryDetailsList _list = new LabratoryDetailsList();
|
||||
public static LabratoryDetailsList LabratoryList => _list;
|
||||
private Dictionary<string, LabratoryDetails> _labs = null;
|
||||
|
||||
private void PopulateList()
|
||||
{
|
||||
if (null != _labs) return;
|
||||
_labs = new Dictionary<string, LabratoryDetails>();
|
||||
foreach (var l in GetAllLabs())
|
||||
{
|
||||
if (!_labs.ContainsKey(l.Name))
|
||||
{
|
||||
_labs.Add(l.Name, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
_labs[l.Name] = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static object _LabLock = new object();
|
||||
|
||||
public LabratoryDetails[] Labs
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_LabLock)
|
||||
{
|
||||
PopulateList();
|
||||
}
|
||||
var labs = new List<LabratoryDetails>(_labs.Values);
|
||||
labs.Sort(CompareLabs);
|
||||
return labs.ToArray();
|
||||
}
|
||||
}
|
||||
private static int CompareLabs(LabratoryDetails a, LabratoryDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
return null == b ? 1 : string.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
public LabratoryDetails GetLab(string name)
|
||||
{
|
||||
try { lock (_LabLock) { return _labs != null ? _labs.ContainsKey(name) ? _labs[name] : null : null; } }
|
||||
catch (Exception) {/* DTS.Utilities.Logging.APILogger.Log("failed to get labratories", ex); */}
|
||||
return null;
|
||||
}
|
||||
|
||||
private LabratoryDetails[] GetAllLabs()
|
||||
{
|
||||
var list = new List<LabratoryDetails>();
|
||||
try
|
||||
{
|
||||
list.Add(new LabratoryDetails()); //This is the "(none)" entry
|
||||
list.AddRange(ISO.LabratoryDetails.GetAllLabratoryDetails().Select(lab => new LabratoryDetails(lab)));
|
||||
}
|
||||
catch (Exception) {/* DTS.Utilities.Logging.APILogger.Log("failed to get labratories", ex);*/ }
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestEngineerDetails
|
||||
{
|
||||
private readonly ISO.TestEngineerDetails _testEngineerDetails;
|
||||
public string Name
|
||||
{
|
||||
get => _testEngineerDetails.Name;
|
||||
set => _testEngineerDetails.Name = value;
|
||||
}
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
_testEngineerDetails = new ISO.TestEngineerDetails();
|
||||
_testEngineerDetails.Name = "(none)"; // Strings.StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public TestEngineerDetails(ISO.TestEngineerDetails testEngineerDetails)
|
||||
{
|
||||
_testEngineerDetails = new ISO.TestEngineerDetails(testEngineerDetails);
|
||||
}
|
||||
public ISO.TestEngineerDetails GetISOTestEngineer()
|
||||
{
|
||||
return _testEngineerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class TestEngineerDetailsList
|
||||
{
|
||||
private static TestEngineerDetailsList _testEngineerList = new TestEngineerDetailsList();
|
||||
public static TestEngineerDetailsList TestEngineerList => _testEngineerList;
|
||||
private static object _testEngineerLock = new object();
|
||||
private Dictionary<string, TestEngineerDetails> _testEngineers = null;
|
||||
public TestEngineerDetails[] TestEngineers
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
if (null == _testEngineers)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
var testEngineers = new List<TestEngineerDetails>(_testEngineers.Values);
|
||||
testEngineers.Sort(CompareTestEngineers);
|
||||
return testEngineers.ToArray();
|
||||
}
|
||||
}
|
||||
private void PopulateEngineers()
|
||||
{
|
||||
_testEngineers = new Dictionary<string, TestEngineerDetails>();
|
||||
foreach (var t in _testEngineerList.GetAllTestEngineers())
|
||||
{
|
||||
if (!_testEngineers.ContainsKey(t.Name)) { _testEngineers.Add(t.Name, t); }
|
||||
}
|
||||
}
|
||||
private static int CompareTestEngineers(TestEngineerDetails a, TestEngineerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
if (null == b) { return 1; }
|
||||
return a.Name.CompareTo(b.Name);
|
||||
}
|
||||
|
||||
private TestEngineerDetails[] GetAllTestEngineers()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
list.Add(new TestEngineerDetails()); //This is the "(none)" entry
|
||||
foreach (var ts in ISO.TestEngineerDetails.GetAllTestEngineerDetails())
|
||||
{
|
||||
list.Add(new TestEngineerDetails(ts));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
public TestEngineerDetails GetTestEngineerDetail(string name)
|
||||
{
|
||||
var testEngineers = from t in TestEngineers.AsParallel() where t.Name == name select t;
|
||||
if (null != testEngineers && testEngineers.Count() > 0) { return testEngineers.First(); }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user