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 @@
12

View File

@@ -0,0 +1 @@
12

View File

@@ -0,0 +1,211 @@
namespace DTS.Common.Storage
{
public partial class DbOperations
{
public abstract class MMETables
{
public const string MyType = "MyType"; //This was exported in all versions up to 1.3.496 and was replaced by "CustomChannelType"
public const string CustomChannelType = "CustomChannelType"; //This was exported in versions from 1.3.498 - 1.3.515 and was replaced by "TYPE"
public const string Id = "Id"; //This was exported in all versions up to 1.3.515 and was replaced by "ID"
public const string MMEPossibleChannelsTable = "MMEPossibleChannels";
public enum MMEPossibleChannelsFields
{
ID,
TYPE,
[CustomChannelFieldSizeAttribute(50)]
TEST_OBJECT,
[CustomChannelFieldSizeAttribute(50)]
POSITION,
[CustomChannelFieldSizeAttribute(50)]
TRANS_MAIN_LOC,
[CustomChannelFieldSizeAttribute(50)]
FINE_LOC_1,
[CustomChannelFieldSizeAttribute(50)]
FINE_LOC_2,
[CustomChannelFieldSizeAttribute(50)]
FINE_LOC_3,
[CustomChannelFieldSizeAttribute(50)]
PHYSICAL_DIMENSION,
[CustomChannelFieldSizeAttribute(50)]
DIRECTION,
[CustomChannelFieldSizeAttribute(50)]
DEFAULT_FILTER_CLASS,
[CustomChannelFieldSizeAttribute(100)]
TEXT_L1,
[CustomChannelFieldSizeAttribute(100)]
TEXT_L2,
VERSION,
DATE,
[CustomChannelFieldSizeAttribute(50)]
REMARKS,
EXPIRED,
[CustomChannelFieldSizeAttribute(50)]
SORTKEY,
[CustomChannelFieldSizeAttribute(50)]
PICTURE_SHORTNAME,
[CustomChannelFieldSizeAttribute(50)]
LAST_CHANGE,
[CustomChannelFieldSizeAttribute(50)]
LAST_CHANGE_TEXT,
[CustomChannelFieldSizeAttribute(50)]
HISTORY
}
public const string MMEDirectionsTable = "tblMMEDirections";
public enum MMEDirectionsFields
{
s_GUID,
DIRECTION,
TEXT_L1,
TEXT_L2,
DATE,
VERSION,
EXPIRED,
REMARKS,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY,
SORTKEY
}
public const string MMEFilterClassesTable = "tblMMEFilterClasses";
public enum MMEFilterClassesFields
{
s_GUID,
FILTER_CLASS,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEFineLocations1Table = "tblMMEFineLocations1";
public enum MMEFineLocations1Fields
{
s_GUID,
FINE_LOC_1,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEFineLocations2Table = "tblMMEFineLocations2";
public enum MMEFineLocations2Fields
{
s_GUID,
FINE_LOC_2,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEFineLocations3Table = "tblMMEFineLocations3";
public enum MMEFineLocations3Fields
{
s_GUID,
FINE_LOC_3,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
PICTURE_SHORTNAME,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEPhysicalDimensions = "tblMMEPhysicalDimensions";
public enum MMEPhysicalDimensionFields
{
s_GUID,
PHYSICAL_DIMENSION,
TEXT_L1,
TEXT_L2,
DEFAULT_UNIT,
LENGTH_EXP,
TIME_EXP,
MASS_EXP,
ELECTRIC_CURRENT_EXP,
TEMPERATURE_EXP,
LUMINOUS_INTENSITY_EXP,
AMOUNT_OFSUBSTANCE_EXP,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEPositionsTable = "tblMMEPositions";
public enum MMEPositionsFields
{
s_GUID,
POSITION,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMETestObjectsTable = "tblMMETestObjects";
public enum MMETestObjectsFields
{
s_GUID,
TEST_OBJECT,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEMainLocationTable = "tblMMEMainLocations";
public enum MMEMainLocationsFields
{
s_GUID,
TYPE,
TRANS_MAIN_LOC,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
PICTURE_SHORTNAME,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
}
}
}

View File

@@ -0,0 +1,38 @@
namespace DTS.Storage
{
/// <summary>
/// tables and fields for user objects
/// </summary>
public abstract class Users
{
public const string USERS_TABLE = "DataPROUsers";
public enum UserFields
{
ID,
UserName,
DisplayName,
Password,
Role,
LastModified,
LastModifiedBy,
LocalOnly
}
public const string UIITEMS_TABLE = "UIITEMS";
public enum UIItemFields
{
ID,
Name
}
public const string USERUISETTINGS_TABLE = "UserUIItemSettings";
public enum UserUIItemSettingFields
{
UserId,
UIItemID,
Permission,
Visible
}
}
}

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Detach_RemoteDB.sql" -v DBNAME=%3

View File

@@ -0,0 +1,22 @@
namespace DTS.Storage
{
public abstract class DigitalOutputSettings
{
public const string Table = "tblTOMDigitalChannels";
public enum Fields
{
ChannelDescription,
DelayMS,
DurationMS,
OutputMode,
LimitDuration,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
DurationMSFloat,
UserTags
}
}
}

View File

@@ -0,0 +1,208 @@
namespace DTS.Storage
{
public class MMETables
{
public const string MyType = "MyType"; //This was exported in all versions up to 1.3.496 and was replaced by "CustomChannelType"
public const string CustomChannelType = "CustomChannelType"; //This was exported in versions from 1.3.498 - 1.3.515 and was replaced by "TYPE"
public const string Id = "Id"; //This was exported in all versions up to 1.3.515 and was replaced by "ID"
public const string MMEPossibleChannelsTable = "tblMMEPossibleChannels";
public enum MMEPossibleChannelsFields
{
ID,
TYPE,
[CustomChannelFieldSize(50)]
TEST_OBJECT,
[CustomChannelFieldSize(50)]
POSITION,
[CustomChannelFieldSize(50)]
TRANS_MAIN_LOC,
[CustomChannelFieldSize(50)]
FINE_LOC_1,
[CustomChannelFieldSize(50)]
FINE_LOC_2,
[CustomChannelFieldSize(50)]
FINE_LOC_3,
[CustomChannelFieldSize(50)]
PHYSICAL_DIMENSION,
[CustomChannelFieldSize(50)]
DIRECTION,
[CustomChannelFieldSize(50)]
DEFAULT_FILTER_CLASS,
[CustomChannelFieldSize(100)]
TEXT_L1,
[CustomChannelFieldSize(100)]
TEXT_L2,
VERSION,
DATE,
[CustomChannelFieldSize(50)]
REMARKS,
EXPIRED,
[CustomChannelFieldSize(50)]
SORTKEY,
[CustomChannelFieldSize(50)]
PICTURE_SHORTNAME,
[CustomChannelFieldSize(50)]
LAST_CHANGE,
[CustomChannelFieldSize(50)]
LAST_CHANGE_TEXT,
[CustomChannelFieldSize(50)]
HISTORY
}
public const string MMEDirectionsTable = "tblMMEDirections";
public enum MMEDirectionsFields
{
s_GUID,
DIRECTION,
TEXT_L1,
TEXT_L2,
DATE,
VERSION,
EXPIRED,
REMARKS,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY,
SORTKEY
}
public const string MMEFilterClassesTable = "tblMMEFilterClasses";
public enum MMEFilterClassesFields
{
s_GUID,
FILTER_CLASS,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEFineLocations1Table = "tblMMEFineLocations1";
public enum MMEFineLocations1Fields
{
s_GUID,
FINE_LOC_1,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEFineLocations2Table = "tblMMEFineLocations2";
public enum MMEFineLocations2Fields
{
s_GUID,
FINE_LOC_2,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEFineLocations3Table = "tblMMEFineLocations3";
public enum MMEFineLocations3Fields
{
s_GUID,
FINE_LOC_3,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
PICTURE_SHORTNAME,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEPhysicalDimensions = "tblMMEPhysicalDimensions";
public enum MMEPhysicalDimensionFields
{
s_GUID,
PHYSICAL_DIMENSION,
TEXT_L1,
TEXT_L2,
DEFAULT_UNIT,
LENGTH_EXP,
TIME_EXP,
MASS_EXP,
ELECTRIC_CURRENT_EXP,
TEMPERATURE_EXP,
LUMINOUS_INTENSITY_EXP,
AMOUNT_OFSUBSTANCE_EXP,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEPositionsTable = "tblMMEPositions";
public enum MMEPositionsFields
{
s_GUID,
POSITION,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMETestObjectsTable = "tblMMETestObjects";
public enum MMETestObjectsFields
{
s_GUID,
TEST_OBJECT,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
public const string MMEMainLocationTable = "tblMMEMainLocations";
public enum MMEMainLocationsFields
{
s_GUID,
TYPE,
TRANS_MAIN_LOC,
TEXT_L1,
TEXT_L2,
VERSION,
DATE,
REMARKS,
EXPIRED,
SORTKEY,
PICTURE_SHORTNAME,
LAST_CHANGE,
LAST_CHANGE_TEXT,
HISTORY
}
}
}

View File

@@ -0,0 +1,4 @@
sqlcmd -E -S (localdb)\DataPROInstance -Q "ALTER DATABASE [%1] SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
sqlcmd -E -S (localdb)\DataPROInstance -Q "sp_Detach_db %1"

View File

@@ -0,0 +1,7 @@
namespace DTS.Storage
{
public abstract class MMEPossibleChannels
{
public const string Table = "tblMMEPossibleChannels";
}
}

View File

@@ -0,0 +1,6 @@
USE master
GO
sp_attach_db '$(DBNAME)Pre20', 'C:\DataPRO_SQL\$(DBNAME)Pre20.mdf'
GO

View File

@@ -0,0 +1,74 @@
namespace DTS.Storage
{
public class DAS
{
public const string Table = "tblDAS";
public enum Fields
{
SerialNumber,
Type,
MaxModules,
MaxMemory,
MaxSampleRate,
MinSampleRate,
FirmwareVersion,
CalDate,
ProtocolVersion,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
LastUsed,
LastUsedBy,
Connection,
Channels,
Position,
ChannelTypes,
Reprogramable,
Reconfigurable,
IsModule
}
public const string TableDASChannels = "tblDASChannels";
public enum DASChannelFields
{
HardwareId,
ChannelIdx,
SupportedBridges,
SupportedExcitations,
DASDisplayOrder,
LocalOnly,
SupportedDigitalInputModes,
SupportedSquibFireModes,
SupportedDigitalOutputModes,
ModuleSerialNumber,
ModuleArrayIndex
}
public const string SLICE1_PROTOTYPE = "SLICE1 Prototype";
public const string SLICEPRO_PROTOTYPE = "SLICEPRO Prototype";
public const string PROTOTYPE_POSITION = "Prototype";
public const string SLICE1_5PROTOTYPE = "SLICE+ Prototype";
public const string G5_VDSPROTOTYPE = "G5 VDS Prototype";
public const string G5_IPORTPROTOTYPE = "G5 iPort Prototype";
public const string TDASPRO_8MRack = "TDASPro Rack 8M Prototype";
public const string TDASPRO_4MRack = "TDASPRO Rack 4M Prototype";
public const string ECM_PROTOTYPE = "SLICE ECM Prototype";
public const string SLE_PROTOTYPE = "SLICE PRO Lab Ethernet Prototype";
public const string SDB_PROTOTYPE = "SLICE Distributor Prototype";
public const string Slice_NanoPROTOTYPE = "SLICE Nano Prototype";
public const string Slice_MicroPROTOTYPE = "SLICE Micro Prototype";
public const string SLICEPRODIM_PROTOTYPE = "SLICE Pro DIM";
public const string SLICEPROSLD_PROTOTYPE = "SLICE PRO Lab DIM";
public const string SLICEPROTOM_PROTOTYPE = "SLICE Pro TOM";
public const string SLICEPROSLT_PROTOTYPE = "SLICE PRO Lab TOM";
public const string SLICEPROSIM_PROTOTYPE = "SLICE Pro SIM";
public const string SLICEPROSLS_PROTOTYPE = "SLICE PRO Lab SIM";
public const string SLICE1_5_MicroPROTOTYPE = "SLICE MICRO BASE+ Prototype";
public const string G5_INDUMMYPROTOTYPE = "G5 InDummy Prototype";
public const string SG5_PROTOTYPE = "SLICE G5 Prototype";
public const string TDASPRO_LabRack = "TDAS PRO Lab Rack";
public const string SLICE6_PROTOTYPE = "SLICE6 Prototype";
public const string SLICE6DB_PROTOTYPE = "SLICE6Db Prototype";
}
}

View File

@@ -0,0 +1,22 @@
namespace DTS.Storage
{
public abstract class LabratoryDetails
{
public const string Table = "tblLabratoryDetails";
public enum LabratoryDetailsFields
{
Name,
LabratoryName,
LabratoryContactName,
LabratoryContactPhone,
LabratoryContactFax,
LabratoryContactEmail,
LabratoryTestRefNumber,
LabratoryProjectRefNumber,
LastModified,
LastModifiedBy,
LocalOnly,
Version
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
namespace DTS.Storage
{
public class DbTypeAttr : Attribute
{
public string DbType { get; private set; }
internal DbTypeAttr(string attr)
{
DbType = attr;
}
public static string GetDbType(object o)
{
if (o != null)
{
System.Reflection.MemberInfo[] mi = o.GetType().GetMember(o.ToString());
if (mi != null && mi.Length > 0)
{
DbTypeAttr attr = Attribute.GetCustomAttribute(mi[0], typeof(DbTypeAttr)) as DbTypeAttr;
if (null != attr)
{
return attr.DbType;
}
}
}
return null;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Linq;
namespace DTS.Storage
{
#region CustomChannelFieldSizeExtensions
public class CustomChannelFieldSizeAttribute : Attribute
{
internal CustomChannelFieldSizeAttribute(int size)
{
this.Size = size;
}
public int Size { get; private set; }
}
public static class CustomChannelFieldSizeExtensions
{
public static int GetFieldSize(MMETables.MMEPossibleChannelsFields field)
{
return (field.GetAttribute<CustomChannelFieldSizeAttribute>()).Size;
}
}
public static class EnumExtensions
{
public static TAttribute GetAttribute<TAttribute>(this Enum value)
where TAttribute : Attribute
{
return (value.GetType()).GetField(Enum.GetName(value.GetType(), value)).GetCustomAttributes(false).OfType<TAttribute>().SingleOrDefault();
}
}
#endregion CustomChannelFieldSizeExtensions
}

View File

@@ -0,0 +1,21 @@
namespace DTS.Storage
{
public abstract class Tags
{
public const string Table = "tblTags";
public enum TagFields
{
TagId,
TagText,
Obsolete
}
public const string TAGASSIGNMENTS_TABLE = "TagAssignments";
public enum TagAssignmentFields
{
ObjectID,
ObjectType,
TagID
}
}
}

View File

@@ -0,0 +1,226 @@
using System;
using System.Collections;
using System.Data;
namespace DTS.Common.Storage
{
/// <summary>
/// Convert a base data type to another base data type
/// </summary>
public sealed class TypeConvertor
{
private struct DbTypeMapEntry
{
public Type Type;
public DbType DbType;
public SqlDbType SqlDbType;
public DbTypeMapEntry(Type type, DbType dbType, SqlDbType sqlDbType)
{
Type = type;
DbType = dbType;
SqlDbType = sqlDbType;
}
};
private static ArrayList _DbTypeList = new ArrayList();
#region Constructors
static TypeConvertor()
{
var dbTypeMapEntry
= new DbTypeMapEntry(typeof(bool), DbType.Boolean, SqlDbType.Bit);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(byte), DbType.Byte, SqlDbType.TinyInt);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(byte[]), DbType.Binary, SqlDbType.Image);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(DateTime), DbType.DateTime, SqlDbType.DateTime);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(decimal), DbType.Decimal, SqlDbType.Decimal);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(double), DbType.Double, SqlDbType.Float);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(Guid), DbType.Guid, SqlDbType.UniqueIdentifier);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(short), DbType.Int16, SqlDbType.SmallInt);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(int), DbType.Int32, SqlDbType.Int);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(long), DbType.Int64, SqlDbType.BigInt);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(object), DbType.Object, SqlDbType.Variant);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry
= new DbTypeMapEntry(typeof(string), DbType.String, SqlDbType.NVarChar);
_DbTypeList.Add(dbTypeMapEntry);
dbTypeMapEntry = new DbTypeMapEntry(typeof(TimeSpan), DbType.Time, SqlDbType.Time); _DbTypeList.Add(dbTypeMapEntry);
_DbTypeList.Add(dbTypeMapEntry);
}
private TypeConvertor()
{
}
#endregion
#region Methods
/// <summary>
/// Convert db type to .Net data type
/// </summary>
/// <param name="dbType"></param>
/// <returns></returns>
public static Type ToNetType(DbType dbType)
{
var entry = Find(dbType);
return entry.Type;
}
/// <summary>
/// Convert TSQL type to .Net data type
/// </summary>
/// <param name="sqlDbType"></param>
/// <returns></returns>
public static Type ToNetType(SqlDbType sqlDbType)
{
var entry = Find(sqlDbType);
return entry.Type;
}
/// <summary>
/// Convert .Net type to Db type
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static DbType ToDbType(Type type)
{
var entry = Find(type);
return entry.DbType;
}
/// <summary>
/// Convert TSQL data type to DbType
/// </summary>
/// <param name="sqlDbType"></param>
/// <returns></returns>
public static DbType ToDbType(SqlDbType sqlDbType)
{
var entry = Find(sqlDbType);
return entry.DbType;
}
/// <summary>
/// Convert .Net type to TSQL data type
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static SqlDbType ToSqlDbType(Type type)
{
var entry = Find(type);
return entry.SqlDbType;
}
/// <summary>
/// Convert DbType type to TSQL data type
/// </summary>
/// <param name="dbType"></param>
/// <returns></returns>
public static SqlDbType ToSqlDbType(DbType dbType)
{
var entry = Find(dbType);
return entry.SqlDbType;
}
private static DbTypeMapEntry Find(Type type)
{
object retObj = null;
for (var i = 0; i < _DbTypeList.Count; i++)
{
var entry = (DbTypeMapEntry)_DbTypeList[i];
if (entry.Type == (Nullable.GetUnderlyingType(type) ?? type))
{
retObj = entry;
break;
}
}
if (retObj == null)
{
throw
new ApplicationException("Referenced an unsupported Type");
}
return (DbTypeMapEntry)retObj;
}
private static DbTypeMapEntry Find(DbType dbType)
{
object retObj = null;
for (var i = 0; i < _DbTypeList.Count; i++)
{
var entry = (DbTypeMapEntry)_DbTypeList[i];
if (entry.DbType == dbType)
{
retObj = entry;
break;
}
}
if (retObj == null)
{
throw
new ApplicationException("Referenced an unsupported DbType");
}
return (DbTypeMapEntry)retObj;
}
private static DbTypeMapEntry Find(SqlDbType sqlDbType)
{
object retObj = null;
for (var i = 0; i < _DbTypeList.Count; i++)
{
var entry = (DbTypeMapEntry)_DbTypeList[i];
if (entry.SqlDbType == sqlDbType)
{
retObj = entry;
break;
}
}
if (retObj == null)
{
throw
new ApplicationException("Referenced an unsupported SqlDbType");
}
return (DbTypeMapEntry)retObj;
}
#endregion
}
}

View File

@@ -0,0 +1,214 @@
using System.IO;
using DTS.Common.Utilities.Logging;
using System;
using DbAPI.Errors;
namespace DTS.Common.Storage
{
public abstract class DatabaseServices
{
public static void RestoreLocalDatabase(string defaultDbName)
{
LocalOnlyOperations.Connection.ResetLocalConnectionString();
Utils.Database.StopInstance(INSTANCE_NAME, APILogger.Log);
var dbFileNameSource = Path.Combine(Environment.CurrentDirectory, LOCAL_DB_FOLDER, defaultDbName) + ".mdf";
var logFileNameSource = Path.Combine(Environment.CurrentDirectory, LOCAL_DB_FOLDER, defaultDbName) + "_log.ldf";
var dbFileNameBak = Path.Combine(Environment.CurrentDirectory, LOCAL_DB_FOLDER, defaultDbName) + ".BAK";
var logFileNameBak = Path.Combine(Environment.CurrentDirectory, LOCAL_DB_FOLDER, defaultDbName) + "_log.BAK";
if (!File.Exists(logFileNameBak) || !File.Exists(dbFileNameBak))
{
throw new Utils.Database.SqlServerLocalDbException(Utils.Database.SqlServerLocalDbException.Errors.LocalDbDoesntExist);
}
if (File.Exists(dbFileNameSource))
{
Utils.FileUtils.DeleteFileOrMove(dbFileNameSource, APILogger.Log);
}
if (File.Exists(logFileNameSource))
{
Utils.FileUtils.DeleteFileOrMove(logFileNameSource, APILogger.Log);
}
File.Copy(dbFileNameBak, dbFileNameSource);
File.Copy(logFileNameBak, logFileNameSource);
LocalOnlyOperations.Connection.Server = LOCAL_SERVER;
Utils.Database.StartInstance(INSTANCE_NAME, APILogger.Log);
LocalOnlyOperations.Connection.DbName = defaultDbName;
}
public static void BackupLocalDatabase(string defaultDbName)
{
LocalOnlyOperations.Connection.ResetLocalConnectionString();
Utils.Database.StopInstance(INSTANCE_NAME, APILogger.Log);
var dbFileNameSource = Path.Combine(Environment.CurrentDirectory, LOCAL_DB_FOLDER, defaultDbName) + ".mdf";
var logFileNameSource = Path.Combine(Environment.CurrentDirectory, LOCAL_DB_FOLDER, defaultDbName) + "_log.ldf";
var dbFileNameBak = Path.Combine(Environment.CurrentDirectory, LOCAL_DB_FOLDER, defaultDbName) + ".BAK";
var logFileNameBak = Path.Combine(Environment.CurrentDirectory, LOCAL_DB_FOLDER, defaultDbName) + "_log.BAK";
if (File.Exists(dbFileNameBak))
{
Utils.FileUtils.DeleteFileOrMove(dbFileNameBak, APILogger.Log);
}
if (File.Exists(logFileNameBak))
{
Utils.FileUtils.DeleteFileOrMove(logFileNameBak, APILogger.Log);
}
if (!File.Exists(dbFileNameSource))
{
throw new FileNotFoundException(dbFileNameSource);
}
if (!File.Exists(logFileNameSource))
{
throw new FileNotFoundException(logFileNameSource);
}
File.Copy(dbFileNameSource, dbFileNameBak);
File.Copy(logFileNameSource, logFileNameBak);
LocalOnlyOperations.Connection.Server = LOCAL_SERVER;
Utils.Database.StartInstance(INSTANCE_NAME, APILogger.Log);
LocalOnlyOperations.Connection.DbName = defaultDbName;
}
public const string INSTANCE_NAME = "DataPROInstance";
public const string LOCAL_SERVER = @"(localdb)\DataPROInstance";
public const string SCRIPTS_FOLDER = "SQL Server Scripts";
public const string LOCAL_DB_FOLDER = "db";
private const string ISO = "ISO";
public const string ATTACH_DBS_BAT = "AttachDBs.bat";
public static int SetupLocal(string defaultDbName)
{
DbOperations.Connection.ResetLocalConnectionString();
var details = new DbAPI.Connections.ConnectionDetails();
details.ClientDbVersion = DbOperations.CURRENT_DB_VERSION;
details.AttachDbsBatPath = Path.Combine(SCRIPTS_FOLDER, ATTACH_DBS_BAT);
details.DbFolderPath = Path.Combine(LOCAL_DB_FOLDER);
details.DbName = defaultDbName;
details.UsingCentralizedDb = false;
details.DbServer = LOCAL_SERVER;
details.InstanceName = INSTANCE_NAME;
details.UseNTLMAuthentication = true;
details.SqlDbPath = Utils.Database.GetSqlServerLocalDbPath();
details.ODBCToolsPath = Utils.Database.GetODBCToolsPath(APILogger.Log);
APILogger.Log($"SqlDbPath is {details.SqlDbPath}; ODBCToolsPath is {details.ODBCToolsPath}");
DbOperations.Connection.Server = details.DbServer;
DbOperations.Connection.DBName = details.DbName;
DbOperations.Connection.Username = details.DbUser;
DbOperations.Connection.Password = details.DbUserPassword;
DbOperations._usingNTLMAuthentication = details.UseNTLMAuthentication;
DbOperations._usingCentralizedDB = details.UsingCentralizedDb;
var res = DbAPI.DbAPI.Connections.ConnectToDb(details);
if (ErrorCodes.ERROR_SUCCESS != res)
{
throw new SystemException($"Couldn't connect to database: {details} - {res}");
}
var connectionDbVersion = DbOperations.GetConnectionDbVersion();
return connectionDbVersion;
}
public static int SetupLocal2(string defaultDbName)
{
LocalOnlyOperations.Connection.Server = LOCAL_SERVER;
var details = new DbAPI.Connections.ConnectionDetails();
details.ClientDbVersion = DbOperations.CURRENT_DB_VERSION;
details.AttachDbsBatPath = Path.Combine(SCRIPTS_FOLDER, ATTACH_DBS_BAT);
details.DbFolderPath = LOCAL_DB_FOLDER;
details.DbName = defaultDbName;
details.UsingCentralizedDb = false;
details.DbServer = LOCAL_SERVER;
details.InstanceName = INSTANCE_NAME;
details.UseNTLMAuthentication = true;
details.SqlDbPath = Utils.Database.GetSqlServerLocalDbPath();
details.ODBCToolsPath = Utils.Database.GetODBCToolsPath(APILogger.Log);
LocalOnlyOperations.Connection.Server = details.DbServer;
LocalOnlyOperations.Connection.Username = details.DbUser;
LocalOnlyOperations.Connection.Password = details.DbUserPassword;
LocalOnlyOperations.Connection.DbName = details.DbName;
var res = DbAPI.DbAPI.Connections.ConnectToDb(details);
if (ErrorCodes.ERROR_SUCCESS != res)
{
throw new SystemException($"Couldn't connect to database: {details} - {res}");
}
LocalOnlyOperations.Connection.DbName = details.DbName;
var connectionDbVersion = DbOperations.GetConnectionDbVersion();
return connectionDbVersion;
}
public static int SetupForRemoteDb(string dbHost, bool userNTLMAuthentication, string user, string password, string defaultDbName)
{
var connectionDbVersion = 0;
DbOperations.Connection.ResetLocalConnectionString();
var details = new DbAPI.Connections.ConnectionDetails();
details.ClientDbVersion = DbOperations.CURRENT_DB_VERSION;
details.AttachDbsBatPath = Path.Combine(SCRIPTS_FOLDER, ATTACH_DBS_BAT);
details.DbFolderPath = LOCAL_DB_FOLDER;
details.DbName = defaultDbName;
details.UsingCentralizedDb = true;
details.DbServer = dbHost;
details.DbUser = user;
details.DbUserPassword = password;
details.InstanceName = INSTANCE_NAME;
details.UseNTLMAuthentication = userNTLMAuthentication;
details.SqlDbPath = Utils.Database.GetSqlServerLocalDbPath();
details.ODBCToolsPath = Utils.Database.GetODBCToolsPath(APILogger.Log);
DbOperations.Connection.Server = details.DbServer;
DbOperations.Connection.DBName = details.DbName;
DbOperations.Connection.Username = details.DbUser;
DbOperations.Connection.Password = details.DbUserPassword;
DbOperations._usingNTLMAuthentication = details.UseNTLMAuthentication;
DbOperations._usingCentralizedDB = details.UsingCentralizedDb;
var res = DbAPI.DbAPI.Connections.ConnectToDb(details);
if (ErrorCodes.ERROR_SUCCESS != res)
{
throw new SystemException($"Couldn't connect to database: {details} - {res}");
}
connectionDbVersion = DbOperations.GetConnectionDbVersion();
return connectionDbVersion;
}
public static bool SimpleDbTest()
{
try
{
using (var cmd = DbOperations.GetSQLCommand(true))
{
cmd.CommandText = "SELECT TOP 1 [DASId] FROM [DAS]";
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
{
if (ds.Tables[0].Rows.Count > 0) { return true; }
}
cmd.Connection.Dispose();
}
}
catch (Exception)
{
return false;
}
return true;
}
}
}

View File

@@ -0,0 +1,9 @@
USE master
GO
ALTER DATABASE $(DBNAME)Pre20 SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
sp_Detach_db $(DBNAME)Pre20, FALSE, TRUE
GO

View File

@@ -0,0 +1,41 @@
namespace DTS.Storage
{
public abstract class LevelTriggers
{
public const string Table = "tblLevelTriggers";
public enum Fields
{
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
TestSetupName,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
GroupSerialNumber,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
TestObjectChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
HardwareChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
SensorSerialNumber,
[DbTypeAttr("BIT NOT NULL")]
GreaterThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
GreaterThanEU,
[DbTypeAttr("BIT NOT NULL")]
LessThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
LessThanEU,
[DbTypeAttr("FLOAT NULL")]
InsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
InsideLowerEU,
[DbTypeAttr("FLOAT NULL")]
OutsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
OutsideLowerEU,
[DbTypeAttr("BIT NULL")]
TriggerInside,
[DbTypeAttr("BIT NULL")]
TriggerOutside
};
}
}

View File

@@ -0,0 +1,7 @@
USE master
GO
BACKUP DATABASE $(DBNAME) TO DISK='C:\DataPRO_SQL\$(DBNAME)Backup.bak'
GO

View File

@@ -0,0 +1,6 @@
rem sqlcmd -E -S (localdb)\DataPROInstance -Q "ALTER DATABASE [%1] SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
rem sqlcmd -E -S (localdb)\DataPROInstance -Q "sp_Detach_db %1"
%4 -E -S (localdb)\DataPROInstance -Q "CREATE DATABASE [%1] ON ( FILENAME = '%~2'), ( FILENAME = '%~3' ) FOR ATTACH"
%4 -E -S (localdb)\DataPROInstance -Q "sp_configure 'clr enabled', 1"
%4 -E -S (localdb)\DataPROInstance -Q "RECONFIGURE"

View File

@@ -0,0 +1,271 @@
using DTS.Common.Classes.Locking;
using DTS.Common.Utilities.Logging;
using System;
using System.Data;
using System.Data.SqlClient;
namespace DTS.Common.Storage
{
public class LockManager
{
public static bool FreeLock(int itemId, string userName, int? userId, out LockError error, int categoryId)
{
error = null;
try
{
using (var cmd = DbOperations.GetSQLCommand(true))
{
try
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_LockFree.ToString();
#region params
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.Int) { Value = userId });
cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 50) { Value = userName });
cmd.Parameters.Add(new SqlParameter("@ItemId", SqlDbType.Int) { Value = itemId });
cmd.Parameters.Add(new SqlParameter("@CategoryId", SqlDbType.Int) { Value = categoryId });
var errorNumber = new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(errorNumber);
var errorMessage = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(errorMessage);
#endregion params
cmd.ExecuteNonQuery();
var errorCode = int.Parse(errorNumber.Value.ToString());
switch (errorCode)
{
case 0: return true; //all cool, lock updated
case 1: //test setup not found
case 2: //user not found
error = new LockError(errorCode,
(errorMessage.Value as string) ?? $"{errorCode}");
return false;
case 3: //no lock to update
error = new LockError(3, (errorMessage.Value as string) ?? $"{errorCode}");
return false;
default:
error = new LockError(4, (errorMessage.Value as string) ?? $"{errorCode}");
return false;
}
}
finally { cmd.Connection.Dispose(); }
}
}
catch (Exception ex)
{
APILogger.Log(ex);
return false;
}
}
public static bool UpdateLock(int itemId, int categoryId, string userName, int? userId, out LockError error)
{
error = null;
try
{
using (var cmd = DbOperations.GetSQLCommand(true))
{
try
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_LockUpdate.ToString();
#region params
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.Int) { Value = userId });
cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 50) { Value = userName });
cmd.Parameters.Add(new SqlParameter("@ItemId", SqlDbType.Int) { Value = itemId });
cmd.Parameters.Add(new SqlParameter("@CategoryId", SqlDbType.Int) { Value = categoryId });
cmd.Parameters.Add(new SqlParameter("@MachineName", SqlDbType.NVarChar, 50) { Value = Environment.MachineName });
var errorNumber = new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(errorNumber);
var errorMessage = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(errorMessage);
var lockingUser = new SqlParameter("@LockingUser", SqlDbType.NVarChar, 50) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lockingUser);
var lockingMachine = new SqlParameter("@LockingMachine", SqlDbType.NVarChar, 50) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lockingMachine);
var lastTimeUsed = new SqlParameter("@LastUsedTime", SqlDbType.DateTime) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lastTimeUsed);
var lockCreateTime = new SqlParameter("@LockCreateTime", SqlDbType.DateTime) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lockCreateTime);
#endregion params
cmd.ExecuteNonQuery();
var errorCode = int.Parse(errorNumber.Value.ToString());
switch (errorCode)
{
case 0: return true; //all cool, lock updated
case 1: //test setup not found
case 2: //user not found
error = new LockError(errorCode,
(errorMessage.Value as string) ?? $"{errorCode}");
return false;
case 3: //no lock to update
error = new LockError(LockError.LOCKDOESNTEXIST_ERROR, (errorMessage.Value as string) ?? $"{errorCode}");
return false;
case 4: //lock stolen
error = new LockError(LockError.LOCKSTOLEN_ERROR,
$"Lock now belongs to user {lockingUser.Value}:{lockingMachine.Value}", (string)lockingUser.Value, (string)lockingMachine.Value);
return false;
default:
error = new LockError(4, (errorMessage.Value as string) ?? $"{errorCode}");
return false;
}
}
finally { cmd.Connection.Dispose(); }
}
}
catch (SqlException ex)
{
switch (ex.Number)
{
case ERROR_BAD_NETPATH:
error = new LockError(LockError.BAD_NETPATH_ERROR, Strings.Strings.BAD_NETPATH_ERROR_MSG);
break;
case ERROR_SEM_TIMEOUT:
error = new LockError(LockError.SEM_TIMEOUT_ERROR, Strings.Strings.SEM_TIME_ERROR_MSG);
break;
}
APILogger.Log("SqlException in UpdateLock", ex);
return false;
}
catch (Exception ex)
{
APILogger.Log("Exception in UpdateLock", ex);
return false;
}
}
/// <summary>
/// The semaphore timeout period has expired
/// https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-?redirectedfrom=MSDN
/// </summary>
private const int ERROR_SEM_TIMEOUT = 0x00000079;
/// <summary>
/// network path not found, apparently also can occur during lock management?
/// 14782 Improve lost remote db connection modal dialogs
/// </summary>
private const int ERROR_BAD_NETPATH = 0x00000035;
public enum ItemCategories
{
TestSetup,
Group,
Sensor,
SystemSettings
}
public static bool LockItem(string itemKey,
int itemId,
ItemCategories itemCategory,
string userName,
int? userId,
out LockRecord existingLock, out
LockError error)
{
error = null;
existingLock = null;
try
{
using (var cmd = DbOperations.GetSQLCommand(true))
{
try
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_LockGet.ToString();
#region params
int? id = null;
if (itemId > 0) { id = itemId; } //NOTE YOU"LL NEED THE ID TO FREE, AND THE CURRENT SP DOESN'T RETURN IT
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.Int) { Value = userId });
cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 50) { Value = userName });
cmd.Parameters.Add(new SqlParameter("@ItemId", SqlDbType.Int) { Value = id });
cmd.Parameters.Add(new SqlParameter("@ItemKey", SqlDbType.NVarChar, 50) { Value = itemKey });
cmd.Parameters.Add(new SqlParameter("@ItemCategory", SqlDbType.NVarChar, 50) { Value = itemCategory.ToString() });
cmd.Parameters.Add(new SqlParameter("@MachineName", SqlDbType.NVarChar, 50) { Value = Environment.MachineName });
var errorNumber = new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(errorNumber);
var errorMessage = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(errorMessage);
var lockingUser = new SqlParameter("@LockingUser", SqlDbType.NVarChar, 50) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lockingUser);
var lockingMachine = new SqlParameter("@LockingMachineName", SqlDbType.NVarChar, 50) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lockingMachine);
var lastTimeUsed = new SqlParameter("@LastUsedTime", SqlDbType.DateTime) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lastTimeUsed);
var lockCreateTime = new SqlParameter("@LockCreateTime", SqlDbType.DateTime) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lockCreateTime);
var lockItemCategory = new SqlParameter("@LockedItemCategory", SqlDbType.Int) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lockItemCategory);
var lockedItemId = new SqlParameter("@LockedItemId", SqlDbType.Int) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(lockedItemId);
#endregion params
cmd.ExecuteNonQuery();
int resultItemId = itemId;
if (itemId < 0)
{
if (!DBNull.Value.Equals(lockedItemId.Value))
{
resultItemId = Convert.ToInt32(lockedItemId.Value);
}
}
var errorCode = int.Parse(errorNumber.Value.ToString());
switch (errorCode)
{
case 0:
existingLock = new LockRecord(userName, Environment.MachineName, DateTime.Now, DateTime.Now, itemKey, Convert.ToInt32(lockItemCategory.Value), resultItemId);
return true; //all cool, locked away
case 1: //item not found
error = new LockError(LockError.ITEM_NOT_FOUND, (errorMessage.Value as string) ?? $"{errorCode}");
return false;
case 2: //user not found
error = new LockError(errorCode,
(errorMessage.Value as string) ?? $"{errorCode}");
return false;
case 3: //already locked
existingLock = new LockRecord((string)lockingUser.Value,
(string)lockingMachine.Value, Convert.ToDateTime(lockCreateTime.Value),
Convert.ToDateTime(lastTimeUsed.Value), itemKey, Convert.ToInt32(lockItemCategory.Value), resultItemId);
error = new LockError(errorCode, (errorMessage.Value as string) ?? $"{errorCode}");
return false;
default:
error = new LockError(LockError.UNKNOWN_ERROR, (errorMessage.Value as string) ?? $"{errorCode}");
return false;
}
}
finally { cmd.Connection.Dispose(); }
}
}
catch (Exception ex)
{
APILogger.Log(ex);
error = new LockError(LockError.UNKNOWN_ERROR, ex.Message);
return false;
}
}
}
}

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="DTS.Common.Storage.DbOperations" Collapsed="true">
<Position X="0.5" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>s62V4un9p8SGES8wZbsJW+9Tpm4LUYDOALzhrpl2x2w=</HashCode>
<FileName>AbstractClasses.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.DatabaseServices" Collapsed="true">
<Position X="4" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>CggQAgCAAAAAAAACACAAEIAAFCECggAABAQQgAAAAA4=</HashCode>
<FileName>DatabaseServices.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.CustomChannelFieldSizeAttribute" Collapsed="true">
<Position X="0.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>DbOperations.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.CustomChannelFieldSizeExtensions" Collapsed="true">
<Position X="2.25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>DbOperations.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.EnumExtensions" Collapsed="true">
<Position X="5.75" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAA=</HashCode>
<FileName>DbOperations.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.DbOperationsEnum" Collapsed="true">
<Position X="2.25" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>DbOperationsEnum.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.DbTimeStampBase" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="4" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>EgAAAAAQAABAEAAAIAAAAAAAgQEAACAQAAAAAAAAAIA=</HashCode>
<FileName>IDbTimeStampAware.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="DTS.Common.Storage.DbItemOutOfDateException" Collapsed="true">
<Position X="5.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>IDbTimeStampAware.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.LocalOnlyOperations" Collapsed="true">
<Position X="0.5" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AqEEAAAEIEAAAAUgIYAAAAAAAAAAAAACAgAAAgBABAA=</HashCode>
<FileName>LocalOnlyOperations.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.LockManager" Collapsed="true">
<Position X="2.25" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAgQAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>LockManager.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.TypeConvertor" Collapsed="true">
<Position X="4" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAgAAAAAAAAAAAEIAAAAAAAAAAAAAAg=</HashCode>
<FileName>TypeConverter.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.Common.Storage.UserMigrationHelper" Collapsed="true">
<Position X="5.75" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AEAAEEQAQAAAAAAAEAAAAAACAAIAAAACEQMAAAAAAAE=</HashCode>
<FileName>UserMigrationHelper.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="DTS.Common.Storage.IDbTimeStampAware" Collapsed="true">
<Position X="0.5" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>EgAAAAAAAABAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>IDbTimeStampAware.cs</FileName>
</TypeIdentifier>
</Interface>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -0,0 +1,4 @@
CD "%1"
DataPRO.exe /u:Admin /p:DTSAdmin /csvimport:"%2"

