Initial population

This commit is contained in:
Jon
2026-03-07 19:38:21 -06:00
commit 46735bddd3
59 changed files with 12911 additions and 0 deletions

370
clsInstrumentation.vb Normal file
View File

@@ -0,0 +1,370 @@
Imports System.Data
Imports System.Xml
Public Class clsInstrumentation
Implements ICloneable
Private mguidInstrumentationID As Guid
Private mstrInstrumentationName As String
Private m_blnObjectAlreadyPersisted As Boolean
Public Sub New()
mguidInstrumentationID = Guid.NewGuid
mstrInstrumentationName = ""
m_blnObjectAlreadyPersisted = False
End Sub
Public Sub New(ByVal lstrInstrumentationName As String)
Dim ldbcmdCommand As New SqlClient.SqlCommand
ldbcmdCommand.CommandText = "sel_instrumentation_by_name"
ldbcmdCommand.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmInstrumentationName As New SqlClient.SqlParameter
prmInstrumentationName.ParameterName = "@instrumentation_name"
prmInstrumentationName.SqlDbType = SqlDbType.VarChar
prmInstrumentationName.Size = MyGlobals.INSTRUMENTATION_NAME_SIZE
prmInstrumentationName.Value = lstrInstrumentationName
ldbcmdCommand.Parameters.Add(prmInstrumentationName)
Dim ldbdsInstrumentations As DataSet = MyGlobals.g_objDatabaseLayer.ExecuteDataSet(ldbcmdCommand)
If ldbdsInstrumentations.Tables(0).Rows.Count > 0 Then
Dim ldbrwRow As DataRow
ldbrwRow = ldbdsInstrumentations.Tables(0).Rows(0)
PopulateFromDBRow(ldbrwRow)
ldbdsInstrumentations.Clear()
m_blnObjectAlreadyPersisted = True
Else
ldbdsInstrumentations.Clear()
mguidInstrumentationID = Guid.NewGuid
mstrInstrumentationName = lstrInstrumentationName.Trim
m_blnObjectAlreadyPersisted = False
End If
End Sub
Public Sub New(ByVal lguidInstrumentationID As Guid)
mguidInstrumentationID = lguidInstrumentationID
Dim ldbcmdCommand As New SqlClient.SqlCommand
ldbcmdCommand.CommandText = "sel_instrumentation"
ldbcmdCommand.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmInstrumentationID As New SqlClient.SqlParameter
prmInstrumentationID.ParameterName = "@instrumentation_id"
prmInstrumentationID.SqlDbType = SqlDbType.UniqueIdentifier
'prmInstrumentationID.Size = 5
prmInstrumentationID.Value = lguidInstrumentationID
ldbcmdCommand.Parameters.Add(prmInstrumentationID)
Dim ldbdsInstrumentations As DataSet = MyGlobals.g_objDatabaseLayer.ExecuteDataSet(ldbcmdCommand)
If ldbdsInstrumentations.Tables(0).Rows.Count > 0 Then
Dim ldbrwRow As DataRow
ldbrwRow = ldbdsInstrumentations.Tables(0).Rows(0)
PopulateFromDBRow(ldbrwRow)
m_blnObjectAlreadyPersisted = True
MyGlobals.AddCachedObject(Me, Me.InstrumentationID.ToString)
End If
ldbdsInstrumentations.Clear()
End Sub
Public Sub New(ByVal ldbrwRow As DataRow)
PopulateFromDBRow(ldbrwRow)
m_blnObjectAlreadyPersisted = True
MyGlobals.AddCachedObject(Me, Me.InstrumentationID.ToString)
End Sub
Private Sub PopulateFromDBRow(ByVal ldbrwRow As DataRow)
mguidInstrumentationID = CType(ldbrwRow.Item("instrumentation_id"), Guid)
mstrInstrumentationName = CType(ldbrwRow.Item("instrumentation_name"), String)
End Sub
Public Function Delete() As Boolean
Try
MyGlobals.RemoveCachedObject(Me.InstrumentationID.ToString)
Dim ldbcmdCommand As New SqlClient.SqlCommand
ldbcmdCommand.CommandText = "del_instrumentation"
ldbcmdCommand.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmInstrumentationID As New SqlClient.SqlParameter
prmInstrumentationID.ParameterName = "@instrumentation_id"
prmInstrumentationID.SqlDbType = SqlDbType.UniqueIdentifier
'prmInstrumentationID.Size = 5
prmInstrumentationID.Value = mguidInstrumentationID
ldbcmdCommand.Parameters.Add(prmInstrumentationID)
Dim lintRowsAffected As Integer = MyGlobals.g_objDatabaseLayer.ExecuteNonQuery(ldbcmdCommand)
If lintRowsAffected > 0 Then
m_blnObjectAlreadyPersisted = False
Return True
Else
Return False
End If
Catch
Return False
End Try
End Function
Public Function Save() As Boolean
Try
MyGlobals.AddCachedObject(Me, Me.InstrumentationID.ToString)
If m_blnObjectAlreadyPersisted Then
Dim ldbcmdCommand As New SqlClient.SqlCommand
ldbcmdCommand.CommandText = "upd_instrumentation"
ldbcmdCommand.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmInstrumentationID As New SqlClient.SqlParameter
prmInstrumentationID.ParameterName = "@instrumentation_id"
prmInstrumentationID.SqlDbType = SqlDbType.UniqueIdentifier
'prmInstrumentationID.Size = 5
prmInstrumentationID.Value = mguidInstrumentationID
ldbcmdCommand.Parameters.Add(prmInstrumentationID)
' Set up parameter for stored procedure
Dim prmInstrumentationName As New SqlClient.SqlParameter
prmInstrumentationName.ParameterName = "@instrumentation_name"
prmInstrumentationName.SqlDbType = SqlDbType.VarChar
prmInstrumentationName.Size = MyGlobals.INSTRUMENTATION_NAME_SIZE
prmInstrumentationName.Value = mstrInstrumentationName
ldbcmdCommand.Parameters.Add(prmInstrumentationName)
Dim lintRowsAffected As Integer = MyGlobals.g_objDatabaseLayer.ExecuteNonQuery(ldbcmdCommand)
If lintRowsAffected > 0 Then
Return True
Else
Return False
End If
Else
Dim ldbcmdCommand As New SqlClient.SqlCommand
ldbcmdCommand.CommandText = "ins_instrumentation"
ldbcmdCommand.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmInstrumentationID As New SqlClient.SqlParameter
prmInstrumentationID.ParameterName = "@instrumentation_id"
prmInstrumentationID.SqlDbType = SqlDbType.UniqueIdentifier
'prmInstrumentationID.Size = 5
prmInstrumentationID.Value = mguidInstrumentationID
ldbcmdCommand.Parameters.Add(prmInstrumentationID)
' Set up parameter for stored procedure
Dim prmInstrumentationName As New SqlClient.SqlParameter
prmInstrumentationName.ParameterName = "@instrumentation_name"
prmInstrumentationName.SqlDbType = SqlDbType.VarChar
prmInstrumentationName.Size = MyGlobals.INSTRUMENTATION_NAME_SIZE
prmInstrumentationName.Value = mstrInstrumentationName
ldbcmdCommand.Parameters.Add(prmInstrumentationName)
Dim lintRowsAffected As Integer = MyGlobals.g_objDatabaseLayer.ExecuteNonQuery(ldbcmdCommand)
If lintRowsAffected > 0 Then
m_blnObjectAlreadyPersisted = True
Return True
Else
Return False
End If
End If
Catch
Return False
End Try
End Function
Public Function DuplicateExists(ByVal lstrInstrumentationNameToCheck As String) As Boolean
Try
Dim ldbcmdCommand As New SqlClient.SqlCommand
ldbcmdCommand.CommandText = "sel_instrumentation_by_name"
ldbcmdCommand.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmInstrumentationName As New SqlClient.SqlParameter
prmInstrumentationName.ParameterName = "@instrumentation_name"
prmInstrumentationName.SqlDbType = SqlDbType.VarChar
prmInstrumentationName.Size = MyGlobals.INSTRUMENTATION_NAME_SIZE
prmInstrumentationName.Value = lstrInstrumentationNameToCheck
ldbcmdCommand.Parameters.Add(prmInstrumentationName)
Dim ldbdsInstrumentations As DataSet = MyGlobals.g_objDatabaseLayer.ExecuteDataSet(ldbcmdCommand)
If ldbdsInstrumentations.Tables(0).Rows.Count > 0 Then
Dim ldbrwRow As DataRow
For Each ldbrwRow In ldbdsInstrumentations.Tables(0).Rows
If mguidInstrumentationID.Equals(CType(ldbrwRow.Item("instrumentation_id"), Guid)) Then
'OK
Else
ldbdsInstrumentations.Clear()
Return True
End If
Next
End If
ldbdsInstrumentations.Clear()
Return False
Catch
Return False
End Try
End Function
Public Property InstrumentationID() As Guid
Get
Return mguidInstrumentationID
End Get
Set(ByVal lguidValue As Guid)
mguidInstrumentationID = lguidValue
End Set
End Property
Public Property InstrumentationName() As String
Get
Return mstrInstrumentationName
End Get
Set(ByVal sValue As String)
mstrInstrumentationName = sValue.Trim
End Set
End Property
Public Property ItemAlreadyPersisted() As Boolean
Get
Return m_blnObjectAlreadyPersisted
End Get
Set(ByVal Value As Boolean)
m_blnObjectAlreadyPersisted = Value
End Set
End Property
Public Function Clone() As Object Implements ICloneable.Clone
Dim lobjReturnValue As New clsInstrumentation
lobjReturnValue.InstrumentationID = Me.InstrumentationID
lobjReturnValue.InstrumentationName = Me.InstrumentationName
lobjReturnValue.ItemAlreadyPersisted = Me.ItemAlreadyPersisted
Return lobjReturnValue
End Function
Public Function StateIsIdentical(ByVal lobjOtherInstrumentation As clsInstrumentation) As Boolean
If Me.InstrumentationID.Equals(lobjOtherInstrumentation.InstrumentationID) _
AndAlso Me.InstrumentationName = lobjOtherInstrumentation.InstrumentationName Then
Return True
Else
Return False
End If
End Function
Public Function Validate(ByRef lstrErrorString As String) As Boolean
lstrErrorString = ""
If Me.InstrumentationName.Length = 0 Then
lstrErrorString = "Instrumentation Name is required"
Return False
End If
If Me.DuplicateExists(Me.InstrumentationName) Then
lstrErrorString = "Given Instrumentation Name already exists"
Return False
End If
Return True
End Function
Public Function OKToDelete(ByRef lstrReferencedByString As String) As Boolean
Dim lblnReturnValue As Boolean
lblnReturnValue = True
lstrReferencedByString = ""
Dim ldbcmdCommand As New SqlClient.SqlCommand
ldbcmdCommand.CommandText = "sel_instrumentation_isreferenced"
ldbcmdCommand.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmInstrumentationID As New SqlClient.SqlParameter
prmInstrumentationID.ParameterName = "@instrumentation_id"
prmInstrumentationID.SqlDbType = SqlDbType.UniqueIdentifier
'prmInstrumentationID.Size = 5
prmInstrumentationID.Value = mguidInstrumentationID
ldbcmdCommand.Parameters.Add(prmInstrumentationID)
Dim ldbdsInstrumentations As DataSet = MyGlobals.g_objDatabaseLayer.ExecuteDataSet(ldbcmdCommand)
If ldbdsInstrumentations.Tables(0).Rows.Count > 0 Then
lblnReturnValue = False
Dim ldbrwRow As DataRow
For Each ldbrwRow In ldbdsInstrumentations.Tables(0).Rows
If Not ldbrwRow.IsNull("table_referencing_instance") Then
If lstrReferencedByString.Length = 0 Then
lstrReferencedByString = CType(ldbrwRow.Item("table_referencing_instance"), String) + "(s)"
Else
lstrReferencedByString = lstrReferencedByString + " and " + CType(ldbrwRow.Item("table_referencing_instance"), String) + "(s)"
End If
End If
Next
End If
ldbdsInstrumentations.Clear()
Return lblnReturnValue
End Function
Public Overrides Function ToString() As String
Return mstrInstrumentationName
End Function
Public Sub WriteXML(ByRef objXMLWriter As XmlTextWriter)
objXMLWriter.WriteStartElement("Instrumentation")
objXMLWriter.WriteElementString("InstrumentationID", Me.InstrumentationID.ToString)
objXMLWriter.WriteElementString("InstrumentationName", Me.InstrumentationName)
objXMLWriter.WriteEndElement()
End Sub
Public Shared Function GetAllInstrumentations() As System.Collections.Generic.List(Of clsInstrumentation)
Dim lguidInstrumentationID As Guid
Dim ldbcmdCommand As New SqlClient.SqlCommand
Dim lobjInstrumentation As clsInstrumentation
Dim lcolInstrumentations As New System.Collections.Generic.List(Of clsInstrumentation)
ldbcmdCommand.CommandText = "sel_instrumentation_all"
ldbcmdCommand.CommandType = CommandType.StoredProcedure
Dim ldbdsInstrumentations As DataSet = MyGlobals.g_objDatabaseLayer.ExecuteDataSet(ldbcmdCommand)
If ldbdsInstrumentations.Tables(0).Rows.Count > 0 Then
Dim ldbrwRow As DataRow
For Each ldbrwRow In ldbdsInstrumentations.Tables(0).Rows
lguidInstrumentationID = CType(ldbrwRow.Item("instrumentation_id"), Guid)
If MyGlobals.CachedObjectExists(lguidInstrumentationID.ToString) Then
lobjInstrumentation = CType(MyGlobals.CachedObjectRetrieve(lguidInstrumentationID.ToString), clsInstrumentation)
Else
'lobjInstrumentation = New clsInstrumentation(lguidInstrumentationID)
lobjInstrumentation = New clsInstrumentation(ldbrwRow)
End If
lcolInstrumentations.Add(lobjInstrumentation)
Next
End If
ldbdsInstrumentations.Clear()
Return lcolInstrumentations
End Function
Public Shared Sub AddAllInstrumentationsToCache()
If MyGlobals.g_objObjectTypesCached.Contains("Instrumentations") = False Then
GetAllInstrumentations()
MyGlobals.g_objObjectTypesCached.Add("Instrumentations")
End If
End Sub
End Class