246 lines
8.5 KiB
C#
246 lines
8.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace DatabaseExport.ISO
|
|
{
|
|
[Serializable()]
|
|
public class LabratoryDetails //: ISerializableFile
|
|
{
|
|
private string _labratoryName = string.Empty;
|
|
|
|
public string LabratoryName
|
|
{
|
|
get => _labratoryName;
|
|
set => _labratoryName = value;
|
|
}
|
|
|
|
private string _labratoryContactName = string.Empty;
|
|
|
|
public string LabratoryContactName
|
|
{
|
|
get => _labratoryContactName;
|
|
set => _labratoryContactName = value;
|
|
}
|
|
|
|
private string _labratoryContactPhone = "NOVALUE";
|
|
|
|
public string LabratoryContactPhone
|
|
{
|
|
get => _labratoryContactPhone;
|
|
set
|
|
{
|
|
if (value != string.Empty)
|
|
{
|
|
_labratoryContactPhone = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private string _labratoryContactFax = "NOVALUE";
|
|
|
|
public string LabratoryContactFax
|
|
{
|
|
get => _labratoryContactFax;
|
|
set
|
|
{
|
|
if (value != string.Empty)
|
|
{
|
|
_labratoryContactFax = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private string _labratoryContactEmail = "NOVALUE";
|
|
|
|
public string LabratoryContactEmail
|
|
{
|
|
get => _labratoryContactEmail;
|
|
set
|
|
{
|
|
if (value != string.Empty)
|
|
{
|
|
_labratoryContactEmail = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private string _labratoryTestRefNumber = string.Empty;
|
|
|
|
public string LabratoryTestRefNumber
|
|
{
|
|
get => _labratoryTestRefNumber;
|
|
set => _labratoryTestRefNumber = value;
|
|
}
|
|
|
|
private string _labratoryProjectRefNumber = string.Empty;
|
|
|
|
public string LabratoryProjectRefNumber
|
|
{
|
|
get => _labratoryProjectRefNumber;
|
|
set => _labratoryProjectRefNumber = value;
|
|
}
|
|
|
|
private string _name = "";
|
|
|
|
public string Name
|
|
{
|
|
get => _name;
|
|
set => _name = value;
|
|
}
|
|
|
|
public static LabratoryDetails[] GetAllLabratoryDetails()
|
|
{
|
|
var labs = new List<LabratoryDetails>();
|
|
try
|
|
{
|
|
using (var cmd = DbOperations.GetCommand())
|
|
{
|
|
cmd.CommandText = "SELECT Name" +
|
|
",LabratoryName" +
|
|
",LabratoryContactName" +
|
|
",LabratoryContactPhone" +
|
|
",LabratoryContactFax" +
|
|
",LabratoryContactEmail" +
|
|
",LabratoryTestRefNumber" +
|
|
",LabratoryProjectRefNumber" +
|
|
",LastModified" +
|
|
",LastModifiedBy" +
|
|
",LocalOnly" +
|
|
",Version" +
|
|
",DbTimeStamp" +
|
|
" from tblLabratoryDetails";
|
|
|
|
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
|
{
|
|
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
|
{
|
|
try
|
|
{
|
|
labs.Add(new LabratoryDetails(dr));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//DTS.Utilities.Logging.APILogger.Log("Failed to read laboratory details", ex2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//DTS.Utilities.Logging.APILogger.Log("Failed to retreive laboratory details", ex);
|
|
}
|
|
return labs.ToArray();
|
|
}
|
|
|
|
private bool _localOnly = false;
|
|
|
|
public bool LocalOnly
|
|
{
|
|
get => _localOnly;
|
|
set => _localOnly = value;
|
|
}
|
|
|
|
private DateTime _lastModified;
|
|
|
|
public DateTime LastModified
|
|
{
|
|
get => _lastModified;
|
|
set => _lastModified = value;
|
|
}
|
|
|
|
private string _lastModifiedBy;
|
|
|
|
public string LastModifiedBy
|
|
{
|
|
get => _lastModifiedBy;
|
|
set => _lastModifiedBy = value;
|
|
}
|
|
|
|
public LabratoryDetails()
|
|
{
|
|
}
|
|
|
|
public LabratoryDetails(System.Data.DataRow dr)
|
|
{
|
|
_name = (string)dr["Name"];
|
|
LabratoryName = (string)dr["LabratoryName"];
|
|
LabratoryContactName = (string)dr["LabratoryContactName"];
|
|
LabratoryContactPhone = (string)dr["LabratoryContactPhone"];
|
|
LabratoryContactFax = (string)dr["LabratoryContactFax"];
|
|
LabratoryContactEmail = (string)dr["LabratoryContactEmail"];
|
|
LabratoryTestRefNumber = (string)dr["LabratoryTestRefNumber"];
|
|
LabratoryProjectRefNumber = (string)dr["LabratoryProjectRefNumber"];
|
|
_lastModified = Convert.ToDateTime(dr["LastModified"]);
|
|
_lastModifiedBy = (string)dr["LastModifiedBy"];
|
|
_localOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
|
_version = Convert.ToInt32(dr["Version"]);
|
|
}
|
|
|
|
public LabratoryDetails(LabratoryDetails copy)
|
|
{
|
|
_name = copy.Name;
|
|
LabratoryName = copy.LabratoryName;
|
|
LabratoryContactName = copy.LabratoryContactName;
|
|
LabratoryContactPhone = copy.LabratoryContactPhone;
|
|
LabratoryContactFax = copy.LabratoryContactFax;
|
|
LabratoryContactEmail = copy.LabratoryContactEmail;
|
|
LabratoryTestRefNumber = copy.LabratoryTestRefNumber;
|
|
LabratoryProjectRefNumber = copy.LabratoryProjectRefNumber;
|
|
_lastModified = copy.LastModified;
|
|
_lastModifiedBy = copy.LastModifiedBy;
|
|
_localOnly = copy.LocalOnly;
|
|
_version = copy.Version;
|
|
}
|
|
|
|
private enum fields
|
|
{
|
|
Name,
|
|
LaboratoryName,
|
|
LaboratoryContactName,
|
|
LaboratoryContactPhone,
|
|
LaboratoryContactFax,
|
|
LaboratoryContactEmail,
|
|
LaboratoryTestRefNumber,
|
|
LaboratoryProjectRefNumber,
|
|
LastModified,
|
|
LastModifiedBy,
|
|
LocalOnly,
|
|
Version
|
|
};
|
|
|
|
public Dictionary<string, string> GetValues()
|
|
{
|
|
var elementNameValuePairs = new Dictionary<string, string>();
|
|
|
|
elementNameValuePairs[fields.Name.ToString()] = Name;
|
|
elementNameValuePairs[fields.LaboratoryName.ToString()] = LabratoryName;
|
|
elementNameValuePairs[fields.LaboratoryContactName.ToString()] = LabratoryContactName;
|
|
elementNameValuePairs[fields.LaboratoryContactPhone.ToString()] = LabratoryContactPhone;
|
|
elementNameValuePairs[fields.LaboratoryContactFax.ToString()] = LabratoryContactFax;
|
|
elementNameValuePairs[fields.LaboratoryContactEmail.ToString()] = LabratoryContactEmail;
|
|
elementNameValuePairs[fields.LaboratoryTestRefNumber.ToString()] = LabratoryTestRefNumber;
|
|
elementNameValuePairs[fields.LaboratoryProjectRefNumber.ToString()] = LabratoryProjectRefNumber;
|
|
elementNameValuePairs[fields.LastModified.ToString()] =
|
|
LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
|
elementNameValuePairs[fields.LastModifiedBy.ToString()] = LastModifiedBy;
|
|
elementNameValuePairs[fields.LocalOnly.ToString()] = LocalOnly.ToString();
|
|
elementNameValuePairs[fields.Version.ToString()] =
|
|
Version.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
|
|
|
return elementNameValuePairs;
|
|
}
|
|
|
|
private int _version = 1;
|
|
|
|
public int Version
|
|
{
|
|
get => _version;
|
|
set => _version = value;
|
|
}
|
|
}
|
|
}
|