View File

@@ -0,0 +1,14 @@
USE master
GO
BACKUP DATABASE $(DBNAME) TO DISK='C:\DataPRO_SQL\$(DBNAME)Backup.bak'
GO
ALTER DATABASE $(DBNAME) SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
sp_Detach_db '$(DBNAME)', FALSE, TRUE
GO
ALTER DATABASE ISO SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
sp_Detach_db ISO, FALSE, TRUE
GO

View File

@@ -0,0 +1,425 @@
namespace DTS.Common.Storage
{
public partial class DbOperations
{
public abstract class DigitalInputSettings
{
public const string Table = "tblDigitalInputSetting";
public enum Fields
{
SettingName,
SettingMode,
ScaleMultiplier,
LastModified,
LastModifiedBy,
SensorId,
UserValue1,
UserValue2,
UserValue3,
UserTags,
eId,
MeasurementUnit,
FilterClass,
ISOCode,
ISOChannelName,
UserCode,
UserChannelName,
Broken, //new in 2.0
DoNotUse //new in 2.0
}
}
public abstract class VersionTable
{
public enum Fields
{
Version,
Step,
Date,
Remarks,
UserField
}
public const string TableName = "tblDataPRODbVersion";
}
public abstract class DAS
{
public const string Table = "tblDAS";
public enum Fields
{
SerialNumber,
Type,
MaxModules,
MaxMemory,
MaxSampleRate,
MinSampleRate,
FirmwareVersion,
CalDate,
ProtocolVersion,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
LastUsed,
LastUsedBy,
Connection,
Channels,
Position,
ChannelTypes,
Reprogramable,
Reconfigurable,
IsModule,
PositionOnDistributor,
PositionOnChain,
Port,
ParentDAS,
DASId,
FirstUseDate,
StandIn,
MaxAAFRate,
TestId,
GroupId
}
public const string TableDASChannels = "tblDASChannels";
public enum DASChannelFields
{
HardwareId,
ChannelIdx,
SupportedBridges,
SupportedExcitations,
DASDisplayOrder,
LocalOnly,
SupportedDigitalInputModes,
SupportedSquibFireModes,
SupportedDigitalOutputModes,
ModuleSerialNumber,
ModuleArrayIndex
}
public const string SLICE1_PROTOTYPE = "SLICE1 Prototype";
public const string SLICEPRO_PROTOTYPE = "SLICEPRO Prototype";
public const string PROTOTYPE_POSITION = "Prototype";
public const string SLICE1_5PROTOTYPE = "SLICE+ Prototype";
public const string G5_VDSPROTOTYPE = "G5 VDS Prototype";
public const string G5_IPORTPROTOTYPE = "G5 iPort Prototype";
public const string TDASPRO_8MRack = "TDASPro Rack 8M Prototype";
public const string TDASPRO_4MRack = "TDASPRO Rack 4M Prototype";
public const string ECM_PROTOTYPE = "SLICE ECM Prototype";
public const string SPM_PROTOTYPE = "SLICE Mini Distributor Prototype";
public const string SLE_PROTOTYPE = "SLICE PRO Lab Ethernet Prototype";
public const string SDB_PROTOTYPE = "SLICE Distributor Prototype";
public const string Slice_NanoPROTOTYPE = "SLICE Nano Prototype";
public const string Slice_MicroPROTOTYPE = "SLICE Micro Prototype";
public const string SLICEPRODIM_PROTOTYPE = "SLICE Pro DIM";
public const string SLICEPROSLD_PROTOTYPE = "SLICE PRO Lab DIM";
public const string SLICEPROTOM_PROTOTYPE = "SLICE Pro TOM";
public const string SLICEPROSLT_PROTOTYPE = "SLICE PRO Lab TOM";
public const string SLICEPROSIM_PROTOTYPE = "SLICE Pro SIM";
public const string SLICEPROSLS_PROTOTYPE = "SLICE PRO Lab SIM";
public const string SLICE1_5_MicroPROTOTYPE = "SLICE MICRO BASE+ Prototype";
public const string G5_INDUMMYPROTOTYPE = "G5 InDummy Prototype";
public const string SG5_PROTOTYPE = "SLICE G5 Prototype";
public const string TDASPRO_LabRack = "TDAS PRO Lab Rack";
public const string SLICE6_PROTOTYPE = "SLICE6 Prototype";
public const string SLICE6_AIR_PROTOTYPE = "SLICE6 AIR Prototype";
public const string SLICE6_AIR_ER_PROTOTYPE = "SLICE6 AIR ER Prototype";
public const string SLICE6_AIR_BR_PROTOTYPE = "SLICE6 Falcon Prototype";
public const string SLICE6DB_PROTOTYPE = "SLICE6Db Prototype";
public const string SLICE6DB3_PROTOTYPE = "SLICE6Db3 Prototype";
public const string SLICE6DB_AIR_PROTOTYPE = "SLICE6Db AIR Prototype";
public const string SLICE6DB_INDUMMY_PROTOTYPE = "SLICE6Db InDummy Prototype";
public const string POWERPRO_PROTOTYPE = "PowerPRO Prototype";
public const string TSR_AIR_PROTOTYPE = "TSR Air Prototype";
public const string TSR_AIR_REVB_PROTOTYPE = "TSR Air RevB Prototype";
public const string DIR_PROTOTYPE = "DIR Prototype";
public const string DKR_PROTOTYPE = "DKR Prototype";
public const string EMB_LIN_ACC_LO_MODULE_PROTOTYPE = "EMB LIN ACC LO Module Prototype";
public const string EMB_LIN_ACC_HI_MODULE_PROTOTYPE = "EMB LIN ACC HI Module Prototype";
public const string EMB_ARS_MODULE_PROTOTYPE = "EMB ARS Module Prototype";
public const string EMB_ATM_MODULE_PROTOTYPE = "EMB ATM Module Prototype";
public const string SLICEPRO_DB_PROTOTYPE = "SLICE Pro Distributor Prototype";
public const string SLICE_TC_PROTOTYPE = "SLICE TC Prototype";
public const string SLICE_PRO_CAN_FD_PROTOTYPE = "SLICE PRO CAN FD Prototype";
}
public abstract class TestObjectChannelSettings
{
public const string TableName = "tblTestObjectChannelSettings";
public enum Fields
{
TestObjectSerial,
ChannelId,
Setting,
SensorSerial,
SerialNumber
}
}
public abstract class DigitalOutputSettings
{
public const string Table = "tblTOMDigitalChannels";
public enum Fields
{
ChannelDescription,
DelayMS,
DurationMS,
OutputMode,
LimitDuration,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
DurationMSFloat,
UserTags,
Broken, //new in 2.0
DoNotUse //new in 2.0
}
}
public abstract class Squib
{
public const string Table = "tblTOMSquibChannels";
public enum Fields
{
SerialNumber,
SquibDescription,
BypassCurrentFilter,
BypassVoltageFilter,
DelayMS,
DurationMS,
FireMode,
ISOCode,
ISOChannelName,
UserCode,
UserChannelName,
MeasurementType,
SquibOutputCurrent,
SquibToleranceLow,
SquibToleranceHigh,
LimitDuration,
ArticleId,
LocalOnly,
Version,
LastModified,
LastModifiedBy,
UserValue1,
UserValue2,
UserValue3,
UserTags,
Broken, //new in 2.0
DoNotUse, //new in 2.0
DefineDelayInTest // new in 2.3
}
}
public abstract class UartIOSettings
{
public const string Table = "tblUartIOSettings";
public enum Fields
{
SerialNumber,
Description,
BaudRate,
DataBits,
StopBits,
Parity,
FlowControl,
DataFormat,
LastModified,
LastModifiedBy,
UserTags,
Broken,
DoNotUse
}
}
public abstract class StreamOutputSettings
{
public const string Table = "tblStreamOutputSettings";
public enum Fields
{
SerialNumber,
Description,
StreamProfile,
UDPAddress,
TimeChannelId,
DataChannelId,
TmNSConfig,
IRIGTimeDataPacketIntervalMs,
LastModified,
LastModifiedBy,
UserTags,
Broken,
DoNotUse
}
}
public abstract class CalculatedChannels
{
public const string Table = "tblCalculatedChannels";
public enum Fields
{
[DbTypeAttr("INTEGER PRIMARY KEY NOT NULL")]
Id,
[DbTypeAttr("INTEGER")]
Operation,
[DbTypeAttr("NVARCHAR(255)")]
CalculatedChannelValueCode,
[DbTypeAttr("BLOB")]
InputChannelIds,
[DbTypeAttr("NVARCHAR(255)")]
CFCForInputChannels,
[DbTypeAttr("NVARCHAR(255)")]
CFCForOutput,
[DbTypeAttr("NVARCHAR(255)")]
TestSetupName,
[DbTypeAttr("NVARCHAR(255)")]
CCName,
[DbTypeAttr("Bit")]
ViewInRealtime,
[DbTypeAttr("Int")]
ClipLength
}
}
public abstract class LevelTriggers
{
public const string Table = "tblLevelTriggers";
public enum Fields
{
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
TestSetupName,
[DbTypeAttr("BIGINT NOT NULL")]
ChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
GroupName,
//[DbTypeAttr("NVARCHAR(255) NOT NULL")]
//TestObjectChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
HardwareChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
SensorSerialNumber,
[DbTypeAttr("BIT NOT NULL")]
GreaterThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
GreaterThanEU,
[DbTypeAttr("BIT NOT NULL")]
LessThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
LessThanEU,
[DbTypeAttr("FLOAT NULL")]
InsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
InsideLowerEU,
[DbTypeAttr("FLOAT NULL")]
OutsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
OutsideLowerEU,
[DbTypeAttr("BIT NULL")]
InsideEnabled, //TriggerInside,
[DbTypeAttr("BIT NULL")]
OutsideEnabled, //TriggerOutside,
//[DbTypeAttr("NVARCHAR(255) NOT NULL")]
//TestObjectName
};
}
public abstract class Tags
{
public const string Table = "tblTags";
public enum TagFields
{
TagId,
TagText,
Obsolete
}
public const string TAGASSIGNMENTS_TABLE = "TagAssignments";
public enum TagAssignmentFields
{
ObjectID,
ObjectType,
TagID
}
}
public abstract class DbVersions
{
public enum DbVersionFields
{
Version,
Step,
Date,
Remarks,
UserField
}
}
public abstract class Settings
{
public const string Table = "tblSettings";
public enum UserFields
{
PropertyId,
PropertyType,
PropertyValue,
UserId
}
}
public abstract class MMEPossibleChannels
{
public const string Table = "tblMMEPossibleChannels";
}
public abstract class LabratoryDetails
{
public const string Table = "tblLabratoryDetails";
public enum LabratoryDetailsFields
{
Name,
LabratoryName,
LabratoryContactName,
LabratoryContactPhone,
LabratoryContactFax,
LabratoryContactEmail,
LabratoryTestRefNumber,
LabratoryProjectRefNumber,
LastModified,
LastModifiedBy,
LocalOnly,
Version
}
}
/// <summary>
/// tables and fields for user objects
/// </summary>
public abstract class Users
{
public const string USERS_TABLE = "DataPROUsers";
public enum UserFields
{
ID,
UserName,
DisplayName,
Password,
Role,
LastModified,
LastModifiedBy,
LocalOnly
}
public const string UIITEMS_TABLE = "UIITEMS";
public enum UIItemFields
{
ID,
Name
}
public const string USERUISETTINGS_TABLE = "UserUIItemSettings";
public enum UserUIItemSettingFields
{
UserId,
UIItemID,
Permission,
Visible
}
}
}
}

