79 lines
3.5 KiB
C#
79 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
|
|
namespace DatabaseExport
|
|
{
|
|
public class TestObjectTemplateCollection
|
|
{
|
|
|
|
private static volatile TestObjectTemplateCollection _testObjectCollection;
|
|
public static TestObjectTemplateCollection TemplateCollection => _testObjectCollection ?? (_testObjectCollection = new TestObjectTemplateCollection());
|
|
|
|
public GroupTemplateTableInfo[] GetAllTemplates(bool bIncludeEmbeddedAndSysBuilt = true)
|
|
{
|
|
var templates = new List<GroupTemplateTableInfo>();
|
|
|
|
using (var sql = DbOperations.GetCommand())
|
|
{
|
|
if (bIncludeEmbeddedAndSysBuilt)
|
|
{
|
|
sql.CommandText =
|
|
"SELECT TemplateName, Description, LastModifiedBy, TestObjectType, LastModified, SysBuilt, Embedded from tblTestObjectTemplates";
|
|
}
|
|
else
|
|
{
|
|
sql.CommandText = "SELECT TemplateName, Description, LastModifiedBy, TestObjectType, LastModified, SysBuilt, Embedded from tblTestObjectTemplates WHERE (Embedded=0 OR Embedded is NULL) AND SysBuilt=0";
|
|
}
|
|
|
|
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
|
{
|
|
foreach (DataRow dr in ds.Tables[0].Rows)
|
|
{
|
|
var templateName = (string)dr["TemplateName"];
|
|
var templateDescription = (string)dr["Description"];
|
|
var lastModifiedBy = (string)dr["LastModifiedBy"];
|
|
var testObjectType = (string)dr["TestObjectType"];
|
|
var lastModified = Convert.ToDateTime(dr["LastModified"]);
|
|
var sysBuilt = Convert.ToBoolean(dr["SysBuilt"]);
|
|
var embeddedValue = dr["Embedded"];
|
|
var embedded = false;
|
|
if (!DBNull.Value.Equals(embeddedValue))
|
|
{
|
|
embedded = Convert.ToBoolean(dr["Embedded"]);
|
|
}
|
|
|
|
var isoSupportLevel =
|
|
(testObjectType.Contains(TestObjectTemplate.NON_ISO_TESTOBJECT_CHANNEL_TYPE) ||
|
|
testObjectType.Contains(TestObjectTemplateChannel.NONISOCHANNELTYPE))
|
|
? SerializedSettings.ISOSupportLevels.NO_ISO
|
|
: SerializedSettings.ISOSupportLevels.ISO_ONLY;
|
|
|
|
templates.Add(new GroupTemplateTableInfo(templateName, isoSupportLevel, sysBuilt,
|
|
templateDescription, lastModified, lastModifiedBy, embedded));
|
|
}
|
|
}
|
|
|
|
}
|
|
return templates.ToArray();
|
|
}
|
|
private static volatile TestObjectTemplate _sysBuiltTestObjectTemplate;
|
|
public TestObjectTemplate SysBuiltTestObjectTemplate => _sysBuiltTestObjectTemplate;
|
|
|
|
public TestObjectTemplate GetTemplate(string templateId)
|
|
{
|
|
//if (null == Application.Current) { return null; }
|
|
var db = ISO13499FileDb.IsoDb;
|
|
var template = ISO.TestObjectTemplate.GetTemplate(ref db, templateId);
|
|
if (null == template)
|
|
{
|
|
return new TestObjectTemplate();
|
|
}
|
|
else
|
|
{
|
|
return new TestObjectTemplate(template, ref db);
|
|
}
|
|
}
|
|
}
|
|
}
|