Initial commit
This commit is contained in:
32
BMS/BMSDll/bms/AssemblyInfo.vb
Normal file
32
BMS/BMSDll/bms/AssemblyInfo.vb
Normal file
@@ -0,0 +1,32 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports 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.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("BMS Logging DLL")>
|
||||
<Assembly: AssemblyDescription("Writes journal entries to BMS database journal")>
|
||||
<Assembly: AssemblyCompany("Zubler & Partner")>
|
||||
<Assembly: AssemblyProduct("BMS Logging DLL")>
|
||||
<Assembly: AssemblyCopyright("")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
<Assembly: CLSCompliant(True)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("2BBEB51D-23B1-4418-A844-9471B78A910B")>
|
||||
|
||||
' 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.*")>
|
||||
111
BMS/BMSDll/bms/BMSDll.vbproj
Normal file
111
BMS/BMSDll/bms/BMSDll.vbproj
Normal file
@@ -0,0 +1,111 @@
|
||||
<VisualStudioProject>
|
||||
<VisualBasic
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{A3645B42-5328-4197-92A6-3124FE38AD0C}"
|
||||
SccProjectName = "SAK"
|
||||
SccLocalPath = "SAK"
|
||||
SccAuxPath = "SAK"
|
||||
SccProvider = "SAK"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "BMS"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
AssemblyOriginatorKeyMode = "None"
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "Library"
|
||||
OptionCompare = "Binary"
|
||||
OptionExplicit = "On"
|
||||
OptionStrict = "Off"
|
||||
RootNamespace = "bms"
|
||||
StartupObject = ""
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "true"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "true"
|
||||
IncrementalBuild = "true"
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "false"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "false"
|
||||
IncrementalBuild = "false"
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Common"
|
||||
Project = "{A1E2756A-4E32-40BB-B449-9BDA1C15DE84}"
|
||||
Package = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "DataAccess"
|
||||
Project = "{21B54F51-D2B2-459E-895C-540AD4A8704F}"
|
||||
Package = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"
|
||||
/>
|
||||
</References>
|
||||
<Imports>
|
||||
<Import Namespace = "Microsoft.VisualBasic" />
|
||||
<Import Namespace = "System" />
|
||||
<Import Namespace = "System.Collections" />
|
||||
<Import Namespace = "System.Data" />
|
||||
<Import Namespace = "System.Diagnostics" />
|
||||
</Imports>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Logging.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</VisualBasic>
|
||||
</VisualStudioProject>
|
||||
|
||||
10
BMS/BMSDll/bms/BMSDll.vbproj.vspscc
Normal file
10
BMS/BMSDll/bms/BMSDll.vbproj.vspscc
Normal file
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = "relative:bms"
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||
}
|
||||
185
BMS/BMSDll/bms/Logging.vb
Normal file
185
BMS/BMSDll/bms/Logging.vb
Normal file
@@ -0,0 +1,185 @@
|
||||
|
||||
#Region "Includes"
|
||||
|
||||
Imports System.Data.SqlClient
|
||||
Imports Common.Common
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
#End Region
|
||||
|
||||
'Class used 4 common Logging
|
||||
<ClassInterface(ClassInterfaceType.AutoDual)> _
|
||||
Public Class Logging
|
||||
|
||||
#Region "Members"
|
||||
|
||||
Dim m_JournalId As Integer
|
||||
Dim m_JobId As Integer
|
||||
Dim m_ProgrammId As Integer
|
||||
Dim m_DbConnection As SqlConnection
|
||||
Dim m_Common As Common.Common
|
||||
Dim m_JobTyp As JobType
|
||||
Dim m_IsNachLetzterAusfuerung As Boolean
|
||||
Dim m_RunJob As Boolean
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Constructor"
|
||||
|
||||
'Gets a new JournalId for a new logging instance
|
||||
'TODO: jobtype muss nicht bekannt sein, wenn ein tool als start UND watch läuft...
|
||||
'Wird aber benötigt, um LastRunEnde auf Job zu setzen. Dies wiederum wird in GetFailedStartJobs
|
||||
'verwendet um zu überprüfen, ob der JOB(und ebe nicht das programm) gestartet wurde
|
||||
Public Sub New(ByVal programId As Integer, ByVal jobType As JobType)
|
||||
Try
|
||||
Dim sqlCom As New SqlCommand
|
||||
Dim da As New SqlDataAdapter
|
||||
Dim ds As New DataSet
|
||||
|
||||
m_ProgrammId = programId
|
||||
m_Common = New Common.Common
|
||||
|
||||
m_DbConnection = New SqlConnection(m_Common.DSN)
|
||||
m_DbConnection.Open()
|
||||
|
||||
sqlCom.CommandType = CommandType.StoredProcedure
|
||||
sqlCom.Connection = m_DbConnection
|
||||
sqlCom.CommandText = "CreateJournal"
|
||||
|
||||
sqlCom.Parameters.Add(New SqlParameter("@ProgrammId", m_ProgrammId))
|
||||
sqlCom.Parameters.Add(New SqlParameter("@JobTypId", jobType))
|
||||
|
||||
da.SelectCommand = sqlCom
|
||||
da.Fill(ds)
|
||||
|
||||
'One table and one row are required
|
||||
If ds.Tables.Count > 0 Then
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
m_JournalId = ds.Tables(0).Rows(0).Item("JournalId")
|
||||
m_JobId = ds.Tables(0).Rows(0).Item("JobId")
|
||||
m_IsNachLetzterAusfuerung = ds.Tables(0).Rows(0).Item("NachLetzterAusfuerung")
|
||||
m_RunJob = ds.Tables(0).Rows(0)("RunJob")
|
||||
Else
|
||||
Throw New Exception("Neues Journal konnte nicht erzeugt werden oder zugehöriger Job wurde nicht gefunden")
|
||||
End If
|
||||
Else
|
||||
Throw New Exception("Neues Journal konnte nicht erzeugt werden oder zugehöriger Job wurde nicht gefunden")
|
||||
End If
|
||||
|
||||
If jobType = jobType.WatchJob Then
|
||||
'needed for validating correct start and maximal durations
|
||||
DataAccess.Job.SetJobLastRun(m_Common.DSN, m_JobId, LastRun.Start)
|
||||
m_Common.Log(m_Common.DLL_DISPLAY_NAME, "DLL Library setted LastRunStart to " + DateTime.Now.ToString("G") + " for JobId " + m_JobId.ToString)
|
||||
End If
|
||||
|
||||
|
||||
m_DbConnection.Close()
|
||||
|
||||
Catch ex As Exception
|
||||
If m_DbConnection.State = ConnectionState.Open Then
|
||||
m_DbConnection.Close()
|
||||
End If
|
||||
WriteEventLog(ex.Source, ex.Message, EventLogEntryType.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Public Methods"
|
||||
|
||||
'Note: This Sub is necessary, because VB cannot handle constructors with parameters
|
||||
'so we have to do all the "constuctor" stuff in a method...
|
||||
'Public Sub InitLogging(ByVal programId As Integer, ByVal jobTyp As Integer)
|
||||
'End Sub
|
||||
|
||||
'Writes a message with a journalEntryType to the journal
|
||||
Public Sub Log(ByVal message As String, ByVal journalEintragTyp As JournalEntryType)
|
||||
Try
|
||||
WriteJournalEntry(message, CType(journalEintragTyp, JournalEntryType))
|
||||
|
||||
'in an error case, service should do something
|
||||
If journalEintragTyp = JournalEntryType.Error Then
|
||||
Dim ds As New DataSet
|
||||
DataAccess.Job.GetNotifications(m_Common, m_ProgrammId, ds)
|
||||
DataAccess.Job.SendNotification(m_Common, m_ProgrammId, ds, message, m_JobId, JobType.WatchJob)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
WriteEventLog(ex.Source, ex.Message, EventLogEntryType.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Writes a message to the journal
|
||||
Public Sub Log(ByVal message As String)
|
||||
Try
|
||||
'MsgBox("adsf" / 10) force crash 4 debug
|
||||
Log(message, JournalEntryType.Information)
|
||||
Catch ex As Exception
|
||||
WriteEventLog(ex.Source, ex.Message, EventLogEntryType.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Writes to journal, that the program has started
|
||||
Public Sub Start()
|
||||
Try
|
||||
DataAccess.Job.SetIsRunning(m_Common.DSN, m_ProgrammId, True)
|
||||
WriteJournalEntry("Start", JournalEntryType.Information)
|
||||
Catch ex As Exception
|
||||
DataAccess.Job.SetIsRunning(m_Common.DSN, m_ProgrammId, False)
|
||||
WriteEventLog(ex.Source, ex.Message, EventLogEntryType.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Writes to journal, that the program has ended
|
||||
Public Sub Ende()
|
||||
Try
|
||||
DataAccess.Job.SetIsRunning(m_Common.DSN, m_ProgrammId, False)
|
||||
DataAccess.Job.SetJobLastRun(m_Common.DSN, m_JobId, LastRun.End)
|
||||
|
||||
'calc next start time JUST if its a "NachLetzterAusfuerung" Job
|
||||
If m_IsNachLetzterAusfuerung Then
|
||||
DataAccess.Job.SetNextExecDateTime(m_Common.DSN, m_JobId)
|
||||
End If
|
||||
WriteJournalEntry("Ende", JournalEntryType.Information)
|
||||
Catch ex As Exception
|
||||
WriteEventLog(ex.Source, ex.Message, EventLogEntryType.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Private Methods"
|
||||
|
||||
'Writes an nice formatted error message to windows eventlog
|
||||
Private Sub WriteEventLog(ByVal source As String, ByVal errorMessage As String, ByVal eventLogType As EventLogEntryType)
|
||||
m_Common.Log(source, "Quelle: " & source & Environment.NewLine & "Meldung: " & errorMessage, eventLogType)
|
||||
End Sub
|
||||
|
||||
'Writes an entry to the BMS journal
|
||||
Private Sub WriteJournalEntry(ByVal message As String, ByVal journalEntryType As JournalEntryType)
|
||||
Try
|
||||
Dim dr As SqlDataReader
|
||||
Dim sqlCom As New SqlCommand
|
||||
|
||||
m_DbConnection.Open()
|
||||
|
||||
sqlCom.CommandType = CommandType.StoredProcedure
|
||||
sqlCom.Connection = m_DbConnection
|
||||
sqlCom.CommandText = "CreateJournalEntry"
|
||||
|
||||
sqlCom.Parameters.Add(New SqlParameter("@JournalId", m_JournalId))
|
||||
sqlCom.Parameters.Add(New SqlParameter("@EintragDesc", message))
|
||||
sqlCom.Parameters.Add(New SqlParameter("@JournalEintragTypId", CInt(journalEntryType)))
|
||||
sqlCom.ExecuteNonQuery()
|
||||
|
||||
m_DbConnection.Close()
|
||||
Catch
|
||||
If m_DbConnection.State = ConnectionState.Open Then
|
||||
m_DbConnection.Close()
|
||||
End If
|
||||
Throw
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
5
BMS/BMSDll/bms/mssccprj.scc
Normal file
5
BMS/BMSDll/bms/mssccprj.scc
Normal file
@@ -0,0 +1,5 @@
|
||||
SCC = This is a Source Code Control file
|
||||
|
||||
[BMSDll.vbproj]
|
||||
SCC_Aux_Path = "\\SERVER01\DATEN\SourceSave\EDOKA4.0"
|
||||
SCC_Project_Name = "$/BMS/BMSDll/bms", FSCAAAAA
|
||||
BIN
BMS/BMSDll/bms/vssver.scc
Normal file
BIN
BMS/BMSDll/bms/vssver.scc
Normal file
Binary file not shown.
Reference in New Issue
Block a user