View File

@@ -0,0 +1,32 @@
namespace DTS.Storage
{
public abstract class Squib
{
public const string Table = "tblTOMSquibChannels";
public enum Fields
{
SquibDescription,
BypassCurrentFilter,
BypassVoltageFilter,
DelayMS,
DurationMS,
FireMode,
ISOCode,
MeasurementType,
SquibOutputCurrent,
SquibToleranceLow,
SquibToleranceHigh,
LimitDuration,
ArticleId,
LocalOnly,
Version,
LastModified,
LastModifiedBy,
UserValue1,
UserValue2,
UserValue3,
UserTags
}
}
}

View File

@@ -0,0 +1,15 @@
namespace DTS.Storage
{
public abstract class TestObjectChannelSettings
{
public const string TableName = "tblTestObjectChannelSettings";
public enum Fields
{
TestObjectSerial,
ChannelId,
Setting,
SensorSerial
}
}
}

View File

@@ -0,0 +1,15 @@
namespace DTS.Storage
{
public abstract class VersionTable
{
public enum Fields
{
Version,
Step,
Date,
Remarks,
UserField
}
public const string TableName = "tblDataPRODbVersion";
}
}

View File

@@ -0,0 +1,333 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Xml.Serialization;
namespace DTS.Common.Storage
{
/// <summary>
/// this class handles serializing and retrieving and holding sensor test history
/// 3003 Attach Test History to Sensors
/// </summary>
[Serializable]
public class SensorTestHistory
{
/// <summary>
/// the id from the test history table for the test record
/// </summary>
public long TestHistoryId { get; set; }
/// <summary>
/// the id of the test setup from the test history table
/// </summary>
public int TestSetupId { get; set; } = -1;
/// <summary>
/// the name of the test setup, as stored in the db
/// </summary>
public string TestSetupName { get; set; } = null;
/// <summary>
/// the description of the test setup, as stored in the db
/// </summary>
public string TestSetupDescription { get; set; } = null;
/// <summary>
/// the user provided test id that was stored in the db
/// </summary>
public string TestId { get; set; }
/// <summary>
/// whether the test was marked as destructive or not
/// </summary>
public bool Destructive { get; set; }
/// <summary>
/// the time the unit was armed (or autoarmed)
/// </summary>
public DateTime ArmTime { get; set; }
/// <summary>
/// gzip'd bytes representing the test setup xml
/// </summary>
public byte[] TestSetup { get; set; }
/// <summary>
/// the primary key/id of the record in the sensor history table
/// </summary>
public long SensorTestHistoryId { get; set; }
/// <summary>
/// the id of the sensor in the sensors table
/// </summary>
public int SensorId { get; set; } = -1;
/// <summary>
/// the serial number of the sensor
/// </summary>
public string SerialNumber { get; set; }
/// <summary>
/// the capacity of the sensor when the test was armed
/// </summary>
public double Capacity { get; set; }
/// <summary>
/// the range the sensor was armed with
/// </summary>
public double Range { get; set; }
/// <summary>
/// the Date of the Calibration of the unit
/// </summary>
public DateTime CalibrationDate { get; set; } = DateTime.MinValue;
/// <summary>
/// the hardware channel the sensor was on
/// </summary>
public string HardwareChannelName { get; set; }
/// <summary>
/// the iso channel name
/// </summary>
public string ISOChannelName { get; set; } = null;
/// <summary>
/// the iso code of the sensor
/// </summary>
public string ISOCode { get; set; } = null;
/// <summary>
/// the user channel name the sensor was on
/// </summary>
public string UserChannelName { get; set; } = null;
/// <summary>
/// the user code of the channel the sensor was on
/// </summary>
public string UserCode { get; set; } = null;
/// <summary>
/// the sensitivity of the channel (taken directly as a string, like in the dts file)
/// </summary>
public string Sensitivity { get; set; } = null;
/// <summary>
/// the filter class of the channel (taken as a string, like in the dts file)
/// </summary>
public string FilterClass { get; set; } = null;
/// <summary>
/// whether the sensor was marked as proportional or not
/// </summary>
public bool IsProportional { get; set; }
/// <summary>
/// any linearization formula stored with the sensor
/// </summary>
public string LinearizationFormula { get; set; } = null;
/// <summary>
/// EID on the sensor during the event
/// </summary>
public string EID { get; set; } = null;
/// <summary>
/// measured excitation
/// </summary>
public double MeasuredExcitation { get; set; } = double.NaN;
/// <summary>
/// measurement unit on the channel
/// </summary>
public string MeasurementUnit { get; set; }
/// <summary>
/// samples per second for the channel the sensor was on during the event
/// </summary>
public int SamplesPerSecond { get; set; }
/// <summary>
/// the Anti-alias filter for the channel the sensor was on during the event
/// </summary>
public int AAF { get; set; }
public SensorTestHistory(IDataReader reader)
{
TestHistoryId = GetLong(reader, "TestHistoryId");
TestSetupId = GetInt(reader, "TestSetupId");
TestSetupName = GetString(reader, "TestSetupName");
TestSetupDescription = GetString(reader, "TestSetupDescription");
TestId = GetString(reader, "TestId");
Destructive = GetBool(reader, "Destructive");
ArmTime = GetDateTime(reader, "ArmTime");
TestSetup = GetBytes(reader, "TestSetup");
SensorTestHistoryId = GetLong(reader, "SensorTestHistoryId");
SensorId = GetInt(reader, "SensorId");
SerialNumber = GetString(reader, "SerialNumber");
Capacity = GetDouble(reader, "Capacity");
Range = GetDouble(reader, "Range");
CalibrationDate = GetDateTime(reader, "CalibrationDate");
HardwareChannelName = GetString(reader, "HardwareChannelName");
ISOChannelName = GetString(reader, "ISOChannelName");
ISOCode = GetString(reader, "ISOCode");
UserChannelName = GetString(reader, "UserChannelName");
UserCode = GetString(reader, "UserCode");
Sensitivity = GetString(reader, "Sensitivity");
FilterClass = GetString(reader, "FilterClass");
IsProportional = GetBool(reader, "IsProportional");
LinearizationFormula = GetString(reader, "LinearizationFormula");
EID = GetString(reader, "EID");
MeasuredExcitation = GetDouble(reader, "MeasuredExcitation");
MeasurementUnit = GetString(reader, "MeasurementUnit");
SamplesPerSecond = GetInt(reader, "SamplesPerSecond");
AAF = GetInt(reader, "AAF");
}
public SensorTestHistory()
{
}
/// <summary>
/// helper function, returns a datetime if db value is valid,
/// DateTime.MinValue otherwise
/// </summary>
/// <param name="reader"></param>
/// <param name="field"></param>
/// <returns></returns>
private DateTime GetDateTime(IDataReader reader, string field)
{
var o = reader[field];
if (DBNull.Value.Equals(o)) { return DateTime.MinValue; }
return Convert.ToDateTime(o);
}
/// <summary>
/// helper function, returns a bool if db value is valid,
/// false otherwise
/// </summary>
/// <param name="reader"></param>
/// <param name="field"></param>
/// <returns></returns>
private bool GetBool(IDataReader reader, string field)
{
var o = reader[field];
if (DBNull.Value.Equals(o)) { return false; }
return Convert.ToBoolean(o);
}
/// <summary>
/// helper function, returns a long if db value is valid
/// long.MinValue otherwise
/// </summary>
/// <param name="reader"></param>
/// <param name="field"></param>
/// <returns></returns>
private long GetLong(IDataReader reader, string field)
{
var o = reader[field];
if (DBNull.Value.Equals(o)) { return long.MinValue; }
else
{
return Convert.ToInt64(o);
}
}
/// <summary>
/// helper function, returns int if db value is valid,
/// int.MinValue otherwise
/// </summary>
/// <param name="reader"></param>
/// <param name="field"></param>
/// <returns></returns>
public int GetInt(IDataReader reader, string field)
{
var o = reader[field];
if (DBNull.Value.Equals(o)) { return int.MinValue; }
return Convert.ToInt32(o);
}
/// <summary>
/// returns a double if db value is valid,
/// double.NaN otherwise
/// </summary>
/// <param name="reader"></param>
/// <param name="field"></param>
/// <returns></returns>
public double GetDouble(IDataReader reader, string field)
{
var o = reader[field];
if (DBNull.Value.Equals(o)) { return double.NaN; }
return Convert.ToDouble(o);
}
/// <summary>
/// returns a string if db value is valid,
/// string.Empty otherwise
/// </summary>
/// <param name="reader"></param>
/// <param name="field"></param>
/// <returns></returns>
public string GetString(IDataReader reader, string field)
{
var o = reader[field];
if (DBNull.Value.Equals(o)) { return string.Empty; }
return Convert.ToString(o);
}
/// <summary>
/// returns byte [] if db value is valid, otherwise
/// byte[0]
/// </summary>
/// <param name="reader"></param>
/// <param name="field"></param>
/// <returns></returns>
public byte[] GetBytes(IDataReader reader, string field)
{
var o = reader[field];
if (DBNull.Value.Equals(o))
{
return new byte[0];
}
return (byte[])o;
}
/// <summary>
/// returns all records matching sensor serial number
/// </summary>
/// <param name="sensorSerial"></param>
/// <returns></returns>
public static SensorTestHistory[] GetSensorTestHistory(string sensorSerial)
{
var list = new List<SensorTestHistory>();
using (var cmd = DbOperations.GetSQLCommand(true))
{
try
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_SensorTestHistoryGet";
cmd.Parameters.Add(new SqlParameter("@SerialNumber", SqlDbType.NVarChar)
{ Value = sensorSerial });
var reader = cmd.ExecuteReader();
while (reader.Read())
{
var history = new SensorTestHistory(reader);
list.Add(history);
}
}
finally
{
cmd.Connection.Dispose();
}
}
return list.ToArray();
}
/// <summary>
/// returns an xml document in string for representing all given histories
/// </summary>
/// <param name="histories"></param>
/// <returns></returns>
public static string SerializeToString(SensorTestHistory[] histories)
{
var serializer = new XmlSerializer(typeof(SensorTestHistoryCollection));
using (var stream = new MemoryStream())
{
serializer.Serialize(stream, new SensorTestHistoryCollection(histories));
return Encoding.UTF8.GetString(stream.ToArray());
}
}
/// <summary>
/// this is just a helper class for xml serialization
/// </summary>
[Serializable]
public class SensorTestHistoryCollection
{
public SensorTestHistory[] SensorHistory { get; set; }
public SensorTestHistoryCollection(SensorTestHistory[] history)
{
SensorHistory = history;
}
public SensorTestHistoryCollection()
{
}
}
}
}

