|
|
|
@ -31,7 +31,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
protected DbProviderFactory GetDbProviderFactory(IDbConnection conn) =>
|
|
|
|
|
DbProviderFactories.GetFactory(conn.GetType().Namespace);
|
|
|
|
|
|
|
|
|
|
public TransactionScope StartTransaction() => new();
|
|
|
|
|
internal static TransactionScope StartTransaction() => new();
|
|
|
|
|
|
|
|
|
|
protected void CacheItem(string key, object v)
|
|
|
|
|
{
|
|
|
|
@ -40,7 +40,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
_ = _Cache.Set(key, v, new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromHours(1)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ToolType> GetToolTypes()
|
|
|
|
|
internal IEnumerable<ToolType> GetToolTypes()
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<ToolType> cached;
|
|
|
|
|
string cacheKey = "GetToolTypes";
|
|
|
|
@ -55,7 +55,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ToolType GetToolTypeByName(string name)
|
|
|
|
|
internal ToolType GetToolTypeByName(string name)
|
|
|
|
|
{
|
|
|
|
|
ToolType cached;
|
|
|
|
|
string cacheKey = "GetToolTypeByName_" + name;
|
|
|
|
@ -72,7 +72,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ToolType GetToolTypeByID(int id)
|
|
|
|
|
internal ToolType GetToolTypeByID(int id)
|
|
|
|
|
{
|
|
|
|
|
ToolType cached;
|
|
|
|
|
string cacheKey = "GetToolTypeByID_" + id.ToString();
|
|
|
|
@ -89,7 +89,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ToolTypeMetadata> GetToolTypeMetadataByToolTypeID(int id)
|
|
|
|
|
internal IEnumerable<ToolTypeMetadata> GetToolTypeMetadataByToolTypeID(int id)
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<ToolTypeMetadata> cached;
|
|
|
|
|
string cacheKey = "GetToolTypeMetadataByToolTypeID_" + id.ToString();
|
|
|
|
@ -106,7 +106,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long InsertToolDataJSON(JToken jsonrow, long headerId, List<ToolTypeMetadata> metaData, string tableName)
|
|
|
|
|
internal long InsertToolDataJSON(JToken jsonrow, long headerId, List<ToolTypeMetadata> metaData, string tableName)
|
|
|
|
|
{
|
|
|
|
|
long r = -1;
|
|
|
|
|
using (DbConnection conn = GetDbConnection())
|
|
|
|
@ -261,7 +261,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return Convert.ToInt64(o);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataTable ExportData(string spName, DateTime startTime, DateTime endTime)
|
|
|
|
|
internal DataTable ExportData(string spName, DateTime startTime, DateTime endTime)
|
|
|
|
|
{
|
|
|
|
|
DataTable dt = new();
|
|
|
|
|
DateTime endTimeLocal = endTime.ToLocalTime();
|
|
|
|
@ -311,7 +311,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataTable GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerId, out long totalRecords)
|
|
|
|
|
internal DataTable GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerId, out long totalRecords)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -404,7 +404,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return dt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataTable GetData(int toolTypeId, long headerid)
|
|
|
|
|
internal DataTable GetData(int toolTypeId, long headerid)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -499,7 +499,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return dt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Guid GetHeaderAttachmentID(int toolTypeId, long headerId)
|
|
|
|
|
internal Guid GetHeaderAttachmentID(int toolTypeId, long headerId)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -511,7 +511,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
$"SELECT AttachmentID FROM [{tt.HeaderTableName}] WHERE ID = @HeaderID";
|
|
|
|
|
return conn.ExecuteScalar<Guid>(sql, param: new { HeaderID = headerId });
|
|
|
|
|
}
|
|
|
|
|
public string GetHeaderInsertDate(int toolTypeId, long headerId)
|
|
|
|
|
internal string GetHeaderInsertDate(int toolTypeId, long headerId)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -522,7 +522,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
$"SELECT CONVERT(varchar, case when [InsertDate] < [Date] or [Date] is null then [InsertDate] else [Date] end, 120) d FROM[{tt.HeaderTableName}] where ID = @HeaderID";
|
|
|
|
|
return conn.ExecuteScalar<string>(sql, param: new { HeaderID = headerId });
|
|
|
|
|
}
|
|
|
|
|
public string GetAttachmentInsertDateByGUID(string tableName, Guid attachmentId)
|
|
|
|
|
internal string GetAttachmentInsertDateByGUID(string tableName, Guid attachmentId)
|
|
|
|
|
{
|
|
|
|
|
using DbConnection conn = GetDbConnection();
|
|
|
|
|
string sql = "";
|
|
|
|
@ -537,13 +537,13 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
|
|
|
|
|
return conn.ExecuteScalar<string>(sql, param: new { AttachmentID = attachmentId });
|
|
|
|
|
}
|
|
|
|
|
public void SetHeaderDirName(string tableName, long headerId, string dateDir)
|
|
|
|
|
internal void SetHeaderDirName(string tableName, long headerId, string dateDir)
|
|
|
|
|
{
|
|
|
|
|
using DbConnection conn = GetDbConnection();
|
|
|
|
|
_ = conn.Execute($"UPDATE [{tableName}] SET AttachDirName = @AttachDirName WHERE ID = @HeaderID;", new { HeaderID = headerId, AttachDirName = dateDir });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Guid GetDataAttachmentID(int toolTypeId, long headerId, string title)
|
|
|
|
|
internal Guid GetDataAttachmentID(int toolTypeId, long headerId, string title)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -556,7 +556,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return conn.ExecuteScalar<Guid>(sql, param: new { HeaderID = headerId, Title = title });
|
|
|
|
|
}
|
|
|
|
|
// J Ouellette Added
|
|
|
|
|
public string GetDataInsertDate(int toolTypeId, long headerId, string title)
|
|
|
|
|
internal string GetDataInsertDate(int toolTypeId, long headerId, string title)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -575,7 +575,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
|
|
|
|
|
return conn.ExecuteScalar<string>(sql, param: new { HeaderID = headerId, Title = title });
|
|
|
|
|
}
|
|
|
|
|
public void SetDataDirName(string tableName, long headerId, string title, string dateDir)
|
|
|
|
|
internal void SetDataDirName(string tableName, long headerId, string title, string dateDir)
|
|
|
|
|
{
|
|
|
|
|
using DbConnection conn = GetDbConnection();
|
|
|
|
|
string sql =
|
|
|
|
@ -583,13 +583,13 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
_ = conn.Execute(sql, param: new { HeaderID = headerId, Title = title, AttachDirName = dateDir });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PurgeExistingData(int toolTypeId, string title)
|
|
|
|
|
internal void PurgeExistingData(int toolTypeId, string title)
|
|
|
|
|
{
|
|
|
|
|
using DbConnection conn = GetDbConnection();
|
|
|
|
|
_ = conn.Execute("PurgeExistingData", param: new { ToolTypeID = toolTypeId, Title = title }, commandType: CommandType.StoredProcedure);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataSet GetOIExportData(int toolTypeId, long headerid)
|
|
|
|
|
internal DataSet GetOIExportData(int toolTypeId, long headerid)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -618,7 +618,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return ds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<HeaderCommon> GetHeaderTitles(int toolTypeId, int? pageNo, int? pageSize, out long totalRecords)
|
|
|
|
|
internal IEnumerable<HeaderCommon> GetHeaderTitles(int toolTypeId, int? pageNo, int? pageSize, out long totalRecords)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -647,7 +647,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return headers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<KeyValuePair<string, string>> GetHeaderFields(int toolTypeId, long headerid)
|
|
|
|
|
internal IEnumerable<KeyValuePair<string, string>> GetHeaderFields(int toolTypeId, long headerid)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -694,7 +694,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<AwaitingDisposition> GetAwaitingDisposition()
|
|
|
|
|
internal IEnumerable<AwaitingDisposition> GetAwaitingDisposition()
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<AwaitingDisposition>? r;
|
|
|
|
|
if (!string.IsNullOrEmpty(_MockRoot))
|
|
|
|
@ -712,7 +712,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int UpdateReviewDate(int toolTypeId, long headerId, bool clearDate)
|
|
|
|
|
internal int UpdateReviewDate(int toolTypeId, long headerId, bool clearDate)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -734,7 +734,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Guid GetHeaderAttachmentIDByTitle(int toolTypeId, string title)
|
|
|
|
|
internal Guid GetHeaderAttachmentIDByTitle(int toolTypeId, string title)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -746,7 +746,7 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
return conn.ExecuteScalar<Guid>(sql, param: new { Title = title });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Guid GetDataAttachmentIDByTitle(int toolTypeId, string title)
|
|
|
|
|
internal Guid GetDataAttachmentIDByTitle(int toolTypeId, string title)
|
|
|
|
|
{
|
|
|
|
|
ToolType tt = GetToolTypeByID(toolTypeId);
|
|
|
|
|
if (tt is null)
|
|
|
|
@ -759,4 +759,30 @@ public class MetrologyRepository : IMetrologyRepository
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataTable IMetrologyRepository.GetDataSharePoint(int toolTypeId, string headerId) => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
IEnumerable<ToolType> IMetrologyRepository.GetToolTypes() => GetToolTypes();
|
|
|
|
|
ToolType IMetrologyRepository.GetToolTypeByName(string name) => GetToolTypeByName(name);
|
|
|
|
|
ToolType IMetrologyRepository.GetToolTypeByID(int id) => GetToolTypeByID(id);
|
|
|
|
|
IEnumerable<ToolTypeMetadata> IMetrologyRepository.GetToolTypeMetadataByToolTypeID(int id) => GetToolTypeMetadataByToolTypeID(id);
|
|
|
|
|
TransactionScope IMetrologyRepository.StartTransaction() => StartTransaction();
|
|
|
|
|
void IMetrologyRepository.PurgeExistingData(int toolTypeId, string title) => PurgeExistingData(toolTypeId, title);
|
|
|
|
|
long IMetrologyRepository.InsertToolDataJSON(JToken jsonbody, long headerId, List<ToolTypeMetadata> metaData, string tableName) => InsertToolDataJSON(jsonbody, headerId, metaData, tableName);
|
|
|
|
|
DataTable IMetrologyRepository.ExportData(string spName, DateTime startTime, DateTime endTime) => ExportData(spName, startTime, endTime);
|
|
|
|
|
DataTable IMetrologyRepository.GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerid, out long totalRecords) => GetHeaders(toolTypeId, startTime, endTime, pageNo, pageSize, headerid, out totalRecords);
|
|
|
|
|
DataTable IMetrologyRepository.GetData(int toolTypeId, long headerId) => GetData(toolTypeId, headerId);
|
|
|
|
|
IEnumerable<HeaderCommon> IMetrologyRepository.GetHeaderTitles(int toolTypeId, int? pageNo, int? pageSize, out long totalRecords) => GetHeaderTitles(toolTypeId, pageNo, pageSize, out totalRecords);
|
|
|
|
|
Guid IMetrologyRepository.GetHeaderAttachmentIDByTitle(int toolTypeId, string title) => GetHeaderAttachmentIDByTitle(toolTypeId, title);
|
|
|
|
|
Guid IMetrologyRepository.GetDataAttachmentIDByTitle(int toolTypeId, string title) => GetDataAttachmentIDByTitle(toolTypeId, title);
|
|
|
|
|
Guid IMetrologyRepository.GetHeaderAttachmentID(int toolTypeId, long headerId) => GetHeaderAttachmentID(toolTypeId, headerId);
|
|
|
|
|
string IMetrologyRepository.GetHeaderInsertDate(int toolTypeId, long headerId) => GetHeaderInsertDate(toolTypeId, headerId);
|
|
|
|
|
string IMetrologyRepository.GetAttachmentInsertDateByGUID(string tableName, Guid attachmentId) => GetAttachmentInsertDateByGUID(tableName, attachmentId);
|
|
|
|
|
void IMetrologyRepository.SetHeaderDirName(string tableName, long headerId, string dateDir) => SetHeaderDirName(tableName, headerId, dateDir);
|
|
|
|
|
Guid IMetrologyRepository.GetDataAttachmentID(int toolTypeId, long headerId, string title) => GetDataAttachmentID(toolTypeId, headerId, title);
|
|
|
|
|
string IMetrologyRepository.GetDataInsertDate(int toolTypeId, long headerId, string title) => GetDataInsertDate(toolTypeId, headerId, title);
|
|
|
|
|
void IMetrologyRepository.SetDataDirName(string tableName, long headerId, string title, string dateDir) => SetDataDirName(tableName, headerId, title, dateDir);
|
|
|
|
|
DataSet IMetrologyRepository.GetOIExportData(int toolTypeId, long headerid) => GetOIExportData(toolTypeId, headerid);
|
|
|
|
|
IEnumerable<KeyValuePair<string, string>> IMetrologyRepository.GetHeaderFields(int toolTypeId, long headerid) => GetHeaderFields(toolTypeId, headerid);
|
|
|
|
|
IEnumerable<AwaitingDisposition> IMetrologyRepository.GetAwaitingDisposition() => GetAwaitingDisposition();
|
|
|
|
|
int IMetrologyRepository.UpdateReviewDate(int toolTypeId, long headerId, bool clearDate) => UpdateReviewDate(toolTypeId, headerId, clearDate);
|
|
|
|
|
|
|
|
|
|
}
|