View File

@@ -0,0 +1,2 @@
Use DataPRO;
UPDATE [dbo].[Users] SET [Password]='Onl79FZmtkwYRi5DfMV46DDfS0HMOpURgIxeUvhswuY=' WHERE ID=1;

View File

@@ -0,0 +1,323 @@
namespace DTS.Common.Storage
{
public partial class DbOperations
{
public abstract class TestSetups
{
public const string HardwareTable = "tblTestSetupHardware";
public enum HardwareFields
{
TestSetupName,
HardwareId,
AddOrRemove //0=remove,1=add
}
public const string DASSettingsTable = "tblTestSetupDASSettings";
public const string ChannelSettingsTable = "tblTestChannelSettings";
public enum ChannelSettingFields
{
TestName,
TestObjectName,
ChannelId,
Setting,
SensorSerial,
Disabled
}
public enum ChannelFields
{
ISOChannelName,
ISOCode,
UserChannelName,
UserCode,
Disabled,
Settings,
SensorId, //version 3
DASId, //version 3
DASChannelIdx, //version 3
TestSetupOrder, //version 3
GroupOrder, //version 3
Id //version 3
}
public enum SettingsFields
{
//Version 3 and earlier
Range,
CFC,
Polarity,
//Version 2 and earlier
LimitDuration,
Duration,
Delay,
OutputMode,
SQMode,
DIMode,
DefaultValue,
ActiveValue,
//version 4 (DataPRO 2.1)
SquibLimitDuration,
SquibDuration,
SquibDelay,
DigitalOutLimitDuration,
DigitalOutDuration,
DigitalOutDelay,
SquibCurrent,
UserValue1,
UserValue2,
UserValue3,
//Version 5? (DataPRO 2.4) [noticed these issues during testing of 3.0]
//15270 Sensor Import does not import most channel settings
ZeroMethod,
ZeroMethodStart,
ZeroMethodEnd,
//Version 6? (DataPRO 3.0)
//15270 Sensor Import does not import most channel settings
InitialOffset,
FilterClass,
//Version ?? (DataPRO 4.0)
//18363 Uart Channels
UartBaudRate,
UartDataBits,
UartStopBits,
UartParity,
UartFlowControl,
UartDataFormat,
//18364 Stream Out Channels
StreamOutUDPProfile,
StreamOutUDPAddress,
StreamOutUDPTimeChannelId,
StreamOutUDPDataChannelId,
StreamOutUDPTmNSConfig,
StreamOutIRIGTimeDataPacketIntervalMs,
//http://manuscript.dts.local/f/cases/29760/Implement-ACCoupleEnable-for-TSR-AIR
ACCouplingEnabled,
StreamOutTMATSIntervalMs,
//33415 Voltage insertion channel should be half bridge
BridgeType
}
public const string TestSetupsTable = "tblTestSetups";
public enum Fields
{
SetupName,
SetupDescription,
AutomaticTestProgression,
AutomaticProgressionDelayMS,
InvertTrigger,
InvertStart,
IgnoreShortedStart,
IgnoreShortedTrigger,
ViewDiagnostics,
VerifyChannels,
AutoVerifyChannels,
VerifyChannelsDelayMS,
RecordingMode,
SamplesPerSecond,
PreTriggerSeconds,
PostTriggerSeconds,
NumberOfEvents,
WakeUpMotionTimeout,
ScheduledStartDateTime,
IntervalBetweenEventStartsMinutes,
StartWithEvent,
WakeUpWithMotion,
StrictDiagnostics,
RequireConfirmationOnErrors,
ROIDownload,
ViewROIDownload,
DownloadAll,
ViewRealtime,
RealtimePlotCount,
RegionsOfInterest,
ROIStart,
ROIEnd,
ViewDownloadAll,
Export,
ExportFormat,
LabDetails,
UseLabDetails,
CustomerDetails,
UseCustomerDetails,
AllowMissingSensors,
AllowSensorIdToBlankChannel,
LocalOnly,
LastModified,
LastModifiedBy,
TurnOffExcitation,
TriggerCheckRealtime,
TriggerCheckStep,
PostTestDiagnostics,
ExportFolder,
DownloadFolder,
CommonStatusLine,
SameAsDownloadFolder,
UploadData,
UploadDataFolder,
UploadExportsOnly,
Settings,
WarnOnBatteryFail,
Dirty,
Complete,
ErrorMessage,
TestEngineerDetails,
UseTestEngineerDetails,
UserTags,
DoAutoArm,
DoEnableRepeat,
DoStreaming,
CheckoutMode,
QuitTestWithoutWarning,
SuppressMissingSensorsWarning,
ISFFile,
NotAllChannelsRealTime,
NotAllChannelsViewer,
CalibrationBehavior,
ClockSyncProfileMaster,
ClockSyncProfileSlave,
ExtraProperties,
MeasureSquibResistancesStep,
TestSetupUniqueId,
AlignUDPToPPS
}
public const string TestSetupObjectsTable = "tblTestSetupObjects";
public enum TestSetupObjectFields
{
TestObjectSerialNumber,
TestObjectName, //TestObjectSerialNumber was changed to TestObjectName in a later version
TestSetupName,
TargetSampleRate,
ExcitationWarmupTimeMS,
LocalOnly,
TestObjectType,
TestObjectPosition,
DisplayOrder
}
public enum TestSetupDASHardwareFields
{
SerialNumber,
SamplesPerSecond,
AntiAliasFilterRate,
IsClockMaster,
PTPDomainID
}
public enum TestSetupGroupFields
{
SerialNumber,
Name,
DisplayName,
Description,
TestSetupName,
DisplayOrder,
Position,
TestObjectType,
Id,
StaticGroupId
}
public const string TestObjectMetaDataTable = "tblTestSetupObjectMetaData";
public enum TestObjectMetaDataFields
{
TestObject,
ISOTestObject,
SetupName,
TestSetupName,
PropName,
PropValue,
Optional,
Version,
}
public const string TestObjectTemplatesTable = "tblTestObjectTemplates";
public enum TestObjectTemplatesFields
{
TemplateName,
Icon,
Description,
LocalOnly,
Version,
LastModifiedBy,
CRC32,
TestObject,
LastModified,
ParentTemplate,
SysBuilt
}
public const string TestObjectsTable = "tblTestObjects";
public enum TestObjectsFields
{
SerialNumber,
LastModifiedBy,
LastModified,
Template,
LocalOnly,
ParentObject,
SysBuilt,
Embedded,
OriginalTemplate,
OriginalSerialNumber
}
public enum GroupsGroupFields
{
Name,
LastModifiedBy,
LastModified,
Id,
Tags
}
public enum GroupsGroupChannelFields
{
IsoCode,
IsoChannelName,
UserCode,
UserChannelName,
DASId,
DASChannelIndex,
GroupChannelOrder,
Sensor,
SensorId,
Disabled,
LastModified,
LastModifiedBy
}
public enum GroupsGroupHardwareListFields
{
Hardware
}
public const string TestGraphsTable = "tblTestGraphs";
public enum GraphFields
{
GraphName,
GraphDescription,
TemplateName,
Channels,
UseDomainMin,
DomainMin,
UseDomainMax,
DomainMax,
UseRangeMin,
RangeMin,
UseRangeMax,
RangeMax,
Thresholds,
LocalOnly,
TestSetupName
}
}
}
}

View File

@@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Xml.Serialization;
namespace DTS.Common.Storage.TestSetups
{
/// <summary>
/// this is a class representing test history
/// 3003 Attach Test History to Sensors
/// </summary>
[Serializable]
public class TestHistory
{
/// <summary>
/// the primary key/id for the record in the test history table
/// </summary>
public long TestHistoryId { get; set; }
/// <summary>
/// the id for the test setup in the db
/// </summary>
public int TestSetupId { get; set; }
/// <summary>
/// the name of the test setup
/// </summary>
public string TestSetupName { get; set; }
/// <summary>
/// the description for the test setup
/// </summary>
public string TestSetupDescription { get; set; }
/// <summary>
/// the user provided test id for the test run
/// </summary>
public string TestId { get; set; }
/// <summary>
/// whether the test was marked as destructive or not
/// </summary>
public bool Destructive { get; set; }
/// <summary>
/// the time the unit was armed or auto-armed
/// </summary>
public DateTime ArmTime { get; set; }
/// <summary>
/// bytes array representing the test setup xml in gzip'd compressed form
/// </summary>
public byte[] TestSetup { get; set; }
public TestHistory()
{
}
public TestHistory(IDataReader reader)
{
var o = reader["TestHistoryId"];
if (!DBNull.Value.Equals(o))
{
TestHistoryId = Convert.ToInt64(o);
}
o = reader["TestSetupId"];
if (!DBNull.Value.Equals(o))
{
TestSetupId = Convert.ToInt32(o);
}
o = reader["TestSetupName"];
if (!DBNull.Value.Equals(o))
{
TestSetupName = Convert.ToString(o);
}
o = reader["TestSetupDescription"];
if (!DBNull.Value.Equals(o))
{
TestSetupDescription = Convert.ToString(o);
}
o = reader["TestId"];
if (!DBNull.Value.Equals(o))
{
TestId = Convert.ToString(o);
}
o = reader["Destructive"];
if (!DBNull.Value.Equals(o))
{
Destructive = Convert.ToBoolean(o);
}
o = reader["ArmTime"];
if (!DBNull.Value.Equals(o))
{
ArmTime = Convert.ToDateTime(o);
}
o = reader["TestSetup"];
if (!DBNull.Value.Equals(o))
{
TestSetup = (byte[])o;
}
}
/// <summary>
/// retrieves all test histories matching the test name
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static TestHistory[] GetTestHistory(string name)
{
var list = new List<TestHistory>();
using (var cmd = DbOperations.GetSQLCommand(true))
{
try
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_TestHistoryGet";
cmd.Parameters.Add(new SqlParameter("@TestSetupName", SqlDbType.NVarChar)
{ Value = name });
var reader = cmd.ExecuteReader();
while (reader.Read())
{
var history = new TestHistory(reader);
list.Add(history);
}
}
finally
{
cmd.Connection.Dispose();
}
}
return list.ToArray();
}
/// <summary>
/// returns an xml document in string form representing all the input histories
/// </summary>
/// <param name="histories"></param>
/// <returns></returns>
public static string SerializeToString(TestHistory[] histories)
{
var serializer = new XmlSerializer(typeof(TestHistoryCollection));
using (var memoryStream = new MemoryStream())
{
serializer.Serialize(memoryStream, new TestHistoryCollection(histories));
return Encoding.UTF8.GetString(memoryStream.ToArray());
}
}
/// <summary>
/// this is just a helper class for serialization
/// </summary>
[Serializable]
public class TestHistoryCollection
{
public TestHistory[] Histories { get; set; }
public TestHistoryCollection(TestHistory[] histories)
{
Histories = histories;
}
public TestHistoryCollection() { }
}
}
}

View File

@@ -0,0 +1,21 @@
namespace DTS.Storage
{
public class DigitalInputSettings
{
public const string Table = "tblDigitalInputSetting";
public enum Fields
{
SettingName,
SettingMode,
ScaleMultiplier,
LastModified,
LastModifiedBy,
SensorId,
UserValue1,
UserValue2,
UserValue3,
UserTags
}
}
}

View File

@@ -0,0 +1,424 @@
namespace DTS.Common.Storage
{
public partial class DbOperations
{
public abstract class DigitalInputSettings
{
public const string Table = "tblDigitalInputSetting";
public enum Fields
{
SettingName,
SettingMode,
ScaleMultiplier,
LastModified,
LastModifiedBy,
SensorId,
UserValue1,
UserValue2,
UserValue3,
UserTags,
eId,
MeasurementUnit,
FilterClass,
ISOCode,
ISOChannelName,
UserCode,
UserChannelName,
Broken, //new in 2.0
DoNotUse //new in 2.0
}
}
public abstract class VersionTable
{
public enum Fields
{
Version,
Step,
Date,
Remarks,
UserField
}
public const string TableName = "tblDataPRODbVersion";
}
public abstract class DAS
{
public const string Table = "tblDAS";
public enum Fields
{
SerialNumber,
Type,
MaxModules,
MaxMemory,
MaxSampleRate,
MinSampleRate,
FirmwareVersion,
CalDate,
ProtocolVersion,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
LastUsed,
LastUsedBy,
Connection,
Channels,
Position,
ChannelTypes,
Reprogramable,
Reconfigurable,
IsModule,
PositionOnDistributor,
PositionOnChain,
Port,
ParentDAS,
DASId,
FirstUseDate,
StandIn,
MaxAAFRate,
TestId,
GroupId
}
public const string TableDASChannels = "tblDASChannels";
public enum DASChannelFields
{
HardwareId,
ChannelIdx,
SupportedBridges,
SupportedExcitations,
DASDisplayOrder,
LocalOnly,
SupportedDigitalInputModes,
SupportedSquibFireModes,
SupportedDigitalOutputModes,
ModuleSerialNumber,
ModuleArrayIndex
}
public const string SLICE1_PROTOTYPE = "SLICE1 Prototype";
public const string SLICEPRO_PROTOTYPE = "SLICEPRO Prototype";
public const string PROTOTYPE_POSITION = "Prototype";
public const string SLICE1_5PROTOTYPE = "SLICE+ Prototype";
public const string G5_VDSPROTOTYPE = "G5 VDS Prototype";
public const string G5_IPORTPROTOTYPE = "G5 iPort Prototype";
public const string TDASPRO_8MRack = "TDASPro Rack 8M Prototype";
public const string TDASPRO_4MRack = "TDASPRO Rack 4M Prototype";
public const string ECM_PROTOTYPE = "SLICE ECM Prototype";
public const string SPM_PROTOTYPE = "SLICE Mini Distributor Prototype";
public const string SLE_PROTOTYPE = "SLICE PRO Lab Ethernet Prototype";
public const string SDB_PROTOTYPE = "SLICE Distributor Prototype";
public const string Slice_NanoPROTOTYPE = "SLICE Nano Prototype";
public const string Slice_MicroPROTOTYPE = "SLICE Micro Prototype";
public const string SLICEPRODIM_PROTOTYPE = "SLICE Pro DIM";
public const string SLICEPROSLD_PROTOTYPE = "SLICE PRO Lab DIM";
public const string SLICEPROTOM_PROTOTYPE = "SLICE Pro TOM";
public const string SLICEPROSLT_PROTOTYPE = "SLICE PRO Lab TOM";
public const string SLICEPROSIM_PROTOTYPE = "SLICE Pro SIM";
public const string SLICEPROSLS_PROTOTYPE = "SLICE PRO Lab SIM";
public const string SLICE1_5_MicroPROTOTYPE = "SLICE MICRO BASE+ Prototype";
public const string G5_INDUMMYPROTOTYPE = "G5 InDummy Prototype";
public const string SG5_PROTOTYPE = "SLICE G5 Prototype";
public const string TDASPRO_LabRack = "TDAS PRO Lab Rack";
public const string SLICE6_PROTOTYPE = "SLICE6 Prototype";
public const string SLICE6_AIR_PROTOTYPE = "SLICE6 AIR Prototype";
public const string SLICE6_AIR_ER_PROTOTYPE = "SLICE6 AIR ER Prototype";
public const string SLICE6_AIR_BR_PROTOTYPE = "SLICE6 Falcon Prototype";
public const string SLICE6DB_PROTOTYPE = "SLICE6Db Prototype";
public const string SLICE6DB3_PROTOTYPE = "SLICE6Db3 Prototype";
public const string SLICE6DB_AIR_PROTOTYPE = "SLICE6Db AIR Prototype";
public const string SLICE6DB_INDUMMY_PROTOTYPE = "SLICE6Db InDummy Prototype";
public const string POWERPRO_PROTOTYPE = "PowerPRO Prototype";
public const string TSR_AIR_PROTOTYPE = "TSR Air Prototype";
public const string TSR_AIR_REVB_PROTOTYPE = "TSR Air RevB Prototype";
public const string DIR_PROTOTYPE = "DIR Prototype";
public const string DKR_PROTOTYPE = "DKR Prototype";
public const string EMB_LIN_ACC_LO_MODULE_PROTOTYPE = "EMB LIN ACC LO Module Prototype";
public const string EMB_LIN_ACC_HI_MODULE_PROTOTYPE = "EMB LIN ACC HI Module Prototype";
public const string EMB_ARS_MODULE_PROTOTYPE = "EMB ARS Module Prototype";
public const string EMB_ATM_MODULE_PROTOTYPE = "EMB ATM Module Prototype";
public const string SLICEPRO_DB_PROTOTYPE = "SLICE Pro Distributor Prototype";
public const string SLICE_TC_PROTOTYPE = "SLICE TC Prototype";
}
public abstract class TestObjectChannelSettings
{
public const string TableName = "tblTestObjectChannelSettings";
public enum Fields
{
TestObjectSerial,
ChannelId,
Setting,
SensorSerial,
SerialNumber
}
}
public abstract class DigitalOutputSettings
{
public const string Table = "tblTOMDigitalChannels";
public enum Fields
{
ChannelDescription,
DelayMS,
DurationMS,
OutputMode,
LimitDuration,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
DurationMSFloat,
UserTags,
Broken, //new in 2.0
DoNotUse //new in 2.0
}
}
public abstract class Squib
{
public const string Table = "tblTOMSquibChannels";
public enum Fields
{
SerialNumber,
SquibDescription,
BypassCurrentFilter,
BypassVoltageFilter,
DelayMS,
DurationMS,
FireMode,
ISOCode,
ISOChannelName,
UserCode,
UserChannelName,
MeasurementType,
SquibOutputCurrent,
SquibToleranceLow,
SquibToleranceHigh,
LimitDuration,
ArticleId,
LocalOnly,
Version,
LastModified,
LastModifiedBy,
UserValue1,
UserValue2,
UserValue3,
UserTags,
Broken, //new in 2.0
DoNotUse, //new in 2.0
DefineDelayInTest // new in 2.3
}
}
public abstract class UartIOSettings
{
public const string Table = "tblUartIOSettings";
public enum Fields
{
SerialNumber,
Description,
BaudRate,
DataBits,
StopBits,
Parity,
FlowControl,
DataFormat,
LastModified,
LastModifiedBy,
UserTags,
Broken,
DoNotUse
}
}
public abstract class StreamOutputSettings
{
public const string Table = "tblStreamOutputSettings";
public enum Fields
{
SerialNumber,
Description,
StreamProfile,
UDPAddress,
TimeChannelId,
DataChannelId,
TmNSConfig,
IRIGTimeDataPacketIntervalMs,
LastModified,
LastModifiedBy,
UserTags,
Broken,
DoNotUse
}
}
public abstract class CalculatedChannels
{
public const string Table = "tblCalculatedChannels";
public enum Fields
{
[DbTypeAttr("INTEGER PRIMARY KEY NOT NULL")]
Id,
[DbTypeAttr("INTEGER")]
Operation,
[DbTypeAttr("NVARCHAR(255)")]
CalculatedChannelValueCode,
[DbTypeAttr("BLOB")]
InputChannelIds,
[DbTypeAttr("NVARCHAR(255)")]
CFCForInputChannels,
[DbTypeAttr("NVARCHAR(255)")]
CFCForOutput,
[DbTypeAttr("NVARCHAR(255)")]
TestSetupName,
[DbTypeAttr("NVARCHAR(255)")]
CCName,
[DbTypeAttr("Bit")]
ViewInRealtime,
[DbTypeAttr("Int")]
ClipLength
}
}
public abstract class LevelTriggers
{
public const string Table = "tblLevelTriggers";
public enum Fields
{
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
TestSetupName,
[DbTypeAttr("BIGINT NOT NULL")]
ChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
GroupName,
//[DbTypeAttr("NVARCHAR(255) NOT NULL")]
//TestObjectChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
HardwareChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
SensorSerialNumber,
[DbTypeAttr("BIT NOT NULL")]
GreaterThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
GreaterThanEU,
[DbTypeAttr("BIT NOT NULL")]
LessThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
LessThanEU,
[DbTypeAttr("FLOAT NULL")]
InsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
InsideLowerEU,
[DbTypeAttr("FLOAT NULL")]
OutsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
OutsideLowerEU,
[DbTypeAttr("BIT NULL")]
InsideEnabled, //TriggerInside,
[DbTypeAttr("BIT NULL")]
OutsideEnabled, //TriggerOutside,
//[DbTypeAttr("NVARCHAR(255) NOT NULL")]
//TestObjectName
};
}
public abstract class Tags
{
public const string Table = "tblTags";
public enum TagFields
{
TagId,
TagText,
Obsolete
}
public const string TAGASSIGNMENTS_TABLE = "TagAssignments";
public enum TagAssignmentFields
{
ObjectID,
ObjectType,
TagID
}
}
public abstract class DbVersions
{
public enum DbVersionFields
{
Version,
Step,
Date,
Remarks,
UserField
}
}
public abstract class Settings
{
public const string Table = "tblSettings";
public enum UserFields
{
PropertyId,
PropertyType,
PropertyValue,
UserId
}
}
public abstract class MMEPossibleChannels
{
public const string Table = "tblMMEPossibleChannels";
}
public abstract class LabratoryDetails
{
public const string Table = "tblLabratoryDetails";
public enum LabratoryDetailsFields
{
Name,
LabratoryName,
LabratoryContactName,
LabratoryContactPhone,
LabratoryContactFax,
LabratoryContactEmail,
LabratoryTestRefNumber,
LabratoryProjectRefNumber,
LastModified,
LastModifiedBy,
LocalOnly,
Version
}
}
/// <summary>
/// tables and fields for user objects
/// </summary>
public abstract class Users
{
public const string USERS_TABLE = "DataPROUsers";
public enum UserFields
{
ID,
UserName,
DisplayName,
Password,
Role,
LastModified,
LastModifiedBy,
LocalOnly
}
public const string UIITEMS_TABLE = "UIITEMS";
public enum UIItemFields
{
ID,
Name
}
public const string USERUISETTINGS_TABLE = "UserUIItemSettings";
public enum UserUIItemSettingFields
{
UserId,
UIItemID,
Permission,
Visible
}
}
}
}

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Attach_DataPRO_RemoteDB.sql" -v DBNAME=%3

View File

@@ -0,0 +1,26 @@
namespace DTS.Storage
{
public abstract class CalculatedChannels
{
public const string Table = "tblCalculatedChannels";
public enum Fields
{
[DbTypeAttr("INTEGER PRIMARY KEY NOT NULL")]
Id,
[DbTypeAttr("INTEGER")]
Operation,
[DbTypeAttr("NVARCHAR(255)")]
CalculatedChannelValueCode,
[DbTypeAttr("BLOB")]
InputChannelIds,
[DbTypeAttr("NVARCHAR(255)")]
CFCForInputChannels,
[DbTypeAttr("NVARCHAR(255)")]
CFCForOutput,
[DbTypeAttr("NVARCHAR(255)")]
TestSetupName,
[DbTypeAttr("NVARCHAR(255)")]
CCName
}
}
}

View File

@@ -0,0 +1,395 @@
// ReSharper disable InconsistentNaming
namespace DTS.Common.Storage
{
public class DbOperationsEnum
{
public enum StoredProcedure
{
sp_UsersDelete,
sp_UsersGet,
sp_UsersInsert,/* not used */
sp_UsersUpdate,
sp_UsersGetId,
sp_UserGetIdsAll,
sp_UsersUpdateInsert,
sp_DefaultPropertiesGet,
sp_DefaultPropertiesUpdate,
sp_DefaultPropertiesInsert,
sp_LastUsedHardwareDelete,
sp_LastUsedHardwareGet,
sp_LastUsedHardwareGetId, /* not used */
sp_LastUsedHardwareInsert,
sp_LastUsedHardwareUpdate,/* not used */
sp_LastUsedHardwareUpdateInsert,/* not used */
sp_CalculatedChannelsDelete,/* not used */
sp_CalculatedChannelsGet,
sp_CalculatedChannelsInsert,/* not used */
sp_CalculatedChannelsUpdate,/* not used */
sp_CalculatedChannelsUpdateInsert,
sp_CustomerDetailsDelete,
sp_CustomerDetailsGet,
sp_CustomerDetailsInsert,
sp_CustomerDetailsUpdate,
sp_DASChannelsDelete,
sp_DASChannelsGet,
sp_DASChannelsInsert,
sp_DASChannelsUpdate,/* not used */
sp_DASChannelsUpdateInsert,
sp_DASDelete,
sp_DASGet,
sp_DASInsert,
sp_DASUpdate,
sp_DASUpdateInsert,
sp_DASChildrenGet,
sp_DASChildrenUnAssociate,
sp_DBImportCustomerDetails,
sp_DBImportDASList,
sp_DBImportDbVersions,
sp_DBImportGroup,
sp_DBImportGroupTemplate,
sp_DBImportLabDetails,
sp_DBImportLastUsedHardware,
sp_DBImportMMEDirections,
sp_DBImportMMEFineLocations1,
sp_DBImportMMEFineLocations2,
sp_DBImportMMEFineLocations3,
sp_DBImportMMEMainLocations,
sp_DBImportMMEPhysicalDimensions,
sp_DBImportMMEPositions,
sp_DBImportMMEPossibleChannels,
sp_DBImportMMETestObjects,
sp_DBImportSensorModel,
sp_DBImportSensors,
sp_DBImportSensorsCalibration,
sp_DBImportSettings,
sp_DBImportTagAssignments,
sp_DBImportTags,
sp_DBImportTemplateRegions,
sp_DBImportTemplateZones,
sp_DBImportTestEngineerDetails,
sp_DBImportTestSetups,
sp_DBImportUsers,
sp_LabratoryDetailsDelete,
sp_LabratoryDetailsGet,
sp_LabratoryDetailsInsert,/* not used */
sp_LabratoryDetailsUpdate,/* not used */
sp_LabratoryDetailsUpdateInsert,
sp_LevelTriggersDelete,
sp_LevelTriggersGet,
sp_LevelTriggersInsert,
sp_LevelTriggersUpdate,/* not used */
sp_MMEDirectionsDelete,
sp_MMEDirectionsGet,
sp_MMEDirectionsGetCustom,
sp_MMEDirectionsInsert,/* not used */
sp_MMEDirectionsUpdate,
sp_MMEDirectionsUpdateInsert,
sp_MMEFiguresDelete,/* not used */
sp_MMEFiguresGet,
sp_MMEFiguresGetCustom,
sp_MMEFiguresInsert, /* not used */
sp_MMEFiguresUpdate,/* not used */
sp_MMEFiguresInsertUpdate,/* not used */
sp_MMEFilterClassesDelete,
sp_MMEFilterClassesGet,
sp_MMEFilterClassesGetCustom,
sp_MMEFilterClassesInsert,
sp_MMEFilterClassesUpdate,/* not used */
sp_MMEFilterClassesInsertUpdate,
sp_MMEFineLocations1Delete,
sp_MMEFineLocations1Get,
sp_MMEFineLocations1GetCustom,
sp_MMEFineLocations1Insert,/* not used */
sp_MMEFineLocations1Update,
sp_MMEFineLocations1UpdateInsert,
/* */
sp_MMEFineLocations2Delete,
sp_MMEFineLocations2Get,
sp_MMEFineLocations2GetCustom,
sp_MMEFineLocations2Insert,
sp_MMEFineLocations2Update,
sp_MMEFineLocations2UpdateInsert,
sp_MMEFineLocations3Delete,
sp_MMEFineLocations3Get,
sp_MMEFineLocations3GetCustom,
sp_MMEFineLocations3Insert,
sp_MMEFineLocations3Update,
sp_MMEFineLocations3UpdateInsert,
sp_MMEMainLocationsDelete,
sp_MMEMainLocationsGet,
sp_MMEMainLocationsGetCustom,
sp_MMEMainLocationsInsert,
sp_MMEMainLocationsUpdate,
sp_MMEMainLocationsUpdateInsert,
sp_MMEPhysicalDimensionsDelete,
sp_MMEPhysicalDimensionsGet,
sp_MMEPhysicalDimensionsGetCustom,
sp_MMEPhysicalDimensionsInsert,
sp_MMEPhysicalDimensionsUpdate,
sp_MMEPhysicalDimensionsUpdateInsert,
sp_MMEPositionsDelete,
sp_MMEPositionsGet,
sp_MMEPositionsGetCustom,
sp_MMEPositionsInsert,
sp_MMEPositionsUpdate,
sp_MMEPositionsUpdateInsert,
sp_MMEPossibleChannelsDelete,
sp_MMEPossibleChannelsGet,
sp_MMEPossibleChannelsGetCustom,
sp_MMEPossibleChannelsInsert,
sp_MMEPossibleChannelsUpdate,
sp_MMEPossibleChannelsUpdateInsert,
sp_MMETestObjectsDelete,
sp_MMETestObjectsGet,
sp_MMETestObjectsGetCustom,
sp_MMETestObjectsInsert,
sp_MMETestObjectsUpdate,
sp_MMETestObjectsUpdateInsert,
sp_TemplateChannelsDelete,
sp_TemplateChannelsDeleteOne,
sp_TemplateChannelsGet,
sp_TemplateChannelsInsert,
sp_TemplateChannelsUpdate,
sp_TemplateChannelsUpdateInsert,
sp_TemplateRegionsDelete,
sp_TemplateRegionsGet,
sp_TemplateRegionsInsert,
sp_TemplateRegionsUpdate,
sp_TemplateZonesDelete,
sp_TemplateZonesGet,
sp_TemplateZonesInsert,
sp_TemplateZonesUpdate,
sp_TestChannelSettingsDelete,
sp_TestChannelSettingsGet,
sp_TestChannelSettingsInsert,
sp_TestChannelSettingsUpdate,
sp_TestEngineerDetailsDelete,
sp_TestEngineerDetailsGet,
sp_TestEngineerDetailsInsert,
sp_TestEngineerDetailsUpdate,
sp_TestEngineerDetailsUpdateInsert,
sp_TestGraphsDelete,
sp_TestGraphsGet,
sp_TestGraphsInsert,
sp_TestGraphsUpdate,
sp_TestGraphsUpdateInsert,
sp_TestObjectChannelSettingsDelete,
sp_TestObjectChannelSettingsGet,
sp_TestObjectChannelSettingsInsert,
sp_TestObjectChannelSettingsUpdate,
sp_TestObjectHardwareDelete,
sp_TestObjectHardwareExists,
sp_TestObjectHardwareGet,
sp_TestObjectHardwareInsert,
sp_TestObjectHardwareUpdate,
sp_TestObjectHardwareIdsGet,
sp_TestObjectSensorsDelete,
sp_TestObjectSensorsGet,
sp_TestObjectSensorsInsert,
sp_TestObjectSensorsUpdate,
sp_TestObjectsDelete,
sp_TestObjectExist,
sp_TestObjectsGet,
sp_TestObjectsInsert,
sp_TestObjectsUpdate,
sp_TestObjectsUpdateInsert,
sp_TestObjectTemplatesDelete,
sp_TestObjectTemplateExist,
sp_TestObjectTemplatesGet,
sp_TestObjectTemplatesInsert,
sp_TestObjectTemplatesUpdate,
sp_TestObjectTemplatesUpdateInsert,
sp_TestSetupDASSettingsDelete,
sp_TestSetupDASSettingsGet,
sp_TestSetupDASSettingsInsert,
sp_TestSetupDASSettingsUpdate,
sp_TestSetupDASSettingsUpdateInsert,
sp_TestSetupHardwareDelete,
sp_TestSetupHardwareGet,
sp_TestSetupHardwareInsert,
sp_TestSetupHardwareUpdate,
sp_TestSetupObjectMetaDataDelete,
sp_TestSetupObjectMetaDataGet,
sp_TestSetupObjectMetaDataInsert,
sp_TestSetupObjectMetaDataUpdate,
sp_TestSetupObjectMetaDataUpdateInsert,
sp_TestSetupObjectsDelete,
sp_TestSetupObjectsGet,
sp_TestSetupObjectNamesGet,
sp_TestSetupObjectsInsert,
sp_TestSetupObjectsUpdate,
sp_TestSetupObjectsUpdateInsert,
sp_TestSetupsDelete,
sp_TestSetupsDeleteAll,
sp_TestSetupsGet,
sp_TestSetupsInsert,
sp_TestSetupsUpdateInsert,
sp_TestSetupsMarkIncomplete,
sp_TestSetupsIsCompleteUpdate,
sp_TestSetupsNameGet,
sp_TestSetupsUpdate,
sp_LockFree,
sp_LockGet,
sp_LockUpdate,
sp_SensorCalibrationsDelete,
sp_SensorCalibrationsGet,
sp_SensorCalibrationsInsert,
sp_SensorCalibrationsUpdate,
sp_SensorCalibrationsUpdateInsert,
sp_SensorInUse,
sp_SensorsDelete, /* All sensor type */
sp_SensorsGet,
sp_SensorsDeleteAll,
sp_SensorsUpdateAll,
sp_SensorExists,
sp_SensorsAnalogDelete,
sp_SensorsAnalogGet,
sp_SensorsAnalogInsert,
sp_SensorsAnalogUpdate,
sp_SensorsAnalogUpdateAll,
sp_SensorsAnalogUpdateInsert,
sp_SensorsAnalogBridgeResistanceGet,
sp_SensorsDigitalInDelete,
sp_SensorsDigitalInGet,
sp_SensorsDigitalInInsert,
sp_SensorsDigitalInUpdate,
sp_SensorsDigitalInUpdateAll,
sp_SensorsDigitalInUpdateInsert,
sp_SensorsDigitalOutDelete,
sp_SensorsDigitalOutGet,
sp_SensorsDigitalOutInsert,
sp_SensorsDigitalOutUpdate,
sp_SensorsDigitalOutUpdateAll,
sp_SensorsDigitalOutUpdateInsert,
sp_SensorsSquibDelete,
sp_SensorsSquibGet,
sp_SensorsSquibInsert,
sp_SensorsSquibUpdate,
sp_SensorsSquibUpdateAll,
sp_SensorsSquibUpdateInsert,
sp_SensorsUARTDelete,
sp_SensorsUARTGet,
sp_SensorsUARTInsert,
sp_SensorsUARTUpdate,
sp_SensorsUARTUpdateAll,
sp_SensorsUARTUpdateInsert,
sp_SensorsStreamOutputDelete,
sp_SensorsStreamOutputGet,
sp_SensorsStreamOutputInsert,
sp_SensorsStreamOutputUpdate,
sp_SensorsStreamOutputUpdateAll,
sp_SensorsStreamOutputUpdateInsert,
sp_SensorCalibrationsZeroMethodUpdate,
sp_SensorModelsDelete,
sp_SensorModelsGet,
sp_SensorModelsInsert,
sp_SensorModelsUpdate,
sp_SensorUpdate,
sp_SettingsDelete,
sp_SettingsGet,
sp_SettingsInsert,
sp_SettingsUpdate,
sp_SettingsUpdateInsert,
sp_TagAssignmentsDelete,
sp_TagAssignmentsGet,
sp_TagAssignmentsInsert,
sp_TagAssignmentsUpdate,
sp_TagsDelete,
sp_TagsGet,
sp_TagsGetId,
sp_TagsInsert,
sp_TagsUpdate,
sp_TagsUpdateInsert,
sp_UIItemsGet,
sp_UserUIItemSettingsDelete,
sp_UserUIItemSettingsGet,
sp_UserUIItemSettingsInsert,
sp_UserUIItemSettingsUpdate,
sp_DbVersionDelete,
sp_DbVersionGet,
sp_DbVersionInsert,
sp_UserPropertiesDelete,
sp_UserPropertiesGet,
sp_UserPropertiesInsert,
sp_UserPropertiesUpdate,
sp_UserPropertiesUpdateInsert,
sp_GroupsGet,
sp_GroupsInsert,
sp_GroupsUpdate,
sp_GroupsUpdateInsert,
sp_ChannelsInsert,
sp_ChannelsUpdateInsert,
sp_ChannelCodesInsert,
sp_GroupHardwareInsert,
sp_ChannelSettingsGet,
sp_GroupChannelSettingsGet,
sp_GroupChannelSettingsInsert,
sp_GroupChannelSettingsUpdateInsert,
sp_TestSetupGroupsInsert,
sp_TestSetupsDeleteManyByDate,
sp_TestSetupsDeleteManyById,
sp_TestSetupsDeleteManyByName,
}
}
}

View File

@@ -0,0 +1,118 @@
namespace DTS.Storage
{
public abstract class SensorDB
{
public const string SensorCalibrationTable = "tblSensorCalibrations";
public const string SensorDataTable = "tblSensors";
public const string SensorModelsTable = "tblSensorModels";
public enum SensorDataFields
{
SerialNumber = 1,
UserSerialNumber,
Model,
Manufacturer,
Status,
MeasurementUnit,
OffsetToleranceLow,
OffsetToleranceHigh,
Id,
Capacity,
Comment,
BridgeType,
BridgeLegMode,
Shunt,
Invert,
UserValue1,
UserValue2,
UserValue3,
FilterClass,
BridgeResistance,
IsoCode,
CheckOffset,
SupportedExcitation,
InitialEU,
CalInterval,
CalibrationSignal,
InternalShuntResistance,
ExternalShuntResistance,
UniPolar,
RangeLow,
RangeAve,
RangeHigh,
Created,
TimesUsed,
SensorCategory,
BypassFilter,
CouplingMode,
Version,
LastModified,
ModifiedBy,
LocalOnly,
AxisNumber,
NumberOfAxes,
UserTags,
DoNotUse,
Broken
}
public enum SensorModelFields
{
Model,
Manufacturer,
UserPartNumber,
Capacity,
OffsetToleranceLow,
OffsetToleranceHigh,
MeasurementUnit,
Bridge,
Shunt,
BridgeResistance,
FilterClass,
UniPolar,
IgnoreRange,
CouplingMode,
Version,
RangeLow,
RangeAve,
RangeHigh,
LastModified,
ModifiedBy,
LocalOnly,
NumberOfAxes,
CalInterval,
AxisNumber,
Polarity,
Invert,
CheckOffset,
CalibrationRecord,
ISOCode,
SupportedExcitation
}
public enum SensorCalibrationFields
{
SerialNumber,
CalibrationDate,
Username,
LocalOnly,
NonLinear,
CalibrationRecords,
ModifyDate,
IsProportional,
RemoveOffset,
ZeroMethod,
CertificationDocuments,
InitialOffset
}
public enum SensorCalibrationRecordFields
{
Sensitivity,
Poly,
AtCapacity,
EngineeringUnits,
Excitation,
CapacityOutputIsBasedOn,
SensitivityUnits
}
}
}

View File

@@ -0,0 +1,11 @@
using System;
namespace DTS.Storage
{
public class NoDBAccessException : Exception
{
public NoDBAccessException(Exception ex)
: base(ex.Message, ex) { }
}
}

View File

@@ -0,0 +1,138 @@
namespace DTS.Common.Storage
{
public partial class DbOperations
{
public abstract class SensorDB
{
public const string SensorCalibrationTable = "tblSensorCalibrations";
public const string SensorDataTable = "tblSensors";
public const string SensorModelsTable = "tblSensorModels";
public enum SensorDataFields
{
SerialNumber = 1,
UserSerialNumber,
Model,
Manufacturer,
Status,
MeasurementUnit,
OffsetToleranceLow,
OffsetToleranceHigh,
Id,
Capacity,
Comment,
BridgeType,
BridgeLegMode,
Shunt,
Invert,
UserValue1,
UserValue2,
UserValue3,
FilterClass,
BridgeResistance,
IsoCode,
CheckOffset,
SupportedExcitation,
InitialEU,
CalInterval,
CalibrationSignal,
InternalShuntResistance,
ExternalShuntResistance,
UniPolar,
RangeLow,
RangeAve,
RangeHigh,
Created,
TimesUsed,
SensorCategory,
BypassFilter,
CouplingMode,
Version,
LastModified,
ModifiedBy,
LocalOnly,
AxisNumber,
NumberOfAxes,
UserTags,
DoNotUse,
Broken,
eId,
DiagnosticsMode,
IsoChannelName,
UserCode,
UserChannelName,
FirstUseDate,
LatestCalibrationId
}
public enum SensorModelFields
{
Model,
Manufacturer,
UserPartNumber,
Capacity,
OffsetToleranceLow,
OffsetToleranceHigh,
MeasurementUnit,
Bridge,
Shunt,
BridgeResistance,
FilterClass,
UniPolar,
IgnoreRange,
CouplingMode,
Version,
RangeLow,
RangeAve,
RangeHigh,
LastModified,
ModifiedBy,
LocalOnly,
NumberOfAxes,
CalInterval,
AxisNumber,
Polarity,
Invert,
CheckOffset,
CalibrationRecord,
ISOCode,
ISOChannelName,
UserCode,
UserChannelName,
SupportedExcitation
}
public enum SensorCalibrationFields
{
SerialNumber,
CalibrationDate,
Username,
LocalOnly,
NonLinear,
CalibrationRecords,
ModifyDate,
IsProportional,
RemoveOffset,
ZeroMethod,
CertificationDocuments,
InitialOffset,
SensorCalibrationId,
UsageCount,
SensitivityInspection,
CalibrationNote
}
public enum SensorCalibrationRecordFields
{
Sensitivity,
Poly,
AtCapacity,
EngineeringUnits,
Excitation,
CapacityOutputIsBasedOn,
SensitivityUnits
}
}
}
}

View File

@@ -0,0 +1,16 @@
namespace DTS.Storage
{
public abstract class Settings
{
public const string Table = "tblSettings";
public enum UserFields
{
PropertyId,
PropertyType,
PropertyValue,
UserId
}
}
}

View File

@@ -0,0 +1,9 @@
USE master
GO
RESTORE DATABASE $(DBNAME)Pre20 FROM DISK='C:\DataPRO_SQL\$(DBNAME)Backup.bak' WITH
MOVE 'DataPRO' TO 'C:\DataPRO_SQL\$(DBNAME)Pre20.mdf',
MOVE 'DataPRO_log' TO 'C:\DataPRO_SQL\$(DBNAME)Pre20_log.ldf'
GO

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Storage")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Storage")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b62ab8e0-42f4-4a11-bad5-0add30baad84")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Attach_ISO_RemoteDB.sql"

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Backup_Alter_Detach_RemoteDBs.sql" -v DBNAME=%3

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Restore_As_DataPROPre20_RemoteDB.sql" -v DBNAME=%3

View File

@@ -0,0 +1,157 @@
namespace DTS.Storage
{
public abstract class TestSetups
{
public const string HardwareTable = "tblTestSetupHardware";
public enum HardwareFields
{
TestSetupName,
HardwareId,
AddOrRemove //0=remove,1=add
}
public const string DASSettingsTable = "tblTestSetupDASSettings";
public const string ChannelSettingsTable = "tblTestChannelSettings";
public enum ChannelSettingFields
{
TestName,
TestObjectName,
ChannelId,
Setting,
SensorSerial
}
public const string TestSetupsTable = "tblTestSetups";
public enum Fields
{
SetupName,
SetupDescription,
AutomaticTestProgression,
AutomaticProgressionDelayMS,
InvertTrigger,
InvertStart,
ViewDiagnostics,
VerifyChannels,
AutoVerifyChannels,
VerifyChannelsDelayMS,
RecordingMode,
SamplesPerSecond,
PreTriggerSeconds,
PostTriggerSeconds,
StrictDiagnostics,
RequireConfirmationOnErrors,
ROIDownload,
ViewROIDownload,
DownloadAll,
ViewRealtime,
RealtimePlotCount,
ROIStart,
ROIEnd,
ViewDownloadAll,
Export,
ExportFormat,
LabDetails,
UseLabDetails,
CustomerDetails,
UseCustomerDetails,
AllowMissingSensors,
AllowSensorIdToBlankChannel,
LocalOnly,
LastModified,
LastModifiedBy,
TurnOffExcitation,
TriggerCheckRealtime,
TriggerCheckStep,
PostTestDiagnostics,
ExportFolder,
DownloadFolder,
CommonStatusLine,
SameAsDownloadFolder,
UploadData,
UploadDataFolder,
Settings,
WarnOnBatteryFail,
Dirty,
Complete,
ErrorMessage,
TestEngineerDetails,
UseTestEngineerDetails,
UserTags,
DoAutoArm,
CheckoutMode,
QuitTestWithoutWarning,
SuppressMissingSensorsWarning,
ISFFile,
NotAllChannelsRealTime,
NotAllChannelsViewer
}
public const string TestSetupObjectsTable = "tblTestSetupObjects";
public enum TestSetupObjectFields
{
TestObjectSerialNumber,
TestSetupName,
TargetSampleRate,
ExcitationWarmupTimeMS,
LocalOnly,
TestObjectType,
TestObjectPosition
}
public const string TestObjectMetaDataTable = "tblTestSetupObjectMetaData";
public enum TestObjectMetaDataFields
{
TestObject,
SetupName,
PropName,
PropValue,
Optional,
Version
}
public const string TestObjectTemplatesTable = "tblTestObjectTemplates";
public enum TestObjectTemplatesFields
{
TemplateName,
Icon,
Description,
LocalOnly,
Version,
LastModifiedBy,
CRC32,
TestObject,
LastModified,
ParentTemplate,
SysBuilt
}
public const string TestObjectsTable = "tblTestObjects";
public enum TestObjectsFields
{
SerialNumber,
LastModifiedBy,
LastModified,
Template,
LocalOnly,
ParentObject,
SysBuilt,
Embedded,
OriginalTemplate,
OriginalSerialNumber
}
public const string TestGraphsTable = "tblTestGraphs";
public enum GraphFields
{
GraphName,
GraphDescription,
TemplateName,
Channels,
UseDomainMin,
DomainMin,
UseDomainMax,
DomainMax,
UseRangeMin,
RangeMin,
UseRangeMax,
RangeMax,
Thresholds,
LocalOnly
}
}
}

View File

@@ -0,0 +1,2 @@
%1\Redistributables\%2\msodbcsql.msi
%1\Redistributables\%2\MsSqlCmdLnUtils.msi

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Attach_DataPROPre20_RemoteDB.sql" -v DBNAME=%3

View File

@@ -0,0 +1,148 @@
using System;
using System.Data;
// ReSharper disable ConditionIsAlwaysTrueOrFalse
using System.Data.SqlClient;
namespace DTS.Common.Storage
{
// this class is just to access the local db while the remote db is still connected
public class LocalOnlyOperations
{
public const string BeginStatement = "BEGIN TRAN;";
public const string CommitStatement = "COMMIT TRAN;";
public const bool UsingNtlmAuthentication = true;
public static void CreateParam(IDbCommand icmd, string name, SqlDbType type, object value)
{
switch (type)
{
case SqlDbType.DateTime:
if (null == value)
{
value = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
}
else if (value is DateTime)
{
if ((DateTime)value < (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue)
{
value = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
}
value = $"{(DateTime)value:yyyy-MM-dd} {((DateTime)value).ToString("HH:mm:ss")}";
}
break;
case SqlDbType.NVarChar:
break;
}
var param = new SqlParameter(name, type);
param.Value = value;
icmd.Parameters.Add(param);
}
public static IDbCommand GetCommand()
{
return GetSQLCommand();
}
public static SqlCommand cmd { get; set; } = null;
public static SqlCommand GetSQLCommand()
{
return GetSQLCommand(false);
}
public static SqlCommand GetSQLCommand(bool newCommand)
{
if (cmd == null) { cmd = new SqlCommand(); }
var currentCmd = cmd;
if (newCommand) { currentCmd = new SqlCommand(); }
if (currentCmd.Connection == null || currentCmd.Connection.State != ConnectionState.Open)
{
currentCmd.Connection = new SqlConnection(Connection.GetLocalConnectionString());
currentCmd.Connection.Open();
}
currentCmd.Parameters.Clear();
return currentCmd;
}
public static IDbCommand GetSQLOnlyCommand()
{
return new SqlCommand();
}
private string _localConnection = null;
public void ResetLocalConnectionString()
{
lock (DbLock)
{
_localConnection = null;
}
}
public string GetLocalConnectionString()
{
lock (DbLock)
{
if (null != _localConnection) return _localConnection;
if (null == Server)
{
throw new Exception("db connection not initialized");
}
_localConnection = $"Server={Server};Database={DbName};Trusted_Connection=TRUE;";
}
return _localConnection;
}
public string Server { get; set; } = null;
public string DbName { get; set; } = null;
public string Username { get; set; } = "";
public string Password { get; set; }
private static LocalOnlyOperations _dbOperations = null;
private static readonly object DbLock = new object();
public static LocalOnlyOperations Connection
{
get
{
lock (DbLock)
{
if (null == _dbOperations) { _dbOperations = new LocalOnlyOperations(); }
}
return _dbOperations;
}
}
protected LocalOnlyOperations() { }
public const string NoConnection = "NoConnection";
public int ExecuteCommand(IDbCommand icmd)
{
var cmd = icmd as SqlCommand;
using (var msSqlConnection = new SqlConnection(GetLocalConnectionString()))
{
try
{
msSqlConnection.Open();
cmd.Connection = msSqlConnection;
}
catch (Exception ex)
{
throw new SystemException(NoConnection, ex);
}
if (cmd != null)
{
cmd.Connection = msSqlConnection;
}
return cmd.ExecuteNonQuery();
}
}
}
}

View File

@@ -0,0 +1,6 @@
USE master
GO
sp_attach_db '$(DBNAME)', 'C:\DataPRO_SQL\$(DBNAME).mdf'
GO

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Backup_RemoteDB.sql" -v DBNAME=%3

View File

@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E3BE457C-0AC7-4A9C-BC81-EAFEB3217878}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Storage</RootNamespace>
<AssemblyName>Storage</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Prism">
<HintPath>..\DTS.Common\lib\PrismLibrary\Prism.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data.SQLite">
<HintPath>..\DTS.Common\lib\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractClasses.cs" />
<Compile Include="DatabaseServices.cs" />
<Compile Include="LocalOnlyOperations.cs" />
<Compile Include="DbOperations.cs" />
<Compile Include="DbOperationsEnum.cs" />
<Compile Include="LockManager.cs" />
<Compile Include="Migrations.cs" />
<Compile Include="MMETables.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SensorDB.cs" />
<Compile Include="TableCreation.cs" />
<Compile Include="SensorTestHistory.cs" />
<Compile Include="TestHistory.cs" />
<Compile Include="TestSetups.cs" />
<Compile Include="TypeConverter.cs" />
<Compile Include="UserMigrationHelper.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="DataPRO.mdf" />
<Content Include="DataPROCreationScript_3.0.sql" />
<Content Include="DataPRO_log.ldf" />
<Content Include="ISO.mdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="ISO_log.ldf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="AttachDBs.bat" />
<None Include="Design\DTS.Common.StorageClassDiagram.cd" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DataPRO\DbAPI\DbAPI.csproj">
<Project>{c356fb81-3177-4a42-b3c2-afa619335e3f}</Project>
<Name>DbAPI</Name>
</ProjectReference>
<ProjectReference Include="..\..\DataPRO\Modules\Database\DatabaseInitializationScripts\DatabaseInitializationScripts.csproj">
<Project>{6094201e-5ed8-4aaa-a487-a0361a9e1e2e}</Project>
<Name>DatabaseInitializationScripts</Name>
</ProjectReference>
<ProjectReference Include="..\..\DataPRO\Modules\Database\DatabaseMigrationScripts\DatabaseMigrationScripts.csproj">
<Project>{efab771c-7aa7-4715-8ac3-9a1b6194fcc2}</Project>
<Name>DatabaseMigrationScripts</Name>
</ProjectReference>
<ProjectReference Include="..\DTS.Common.Utilities\DTS.Common.Utilities.csproj">
<Project>{d6da1b74-c711-43c2-91b1-1908a8d04dbf}</Project>
<Name>DTS.Common.Utilities</Name>
</ProjectReference>
<ProjectReference Include="..\DTS.Common\DTS.Common.csproj">
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
<Name>DTS.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="DTS\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,259 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using DTS.Common.Utilities.Logging;
// ReSharper disable once CheckNamespace
namespace DTS.Common.Storage
{
/// <summary>
/// this class is used for migration from 52 to 53 in the database
/// it handles moving the users from the old structures to the new ones
/// http://fogbugz/fogbugz/default.asp?9749
/// </summary>
public class UserMigrationHelper
{
public string UserName { get; }
public string DisplayName { get; }
public string Password { get; }
public short Role { get; }
public DateTime LastModified { get; }
public string LastModifiedBy { get; }
public bool LocalOnly { get; }
public Dictionary<string, short> Permissions { get; }
public Dictionary<string, bool> Visibility { get; }
public int[] TagIds { get; }
public UserMigrationHelper(DataRow row)
{
UserName = Convert.ToString(row["UserName"]);
DisplayName = Convert.ToString(row["DisplayName"]);
Password = Convert.ToString(row["Password"]);
Permissions = GetPermissionsFromString(Convert.ToString(row["IUIItemPermissions"]));
Visibility = GetVisibilityFromString(Convert.ToString(row["IUIItemVisibility"]));
Role = Convert.ToInt16(row["Role"]);
LastModified = Convert.ToDateTime(row["LastModified"]);
LastModifiedBy = Convert.ToString(row["LastModifiedBy"]);
LocalOnly = Convert.ToBoolean(row["LocalOnly"]);
var tagObject = row["UserTags"];
if (!DBNull.Value.Equals(tagObject))
{
var tags = new List<int>(GetTags((byte[])row["UserTags"]).Distinct());
tags.Remove(0);
TagIds = tags.ToArray();
}
else
{
TagIds = new int[0];
}
}
private static Dictionary<string, short> GetPermissionsFromString(string sPermissions)
{
var lookup = new Dictionary<string, short>();
var tokens = sPermissions.Split(',');
foreach (var token in tokens)
{
var subtokens = token.Split('=');
if (2 != subtokens.Length) { continue; }
lookup[subtokens[0]] = Convert.ToInt16(subtokens[1]);
}
return lookup;
}
private static Dictionary<string, bool> GetVisibilityFromString(string sVisibilities)
{
var lookup = new Dictionary<string, bool>();
var tokens = sVisibilities.Split(',');
foreach (var token in tokens)
{
var subtokens = token.Split('=');
if (2 != subtokens.Length) { continue; }
lookup[subtokens[0]] = Convert.ToBoolean(Convert.ToInt32(subtokens[1]));
}
return lookup;
}
private static int[] GetTags(byte[] bytes)
{
if (!bytes.Any()) return new int[0];
var tags = new int[bytes.Length / sizeof(int)];
try
{
Buffer.BlockCopy(bytes, 0, tags, 0, bytes.Length);
return tags;
}
catch (Exception ex)
{
APILogger.Log(ex);
}
return new int[0];
}
// ReSharper disable once InconsistentNaming
public void Commit(Dictionary<string, long> IUIItemNameToID)
{
int id;
using (var cmd = DbOperations.GetCommand())
{
try
{
cmd.CommandText = "INSERT INTO [DataPROUsers] ([UserName],[DisplayName],[Password],[Role],[LastModified],[LastModifiedBy],[LocalOnly]) VALUES (@1,@2,@3,@4,@5,@6,@7)";
DbOperations.CreateParam(cmd, "@1", SqlDbType.NVarChar, UserName);
DbOperations.CreateParam(cmd, "@2", SqlDbType.NVarChar, DisplayName);
DbOperations.CreateParam(cmd, "@3", SqlDbType.NVarChar, Password);
DbOperations.CreateParam(cmd, "@4", SqlDbType.SmallInt, Role);
DbOperations.CreateParam(cmd, "@5", SqlDbType.DateTime, LastModified);
DbOperations.CreateParam(cmd, "@6", SqlDbType.NVarChar, LastModifiedBy);
DbOperations.CreateParam(cmd, "@7", SqlDbType.Bit, LocalOnly);
//DbOperations.Connection.ExecuteCommand(cmd);
if (DbOperations._usingMSSQL)
{
DbOperations.Connection.ExecuteCommand(cmd);
}
else
{
DbOperations.Connection.ExecuteSQLiteCommand(cmd);
}
using (var nestedCmd = DbOperations.GetCommand())
{
try
{
nestedCmd.CommandText = "SELECT [ID] FROM [DataPROUsers] WHERE [UserName]=@1";
DbOperations.CreateParam(nestedCmd, "@1", SqlDbType.NVarChar, UserName);
using (var ds = DbOperations.Connection.QueryDataSet(nestedCmd))
{
var dr = ds.Tables[0].Rows[0];
id = Convert.ToInt32(dr["ID"]);
}
}
finally
{
nestedCmd.Connection.Dispose();
}
}
}
finally
{
cmd.Connection.Dispose();
}
}
if (Permissions.Any())
{
IDbCommand cmd = null;
StringBuilder sb = null;
var i = 0;
using (var e = Permissions.GetEnumerator())
{
while (e.MoveNext())
{
if (null == cmd)
{
cmd = DbOperations.GetCommand();
sb = new StringBuilder();
sb.Append(DbOperations.BEGIN_STATEMENT);
}
var permission = e.Current.Value;
var visible = !Visibility.ContainsKey(e.Current.Key) || Visibility[e.Current.Key];
sb.AppendFormat(
"INSERT INTO UserUIItemSettings (UserID, UIItemID, Permission, Visible) VALUES (@{0}_1, @{0}_2, @{0}_3, @{0}_4);",
i);
DbOperations.CreateParam(cmd, string.Format("@{0}_1", i), SqlDbType.Int, id);
DbOperations.CreateParam(cmd, string.Format("@{0}_2", i), SqlDbType.BigInt,
IUIItemNameToID[e.Current.Key]);
DbOperations.CreateParam(cmd, string.Format("@{0}_3", i), SqlDbType.SmallInt, permission);
DbOperations.CreateParam(cmd, string.Format("@{0}_4", i), SqlDbType.BigInt, visible);
if (0 == i % 25 && 0 != i)
{
sb.Append(DbOperations.COMMIT_STATEMENT);
cmd.CommandText = sb.ToString();
//DbOperations.Connection.ExecuteCommand(cmd);
if (DbOperations._usingMSSQL)
{
DbOperations.Connection.ExecuteCommand(cmd);
}
else
{
DbOperations.Connection.ExecuteSQLiteCommand(cmd);
}
cmd.Connection.Dispose();
cmd.Dispose();
sb = null;
cmd = null;
}
i++;
}
}
if (null != cmd)
{
sb.Append(DbOperations.COMMIT_STATEMENT);
cmd.CommandText = sb.ToString();
//DbOperations.Connection.ExecuteCommand(cmd);
if (DbOperations._usingMSSQL)
{
DbOperations.Connection.ExecuteCommand(cmd);
}
else
{
DbOperations.Connection.ExecuteSQLiteCommand(cmd);
}
cmd.Connection.Dispose();
cmd.Dispose();
}
}
// ReSharper disable once InvertIf
if (TagIds.Any())
{
IDbCommand cmd = null;
StringBuilder sb = null;
var i = 0;
foreach (var tag in TagIds)
{
if (null == cmd)
{
cmd = DbOperations.GetSQLCommand();
sb = new StringBuilder();
sb.Append(DbOperations.BEGIN_STATEMENT);
}
sb.Append(string.Format("INSERT INTO [TagAssignments] ([ObjectID],[ObjectType],[TagID]) VALUES (@{0}_1,@{0}_2,@{0}_3);", i));
DbOperations.CreateParam(cmd, string.Format("@{0}_1", i), SqlDbType.Int, id);
DbOperations.CreateParam(cmd, string.Format("@{0}_2", i), SqlDbType.SmallInt, 0);
DbOperations.CreateParam(cmd, string.Format("@{0}_3", i), SqlDbType.Int, tag);
i++;
}
if (null == sb)
{
return;
}
sb.Append(DbOperations.COMMIT_STATEMENT);
cmd.CommandText = sb.ToString();
//DbOperations.Connection.ExecuteCommand(cmd);
if (DbOperations._usingMSSQL)
{
DbOperations.Connection.ExecuteCommand(cmd);
}
else
{
DbOperations.Connection.ExecuteSQLiteCommand(cmd);
}
cmd.Connection.Dispose();
}
}
}
}

View File

@@ -0,0 +1,7 @@
rem this file resets the admin password for datapro
rem the basic format to connect and run the command is as follows
rem sqlcmd -S ComputerName\InstanceName -U UserName -P Password -i ResetAdmin.sql -o SQL.log
rem if using NT authentication user name and password is unnecessary
rem adjust the server name, instance name, or database name in resetadmin.sql as needed
sqlcmd -S (localdb)\DataPROInstance -i ResetAdmin.sql -o "SQL.log"

View File

@@ -0,0 +1,6 @@
USE master
GO
sp_attach_db 'ISO', 'C:\DataPRO_SQL\ISO.mdf'
GO

View File

@@ -0,0 +1,16 @@
namespace Storage.Classes.Abstract
{
public abstract class DbVersions
{
public enum DbVersionFields
{
Version,
Step,
Date,
Remarks,
UserField
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,425 @@
namespace DTS.Common.Storage
{
public partial class DbOperations
{
public abstract class DigitalInputSettings
{
public const string Table = "tblDigitalInputSetting";
public enum Fields
{
SettingName,
SettingMode,
ScaleMultiplier,
LastModified,
LastModifiedBy,
SensorId,
UserValue1,
UserValue2,
UserValue3,
UserTags,
eId,
MeasurementUnit,
FilterClass,
ISOCode,
ISOChannelName,
UserCode,
UserChannelName,
Broken, //new in 2.0
DoNotUse //new in 2.0
}
}
public abstract class VersionTable
{
public enum Fields
{
Version,
Step,
Date,
Remarks,
UserField
}
public const string TableName = "tblDataPRODbVersion";
}
public abstract class DAS
{
public const string Table = "tblDAS";
public enum Fields
{
SerialNumber,
Type,
MaxModules,
MaxMemory,
MaxSampleRate,
MinSampleRate,
FirmwareVersion,
CalDate,
ProtocolVersion,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
LastUsed,
LastUsedBy,
Connection,
Channels,
Position,
ChannelTypes,
Reprogramable,
Reconfigurable,
IsModule,
PositionOnDistributor,
PositionOnChain,
Port,
ParentDAS,
DASId,
FirstUseDate,
StandIn,
MaxAAFRate,
TestId,
GroupId
}
public const string TableDASChannels = "tblDASChannels";
public enum DASChannelFields
{
HardwareId,
ChannelIdx,
SupportedBridges,
SupportedExcitations,
DASDisplayOrder,
LocalOnly,
SupportedDigitalInputModes,
SupportedSquibFireModes,
SupportedDigitalOutputModes,
ModuleSerialNumber,
ModuleArrayIndex
}
public const string SLICE1_PROTOTYPE = "SLICE1 Prototype";
public const string SLICEPRO_PROTOTYPE = "SLICEPRO Prototype";
public const string PROTOTYPE_POSITION = "Prototype";
public const string SLICE1_5PROTOTYPE = "SLICE+ Prototype";
public const string G5_VDSPROTOTYPE = "G5 VDS Prototype";
public const string G5_IPORTPROTOTYPE = "G5 iPort Prototype";
public const string TDASPRO_8MRack = "TDASPro Rack 8M Prototype";
public const string TDASPRO_4MRack = "TDASPRO Rack 4M Prototype";
public const string ECM_PROTOTYPE = "SLICE ECM Prototype";
public const string SPM_PROTOTYPE = "SLICE Mini Distributor Prototype";
public const string SLE_PROTOTYPE = "SLICE PRO Lab Ethernet Prototype";
public const string SDB_PROTOTYPE = "SLICE Distributor Prototype";
public const string Slice_NanoPROTOTYPE = "SLICE Nano Prototype";
public const string Slice_MicroPROTOTYPE = "SLICE Micro Prototype";
public const string SLICEPRODIM_PROTOTYPE = "SLICE Pro DIM";
public const string SLICEPROSLD_PROTOTYPE = "SLICE PRO Lab DIM";
public const string SLICEPROTOM_PROTOTYPE = "SLICE Pro TOM";
public const string SLICEPROSLT_PROTOTYPE = "SLICE PRO Lab TOM";
public const string SLICEPROSIM_PROTOTYPE = "SLICE Pro SIM";
public const string SLICEPROSLS_PROTOTYPE = "SLICE PRO Lab SIM";
public const string SLICE1_5_MicroPROTOTYPE = "SLICE MICRO BASE+ Prototype";
public const string G5_INDUMMYPROTOTYPE = "G5 InDummy Prototype";
public const string SG5_PROTOTYPE = "SLICE G5 Prototype";
public const string TDASPRO_LabRack = "TDAS PRO Lab Rack";
public const string SLICE6_PROTOTYPE = "SLICE6 Prototype";
public const string SLICE6_AIR_PROTOTYPE = "SLICE6 AIR Prototype";
public const string SLICE6_AIR_ER_PROTOTYPE = "SLICE6 AIR ER Prototype";
public const string SLICE6_AIR_BR_PROTOTYPE = "SLICE6 Falcon Prototype";
public const string SLICE6DB_PROTOTYPE = "SLICE6Db Prototype";
public const string SLICE6DB3_PROTOTYPE = "SLICE6Db3 Prototype";
public const string SLICE6DB_AIR_PROTOTYPE = "SLICE6Db AIR Prototype";
public const string SLICE6DB_INDUMMY_PROTOTYPE = "SLICE6Db InDummy Prototype";
public const string POWERPRO_PROTOTYPE = "PowerPRO Prototype";
public const string TSR_AIR_PROTOTYPE = "TSR Air Prototype";
public const string TSR_AIR_REVB_PROTOTYPE = "TSR Air RevB Prototype";
public const string DIR_PROTOTYPE = "DIR Prototype";
public const string DKR_PROTOTYPE = "DKR Prototype";
public const string EMB_LIN_ACC_LO_MODULE_PROTOTYPE = "EMB LIN ACC LO Module Prototype";
public const string EMB_LIN_ACC_HI_MODULE_PROTOTYPE = "EMB LIN ACC HI Module Prototype";
public const string EMB_ARS_MODULE_PROTOTYPE = "EMB ARS Module Prototype";
public const string EMB_ATM_MODULE_PROTOTYPE = "EMB ATM Module Prototype";
public const string SLICEPRO_DB_PROTOTYPE = "SLICE Pro Distributor Prototype";
public const string SLICE_TC_PROTOTYPE = "SLICE TC Prototype";
public const string SLICE_PRO_CAN_FD_PROTOTYPE = "SLICE PRO CAN FD Prototype";
}
public abstract class TestObjectChannelSettings
{
public const string TableName = "tblTestObjectChannelSettings";
public enum Fields
{
TestObjectSerial,
ChannelId,
Setting,
SensorSerial,
SerialNumber
}
}
public abstract class DigitalOutputSettings
{
public const string Table = "tblTOMDigitalChannels";
public enum Fields
{
ChannelDescription,
DelayMS,
DurationMS,
OutputMode,
LimitDuration,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
DurationMSFloat,
UserTags,
Broken, //new in 2.0
DoNotUse //new in 2.0
}
}
public abstract class Squib
{
public const string Table = "tblTOMSquibChannels";
public enum Fields
{
SerialNumber,
SquibDescription,
BypassCurrentFilter,
BypassVoltageFilter,
DelayMS,
DurationMS,
FireMode,
ISOCode,
ISOChannelName,
UserCode,
UserChannelName,
MeasurementType,
SquibOutputCurrent,
SquibToleranceLow,
SquibToleranceHigh,
LimitDuration,
ArticleId,
LocalOnly,
Version,
LastModified,
LastModifiedBy,
UserValue1,
UserValue2,
UserValue3,
UserTags,
Broken, //new in 2.0
DoNotUse, //new in 2.0
DefineDelayInTest // new in 2.3
}
}
public abstract class UartIOSettings
{
public const string Table = "tblUartIOSettings";
public enum Fields
{
SerialNumber,
Description,
BaudRate,
DataBits,
StopBits,
Parity,
FlowControl,
DataFormat,
LastModified,
LastModifiedBy,
UserTags,
Broken,
DoNotUse
}
}
public abstract class StreamOutputSettings
{
public const string Table = "tblStreamOutputSettings";
public enum Fields
{
SerialNumber,
Description,
StreamProfile,
UDPAddress,
TimeChannelId,
DataChannelId,
TmNSConfig,
IRIGTimeDataPacketIntervalMs,
LastModified,
LastModifiedBy,
UserTags,
Broken,
DoNotUse
}
}
public abstract class CalculatedChannels
{
public const string Table = "tblCalculatedChannels";
public enum Fields
{
[DbTypeAttr("INTEGER PRIMARY KEY NOT NULL")]
Id,
[DbTypeAttr("INTEGER")]
Operation,
[DbTypeAttr("NVARCHAR(255)")]
CalculatedChannelValueCode,
[DbTypeAttr("BLOB")]
InputChannelIds,
[DbTypeAttr("NVARCHAR(255)")]
CFCForInputChannels,
[DbTypeAttr("NVARCHAR(255)")]
CFCForOutput,
[DbTypeAttr("NVARCHAR(255)")]
TestSetupName,
[DbTypeAttr("NVARCHAR(255)")]
CCName,
[DbTypeAttr("Bit")]
ViewInRealtime,
[DbTypeAttr("Int")]
ClipLength
}
}
public abstract class LevelTriggers
{
public const string Table = "tblLevelTriggers";
public enum Fields
{
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
TestSetupName,
[DbTypeAttr("BIGINT NOT NULL")]
ChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
GroupName,
//[DbTypeAttr("NVARCHAR(255) NOT NULL")]
//TestObjectChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
HardwareChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
SensorSerialNumber,
[DbTypeAttr("BIT NOT NULL")]
GreaterThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
GreaterThanEU,
[DbTypeAttr("BIT NOT NULL")]
LessThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
LessThanEU,
[DbTypeAttr("FLOAT NULL")]
InsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
InsideLowerEU,
[DbTypeAttr("FLOAT NULL")]
OutsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
OutsideLowerEU,
[DbTypeAttr("BIT NULL")]
InsideEnabled, //TriggerInside,
[DbTypeAttr("BIT NULL")]
OutsideEnabled, //TriggerOutside,
//[DbTypeAttr("NVARCHAR(255) NOT NULL")]
//TestObjectName
};
}
public abstract class Tags
{
public const string Table = "tblTags";
public enum TagFields
{
TagId,
TagText,
Obsolete
}
public const string TAGASSIGNMENTS_TABLE = "TagAssignments";
public enum TagAssignmentFields
{
ObjectID,
ObjectType,
TagID
}
}
public abstract class DbVersions
{
public enum DbVersionFields
{
Version,
Step,
Date,
Remarks,
UserField
}
}
public abstract class Settings
{
public const string Table = "tblSettings";
public enum UserFields
{
PropertyId,
PropertyType,
PropertyValue,
UserId
}
}
public abstract class MMEPossibleChannels
{
public const string Table = "tblMMEPossibleChannels";
}
public abstract class LabratoryDetails
{
public const string Table = "tblLabratoryDetails";
public enum LabratoryDetailsFields
{
Name,
LabratoryName,
LabratoryContactName,
LabratoryContactPhone,
LabratoryContactFax,
LabratoryContactEmail,
LabratoryTestRefNumber,
LabratoryProjectRefNumber,
LastModified,
LastModifiedBy,
LocalOnly,
Version
}
}
/// <summary>
/// tables and fields for user objects
/// </summary>
public abstract class Users
{
public const string USERS_TABLE = "DataPROUsers";
public enum UserFields
{
ID,
UserName,
DisplayName,
Password,
Role,
LastModified,
LastModifiedBy,
LocalOnly
}
public const string UIITEMS_TABLE = "UIITEMS";
public enum UIItemFields
{
ID,
Name
}
public const string USERUISETTINGS_TABLE = "UserUIItemSettings";
public enum UserUIItemSettingFields
{
UserId,
UIItemID,
Permission,
Visible
}
}
}
}

View File

@@ -0,0 +1,6 @@
rem sqlcmd -E -S (localdb)\DataPROInstance -Q "ALTER DATABASE [%1] SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
rem sqlcmd -E -S (localdb)\DataPROInstance -Q "sp_Detach_db %1"
%4 -E -S (localdb)\DataPROInstance -Q "CREATE DATABASE [%1] ON ( FILENAME = '%~2'), ( FILENAME = '%~3' ) FOR ATTACH"
%4 -E -S (localdb)\DataPROInstance -Q "sp_configure 'clr enabled', 1"
%4 -E -S (localdb)\DataPROInstance -Q "RECONFIGURE"

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Attach_DataPROPre20_RemoteDB.sql" -v DBNAME=%3

View File

@@ -0,0 +1,6 @@
USE master
GO
sp_attach_db '$(DBNAME)Pre20', 'C:\DataPRO_SQL\$(DBNAME)Pre20.mdf'
GO

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Attach_DataPRO_RemoteDB.sql" -v DBNAME=%3

View File

@@ -0,0 +1,6 @@
USE master
GO
sp_attach_db '$(DBNAME)', 'C:\DataPRO_SQL\$(DBNAME).mdf'
GO

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Attach_ISO_RemoteDB.sql"

View File

@@ -0,0 +1,6 @@
USE master
GO
sp_attach_db 'ISO', 'C:\DataPRO_SQL\ISO.mdf'
GO

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Backup_Alter_Detach_RemoteDBs.sql" -v DBNAME=%3

View File

@@ -0,0 +1,14 @@
USE master
GO
BACKUP DATABASE $(DBNAME) TO DISK='C:\DataPRO_SQL\$(DBNAME)Backup.bak'
GO
ALTER DATABASE $(DBNAME) SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
sp_Detach_db '$(DBNAME)', FALSE, TRUE
GO
ALTER DATABASE ISO SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
sp_Detach_db ISO, FALSE, TRUE
GO

View File

@@ -0,0 +1,3 @@
%4 -S %1 -i "C:\DTS\DTS.Suite\%2\DataPRO\SQL Server Scripts\Backup_RemoteDB.sql" -v DBNAME=%3

View File

@@ -0,0 +1,7 @@
USE master
GO
BACKUP DATABASE $(DBNAME) TO DISK='C:\DataPRO_SQL\$(DBNAME)Backup.bak'
GO

View File

@@ -0,0 +1,26 @@
namespace DTS.Storage
{
public abstract class CalculatedChannels
{
public const string Table = "tblCalculatedChannels";
public enum Fields
{
[DbTypeAttr("INTEGER PRIMARY KEY NOT NULL")]
Id,
[DbTypeAttr("INTEGER")]
Operation,
[DbTypeAttr("NVARCHAR(255)")]
CalculatedChannelValueCode,
[DbTypeAttr("BLOB")]
InputChannelIds,
[DbTypeAttr("NVARCHAR(255)")]
CFCForInputChannels,
[DbTypeAttr("NVARCHAR(255)")]
CFCForOutput,
[DbTypeAttr("NVARCHAR(255)")]
TestSetupName,
[DbTypeAttr("NVARCHAR(255)")]
CCName
}
}
}

View File

@@ -0,0 +1,16 @@
namespace Storage.Classes.Abstract
{
public abstract class DbVersions
{
public enum DbVersionFields
{
Version,
Step,
Date,
Remarks,
UserField
}
}
}

View File

@@ -0,0 +1,22 @@
namespace DTS.Storage
{
public abstract class DigitalOutputSettings
{
public const string Table = "tblTOMDigitalChannels";
public enum Fields
{
ChannelDescription,
DelayMS,
DurationMS,
OutputMode,
LimitDuration,
LastModified,
LastModifiedBy,
Version,
LocalOnly,
DurationMSFloat,
UserTags
}
}
}

View File

@@ -0,0 +1,22 @@
namespace DTS.Storage
{
public abstract class LabratoryDetails
{
public const string Table = "tblLabratoryDetails";
public enum LabratoryDetailsFields
{
Name,
LabratoryName,
LabratoryContactName,
LabratoryContactPhone,
LabratoryContactFax,
LabratoryContactEmail,
LabratoryTestRefNumber,
LabratoryProjectRefNumber,
LastModified,
LastModifiedBy,
LocalOnly,
Version
}
}
}

View File

@@ -0,0 +1,41 @@
namespace DTS.Storage
{
public abstract class LevelTriggers
{
public const string Table = "tblLevelTriggers";
public enum Fields
{
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
TestSetupName,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
GroupSerialNumber,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
TestObjectChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
HardwareChannelId,
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
SensorSerialNumber,
[DbTypeAttr("BIT NOT NULL")]
GreaterThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
GreaterThanEU,
[DbTypeAttr("BIT NOT NULL")]
LessThanEnabled,
[DbTypeAttr("FLOAT NOT NULL")]
LessThanEU,
[DbTypeAttr("FLOAT NULL")]
InsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
InsideLowerEU,
[DbTypeAttr("FLOAT NULL")]
OutsideUpperEU,
[DbTypeAttr("FLOAT NULL")]
OutsideLowerEU,
[DbTypeAttr("BIT NULL")]
TriggerInside,
[DbTypeAttr("BIT NULL")]
TriggerOutside
};
}
}

View File

@@ -0,0 +1,7 @@
namespace DTS.Storage
{
public abstract class MMEPossibleChannels
{
public const string Table = "tblMMEPossibleChannels";
}
}

View File

@@ -0,0 +1,118 @@
namespace DTS.Storage
{
public abstract class SensorDB
{
public const string SensorCalibrationTable = "tblSensorCalibrations";
public const string SensorDataTable = "tblSensors";
public const string SensorModelsTable = "tblSensorModels";
public enum SensorDataFields
{
SerialNumber = 1,
UserSerialNumber,
Model,
Manufacturer,
Status,
MeasurementUnit,
OffsetToleranceLow,
OffsetToleranceHigh,
Id,
Capacity,
Comment,
BridgeType,
BridgeLegMode,
Shunt,
Invert,
UserValue1,
UserValue2,
UserValue3,
FilterClass,
BridgeResistance,
IsoCode,
CheckOffset,
SupportedExcitation,
InitialEU,
CalInterval,
CalibrationSignal,
InternalShuntResistance,
ExternalShuntResistance,
UniPolar,
RangeLow,
RangeAve,
RangeHigh,
Created,
TimesUsed,
SensorCategory,
BypassFilter,
CouplingMode,
Version,
LastModified,
ModifiedBy,
LocalOnly,
AxisNumber,
NumberOfAxes,
UserTags,
DoNotUse,
Broken
}
public enum SensorModelFields
{
Model,
Manufacturer,
UserPartNumber,
Capacity,
OffsetToleranceLow,
OffsetToleranceHigh,
MeasurementUnit,
Bridge,
Shunt,
BridgeResistance,
FilterClass,
UniPolar,
IgnoreRange,
CouplingMode,
Version,
RangeLow,
RangeAve,
RangeHigh,
LastModified,
ModifiedBy,
LocalOnly,
NumberOfAxes,
CalInterval,
AxisNumber,
Polarity,
Invert,
CheckOffset,
CalibrationRecord,
ISOCode,
SupportedExcitation
}
public enum SensorCalibrationFields
{
SerialNumber,
CalibrationDate,
Username,
LocalOnly,
NonLinear,
CalibrationRecords,
ModifyDate,
IsProportional,
RemoveOffset,
ZeroMethod,
CertificationDocuments,
InitialOffset
}
public enum SensorCalibrationRecordFields
{
Sensitivity,
Poly,
AtCapacity,
EngineeringUnits,
Excitation,
CapacityOutputIsBasedOn,
SensitivityUnits
}
}
}

View File

@@ -0,0 +1,16 @@
namespace DTS.Storage
{
public abstract class Settings
{
public const string Table = "tblSettings";
public enum UserFields
{
PropertyId,
PropertyType,
PropertyValue,
UserId
}
}
}

View File

@@ -0,0 +1,32 @@
namespace DTS.Storage
{
public abstract class Squib
{
public const string Table = "tblTOMSquibChannels";
public enum Fields
{
SquibDescription,
BypassCurrentFilter,
BypassVoltageFilter,
DelayMS,
DurationMS,
FireMode,
ISOCode,
MeasurementType,
SquibOutputCurrent,
SquibToleranceLow,
SquibToleranceHigh,
LimitDuration,
ArticleId,
LocalOnly,
Version,
LastModified,
LastModifiedBy,
UserValue1,
UserValue2,
UserValue3,
UserTags
}
}
}

View File

@@ -0,0 +1,21 @@
namespace DTS.Storage
{
public abstract class Tags
{
public const string Table = "tblTags";
public enum TagFields
{
TagId,
TagText,
Obsolete
}
public const string TAGASSIGNMENTS_TABLE = "TagAssignments";
public enum TagAssignmentFields
{
ObjectID,
ObjectType,
TagID
}
}
}

View File

@@ -0,0 +1,15 @@
namespace DTS.Storage
{
public abstract class TestObjectChannelSettings
{
public const string TableName = "tblTestObjectChannelSettings";
public enum Fields
{
TestObjectSerial,
ChannelId,
Setting,
SensorSerial
}
}
}

View File

@@ -0,0 +1,157 @@
namespace DTS.Storage
{
public abstract class TestSetups
{
public const string HardwareTable = "tblTestSetupHardware";
public enum HardwareFields
{
TestSetupName,
HardwareId,
AddOrRemove //0=remove,1=add
}
public const string DASSettingsTable = "tblTestSetupDASSettings";
public const string ChannelSettingsTable = "tblTestChannelSettings";
public enum ChannelSettingFields
{
TestName,
TestObjectName,
ChannelId,
Setting,
SensorSerial
}
public const string TestSetupsTable = "tblTestSetups";
public enum Fields
{
SetupName,
SetupDescription,
AutomaticTestProgression,
AutomaticProgressionDelayMS,
InvertTrigger,
InvertStart,
ViewDiagnostics,
VerifyChannels,
AutoVerifyChannels,
VerifyChannelsDelayMS,
RecordingMode,
SamplesPerSecond,
PreTriggerSeconds,
PostTriggerSeconds,
StrictDiagnostics,
RequireConfirmationOnErrors,
ROIDownload,
ViewROIDownload,
DownloadAll,
ViewRealtime,
RealtimePlotCount,
ROIStart,
ROIEnd,
ViewDownloadAll,
Export,
ExportFormat,
LabDetails,
UseLabDetails,
CustomerDetails,
UseCustomerDetails,
AllowMissingSensors,
AllowSensorIdToBlankChannel,
LocalOnly,
LastModified,
LastModifiedBy,
TurnOffExcitation,
TriggerCheckRealtime,
TriggerCheckStep,
PostTestDiagnostics,
ExportFolder,
DownloadFolder,
CommonStatusLine,
SameAsDownloadFolder,
UploadData,
UploadDataFolder,
Settings,
WarnOnBatteryFail,
Dirty,
Complete,
ErrorMessage,
TestEngineerDetails,
UseTestEngineerDetails,
UserTags,
DoAutoArm,
CheckoutMode,
QuitTestWithoutWarning,
SuppressMissingSensorsWarning,
ISFFile,
NotAllChannelsRealTime,
NotAllChannelsViewer
}
public const string TestSetupObjectsTable = "tblTestSetupObjects";
public enum TestSetupObjectFields
{
TestObjectSerialNumber,
TestSetupName,
TargetSampleRate,
ExcitationWarmupTimeMS,
LocalOnly,
TestObjectType,
TestObjectPosition
}
public const string TestObjectMetaDataTable = "tblTestSetupObjectMetaData";
public enum TestObjectMetaDataFields
{
TestObject,
SetupName,
PropName,
PropValue,
Optional,
Version
}
public const string TestObjectTemplatesTable = "tblTestObjectTemplates";
public enum TestObjectTemplatesFields
{
TemplateName,
Icon,
Description,
LocalOnly,
Version,
LastModifiedBy,
CRC32,
TestObject,
LastModified,
ParentTemplate,
SysBuilt
}
public const string TestObjectsTable = "tblTestObjects";
public enum TestObjectsFields
{
SerialNumber,
LastModifiedBy,
LastModified,
Template,
LocalOnly,
ParentObject,
SysBuilt,
Embedded,
OriginalTemplate,
OriginalSerialNumber
}
public const string TestGraphsTable = "tblTestGraphs";
public enum GraphFields
{
GraphName,
GraphDescription,
TemplateName,
Channels,
UseDomainMin,
DomainMin,
UseDomainMax,
DomainMax,
UseRangeMin,
RangeMin,
UseRangeMax,
RangeMax,
Thresholds,
LocalOnly
}
}
}

View File

@@ -0,0 +1,38 @@
namespace DTS.Storage
{
/// <summary>
/// tables and fields for user objects
/// </summary>
public abstract class Users
{
public const string USERS_TABLE = "DataPROUsers";
public enum UserFields
{
ID,
UserName,
DisplayName,
Password,
Role,
LastModified,
LastModifiedBy,
LocalOnly
}
public const string UIITEMS_TABLE = "UIITEMS";
public enum UIItemFields
{
ID,
Name
}
public const string USERUISETTINGS_TABLE = "UserUIItemSettings";
public enum UserUIItemSettingFields
{
UserId,
UIItemID,
Permission,
Visible
}
}
}

Some files were not shown because too many files have changed in this diff Show More