Initial commit

This commit is contained in:
2020-10-21 10:43:18 +02:00
commit 56bd02798f
5848 changed files with 2659025 additions and 0 deletions

View 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 Service")>
<Assembly: AssemblyDescription("Handles start and watch jobs over the BMS programs")>
<Assembly: AssemblyCompany("Zubler & Partner")>
<Assembly: AssemblyProduct("BMS Service")>
<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("45063487-0CB3-470D-B394-444EA2CEF66D")>
' 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.*")>

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used forserialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Assembly</value>
</data>
<data name="$this.Name">
<value>BMSService</value>
</data>
</root>

View File

@@ -0,0 +1,365 @@
#Region "Includes"
Imports System.ServiceProcess
Imports System.Data.SqlClient
Imports System.Xml
Imports Common.Common
#End Region
Public Class BMSService
Inherits System.ServiceProcess.ServiceBase
#Region "Members"
Private m_TimerStarter As System.Threading.Timer
Private m_TimerWatcher As System.Threading.Timer
Private m_EventLog As EventLog
Private m_StartJobs As DataSet
Private m_WatchJobs As DataSet
Private m_Common As Common.Common
#End Region
#Region " Component Designer generated code "
Public Sub New()
MyBase.New()
' This call is required by the Component Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call
End Sub
'UserService overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' The main entry point for the process
<MTAThread()> _
Shared Sub Main()
' Dim ServicesToRun() As System.ServiceProcess.ServiceBase
' More than one NT Service may run within the same process. To add
' another service to this process, change the following line to
' create a second service object. For example,
'
' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
'
' ServicesToRun = New System.ServiceProcess.ServiceBase() {New BMSService}
' System.ServiceProcess.ServiceBase.Run(ServicesToRun)
'-----------------
'DEBUG check don't work in windows service manager...
#If DEBUG Then
Dim service As New BMSService
service.StartService()
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite)
#Else
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
ServicesToRun = New System.ServiceProcess.ServiceBase() {New BMSService}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
#End If
End Sub
'Required by the Component Designer
Private components As System.ComponentModel.IContainer
' NOTE: The following procedure is required by the Component Designer
' It can be modified using the Component Designer.
' Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'BMSService
'
Me.ServiceName = "BMS Serivce"
End Sub
#End Region
#Region "Service Start / Stopp"
Protected Overrides Sub OnStart(ByVal args() As String)
StartService()
End Sub
Protected Overrides Sub OnStop()
End Sub
#End Region
#Region "Private Methods"
'Occures ever time the timer elapses
Sub TimeElapsedStarter(ByVal stateInfo As Object)
Try
'Load and execute starter Jobs
m_StartJobs.Clear()
DataAccess.Job.LoadJobs(m_Common, JobType.StartJob, m_StartJobs)
ExecuteStartJobs()
Catch ex As Exception
WriteEventLog("Fehler TimeElapsedStarter: " & ex.Message & Environment.NewLine & Environment.NewLine & ex.StackTrace, EventLogEntryType.Error)
End Try
End Sub
'Occures ever time the timer elapses
Sub TimeElapsedWatcher(ByVal stateInfo As Object)
Try
'Load and execute starter Jobs
m_WatchJobs.Clear()
DataAccess.Job.LoadJobs(m_Common, JobType.WatchJob, m_WatchJobs)
ExecuteWatchJobs()
Catch ex As Exception
WriteEventLog("Fehler TimeElapsedWatcher: " & ex.Message & Environment.NewLine & Environment.NewLine & ex.StackTrace, EventLogEntryType.Error)
End Try
End Sub
'Initializes all the service start stuff...
Private Sub StartService()
Try
m_EventLog = New EventLog
m_Common = New Common.Common
'Cannot use System.Timers.Timer due a Bug (http://support.microsoft.com/default.aspx?scid=kb;en-us;842793)
Dim autoEvent As New System.Threading.AutoResetEvent(False)
Dim timerStarterDelegate As System.Threading.TimerCallback = AddressOf TimeElapsedStarter
Dim timerWatcherDelegate As System.Threading.TimerCallback = AddressOf TimeElapsedWatcher
m_TimerStarter = New System.Threading.Timer(timerStarterDelegate, autoEvent, 1000, m_Common.StartJobInterval)
m_TimerWatcher = New System.Threading.Timer(timerWatcherDelegate, autoEvent, m_Common.WatchJobInterval, m_Common.WatchJobInterval)
m_StartJobs = New DataSet
m_WatchJobs = New DataSet
Catch ex As Exception
WriteEventLog("Fehler: " & ex.Message & Environment.NewLine & Environment.NewLine & ex.StackTrace, EventLogEntryType.Error)
End Try
End Sub
'Executes all watch jobs
Private Sub ExecuteWatchJobs()
Try
'Check if there are any jobs
If m_WatchJobs.Tables.Count > 0 And m_WatchJobs.Tables.Item(0).Rows.Count > 0 Then
Dim dt As DataTable
Dim dsFailedJobs As New DataSet
Dim startTime As New DateTime, endTime As New DateTime
Dim houres As Integer, minutes As Integer
dt = m_WatchJobs.Tables.Item(0)
Dim dr As DataRow
For Each dr In dt.Rows
'Check if job is in valid date range
If dr.Item("DatumStart") <= DateTime.Now And CType(dr.Item("DatumEnde"), Date).AddDays(1) >= DateTime.Now Then
ConvertToDateTime(dr.Item("ZeitVon"), dr.Item("ZeitBis"), startTime, endTime)
If startTime <= DateTime.Now And endTime >= DateTime.Now Then
'job seems to be in his valid datetime range...
Dim lastRunStart As DateTime
If dr("LastRunStart") Is DBNull.Value Then
'use dummy date if the job never run before
lastRunStart = New DateTime(1)
Else
lastRunStart = CDate(dr("LastRunStart"))
End If
'get all failed starter jobs
dsFailedJobs.Clear()
DataAccess.Job.GetFailedStartJobs(m_Common, dr("ProgrammId"), dsFailedJobs)
SendNotifications(dsFailedJobs, "Das Programm ##PROG_NAME## hat nicht innerhalb der Zeitspanne von " & m_Common.MaximalStartDuration.ToString() & " Minuten die Start() Methode der BMS-Dll aufgerufen. Möglicherweise konnte das Programm nicht gestartet werden.", JobType.StartJob)
'check for failed execution jobs
dsFailedJobs.Clear()
DataAccess.Job.GetFailedExecJobs(m_Common, dr("ProgrammId"), dsFailedJobs)
If dsFailedJobs.Tables.Count > 0 And dsFailedJobs.Tables(0).Rows.Count > 0 Then
SendNotifications(dsFailedJobs, "Das Programm ##PROG_NAME## konnte nicht innerhalb der vordefinierten Laufzeit von " & dsFailedJobs.Tables(0).Rows(0)("MaxLaufzeit").ToString() & " Minuten ausgeführt werden.", JobType.WatchJob)
End If
End If
End If
Next
End If
Catch ex As Exception
Throw ex
End Try
End Sub
'Executes all starter jobs
Private Sub ExecuteStartJobs()
Try
'Check if there are any jobs
If m_StartJobs.Tables.Count > 0 And m_StartJobs.Tables.Item(0).Rows.Count > 0 Then
Dim dt As DataTable
Dim startTime As New DateTime, endTime As New DateTime
dt = m_StartJobs.Tables.Item(0)
Dim dr As DataRow
For Each dr In dt.Rows
If dr("RunJob") Then
'RunJob has to run as fast as possible
If Not dr("IsRunning") Then
'job isn't already running
Dim job As New Job(m_Common, dr("JobId"), dr("Beschreibung"), dr("ProgrammId"), CType(dr("JobTypId"), JobType), CType(dr("JobStartTypId"), JobStartType))
If Not dr("ParentProgrammId") Is DBNull.Value Then
Dim parentProgrammId As Integer = dr("ParentProgrammId")
'job has a relation to another job, validate if parent job is currently executing...
If Not DataAccess.Job.CheckIsRunning(m_Common.DSN, parentProgrammId) Then
'parent job is not running, -> run job
'NachLetzterAusfuerung False, cause no one cares about next start time on RunJobs
job.Launch(True, False)
End If
Else
'run job
job.Launch(True, False)
End If
End If
Else
'Check if job is in valid date range
If dr.Item("DatumStart") <= DateTime.Now And CType(dr.Item("DatumEnde"), Date).AddDays(1) >= DateTime.Now Then
ConvertToDateTime(dr.Item("ZeitVon"), dr.Item("ZeitBis"), startTime, endTime)
If startTime <= DateTime.Now And endTime >= DateTime.Now Then
If dr("NextStartDate") < DateTime.Now Then
'interval has elapsed (should already be checked in GetJobs SP...)
If Not dr("IsRunning") Then
'job isn't already running
Dim job As New Job(m_Common, dr("JobId"), dr("Beschreibung"), dr("ProgrammId"), CType(dr("JobTypId"), JobType), CType(dr("JobStartTypId"), JobStartType))
If Not dr("ParentProgrammId") Is DBNull.Value Then
Dim parentProgrammId As Integer = dr("ParentProgrammId")
'job has a relation to another job, validate if parent job is currently executing...
If Not DataAccess.Job.CheckIsRunning(m_Common.DSN, parentProgrammId) Then
'parent job is not running, -> run job
job.Launch(False, dr("NachLetzterAusfuerung"))
End If
Else
'run job
job.Launch(False, dr("NachLetzterAusfuerung"))
End If
End If
End If
End If
End If
End If
Next
End If
Catch ex As Exception
Throw ex
End Try
End Sub
'Sends notifications to the pre-definied receivers (file or mail)
Private Sub SendNotifications(ByVal ds As DataSet, ByVal message As String, ByVal jobType As JobType)
Try
Dim drFailed As DataRow, drNotifications As DataRow
Dim dsNotifications As New DataSet
Dim hasNotiLimitReached As Boolean
hasNotiLimitReached = False
If ds.Tables.Count > 0 Then
If ds.Tables(0).Rows.Count > 0 Then
For Each drFailed In ds.Tables(0).Rows
'check if we already reached the limits for sending start/satch notifications
If jobType = jobType.WatchJob Then
If drFailed("NotiCounter") >= m_Common.MaxWatcherNotifications Then
hasNotiLimitReached = True
Else
hasNotiLimitReached = False
End If
Else
If drFailed("NotiCounter") >= m_Common.MaxStarterNotifications Then
hasNotiLimitReached = True
Else
hasNotiLimitReached = False
End If
End If
If Not hasNotiLimitReached Then
'get all notifications to a programm
dsNotifications.Clear()
DataAccess.Job.GetNotifications(m_Common, CInt(drFailed("ProgrammId")), dsNotifications)
If dsNotifications.Tables.Count > 0 Then
'seems to have rows in a table...
DataAccess.Job.SendNotification(m_Common, CInt(drFailed("ProgrammId")), dsNotifications, message, drFailed("JobId"), jobType)
End If
End If
If drFailed("NachLetzterAusfuerung") Then
DataAccess.Job.SetJobLastRun(m_Common.DSN, drFailed("JobId"), LastRun.End)
If Not drFailed("RunJob") Then
'calc next start exec time if its not a run job
DataAccess.Job.SetNextExecDateTime(m_Common.DSN, drFailed("JobId"))
End If
End If
Next
End If
End If
Catch ex As Exception
Throw ex
End Try
End Sub
#End Region
#Region "Helper Methods"
'Converts the times from database to a datetime datatyp for better handling
Private Sub ConvertToDateTime(ByVal startTime As String, ByVal endTime As String, ByRef startDateTime As DateTime, ByRef endDateTime As DateTime)
Try
Dim houres As Integer, minutes As Integer
'let's parse some time stuff to get start and end time in a better datatype...
houres = Left(startTime, 2)
minutes = Right(startTime, 2)
startDateTime = DateTime.Today.AddHours(houres)
startDateTime = startDateTime.AddMinutes(minutes)
houres = Left(endTime, 2)
minutes = Right(endTime, 2)
endDateTime = DateTime.Today.AddHours(houres)
endDateTime = endDateTime.AddMinutes(minutes)
'if endtime is less, endtime is on next day
'Ex: Start 23:15; End 02:45
If endDateTime < startDateTime Then
endTime = endDateTime.AddDays(1)
End If
Catch ex As Exception
Throw ex
End Try
End Sub
'Writes an message to windows event log
Private Sub WriteEventLog(ByVal errorMessage As String, ByVal eventLogType As EventLogEntryType)
Try
m_Common.Log(m_Common.SERVICE_DISPLAY_NAME, "Quelle: " & SERVICE_DISPLAY_NAME & Environment.NewLine & "Meldung: " & errorMessage, eventLogType)
Catch ex As Exception
System.Diagnostics.EventLog.WriteEntry(SERVICE_DISPLAY_NAME, errorMessage, eventLogType)
System.Diagnostics.EventLog.WriteEntry(SERVICE_DISPLAY_NAME, ex.Message + Environment.NewLine + ex.StackTrace, eventLogType.Error)
End Try
End Sub
#End Region
End Class

View File

@@ -0,0 +1,149 @@
<VisualStudioProject>
<VisualBasic
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{36BEB3BE-ABB4-4843-B6BB-588F5A9DF6C6}"
SccProjectName = "SAK"
SccLocalPath = "SAK"
SccAuxPath = "SAK"
SccProvider = "SAK"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "EDKB10"
AssemblyOriginatorKeyFile = ""
AssemblyOriginatorKeyMode = "None"
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "WinExe"
OptionCompare = "Binary"
OptionExplicit = "On"
OptionStrict = "Off"
RootNamespace = "BMSService"
StartupObject = "BMSService.BMSService"
>
<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.ServiceProcess"
AssemblyName = "System.ServiceProcess"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
/>
<Reference
Name = "System.Configuration.Install"
AssemblyName = "System.Configuration.Install"
HintPath = "..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Configuration.Install.dll"
/>
<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 = "bms_settings.xml"
BuildAction = "Content"
/>
<File
RelPath = "BMSService.vb"
SubType = "Component"
BuildAction = "Compile"
/>
<File
RelPath = "BMSService.resx"
DependentUpon = "BMSService.vb"
BuildAction = "EmbeddedResource"
/>
<File
RelPath = "Job.vb"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Job.resx"
DependentUpon = "Job.vb"
BuildAction = "EmbeddedResource"
/>
<File
RelPath = "ProjectInstaller.vb"
SubType = "Component"
BuildAction = "Compile"
/>
<File
RelPath = "ProjectInstaller.resx"
DependentUpon = "ProjectInstaller.vb"
BuildAction = "EmbeddedResource"
/>
</Include>
</Files>
</VisualBasic>
</VisualStudioProject>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="ResMimeType">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="Version">
<value>1.0.0.0</value>
</resheader>
<resheader name="Reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="Writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,180 @@
#Region "Includes"
Imports System.Data.SqlClient
Imports Common.Common
#End Region
Public Class Job
#Region "Members"
Private m_JobId As Integer
Private m_Description As String
Private m_ProgrammId As Integer
Private m_JobType As JobType
Private m_JobStartType As JobStartType
Private m_Common As Common.Common
#End Region
#Region "Constructor"
Public Sub New(ByVal common As Common.Common, ByVal jobId As Integer, ByVal description As String, ByVal programmId As Integer, ByVal jobType As JobType, ByVal jobStartType As JobStartType)
m_Common = common
m_JobId = jobId
m_Description = description
m_ProgrammId = programmId
m_JobType = jobType
m_JobStartType = jobStartType
End Sub
#End Region
#Region "Properties"
Public ReadOnly Property JobId() As Integer
Get
Return m_JobId
End Get
End Property
Public ReadOnly Property Description() As String
Get
Return m_Description
End Get
End Property
Public ReadOnly Property ProgrammId() As Integer
Get
Return m_ProgrammId
End Get
End Property
Public ReadOnly Property JobType() As JobType
Get
Return m_JobType
End Get
End Property
Public ReadOnly Property JobStartType() As JobStartType
Get
Return m_JobStartType
End Get
End Property
#End Region
#Region "Public Methods"
'Launches a start or a watch job
Public Sub Launch(ByVal isRunJob As Boolean, ByVal isNachLetzterAusfuerung As Boolean)
Try
'insert start datetime into db, used to check, if the job really started
'batch has to call bmsDll.Start() method...
DataAccess.Job.SetJobLastRun(m_Common.DSN, m_JobId, LastRun.Start)
'log some infos into eventlog
m_Common.Log(SERVICE_DISPLAY_NAME, "Starter launched Job " + m_JobId.ToString() + " (" + m_Description + ")")
'reset calculated bit
DataAccess.Job.SetNextStartDateCalculated(m_Common.DSN, m_JobId, True)
If Not isRunJob And Not isNachLetzterAusfuerung Then
'just calculate next start time if its not a runjob (job that has to execute as fast as possible)
DataAccess.Job.SetNextExecDateTime(m_Common.DSN, m_JobId)
End If
Select Case m_JobType
Case JobType.StartJob
Select Case m_JobStartType
Case JobStartType.Executable
StartExe()
Case JobStartType.SqlQuery
StartSqlQuery()
Case JobStartType.WindowsService
StartService()
Case Else
Throw New Exception("Unbekannter Job Start Typ """ & m_JobStartType.ToString() & """ ist unbekannt")
End Select
Case Else
Throw New Exception("Unbekannter Job Typ """ & m_JobType.ToString() & """")
End Select
Catch ex As Exception
Dim exModified As New Exception("Der Job JobId: " + m_JobId.ToString() + " (" + m_Description + ") konnte nicht gestartet werden." + Environment.NewLine + ex.Message, ex)
Throw exModified
End Try
End Sub
#End Region
#Region "private Methods"
'Starts an executable. But before, it gets all start parameters from db it needs
Private Sub StartExe()
Try
Dim programmPath As String
Dim process As New Process
DataAccess.Job.GetStartParameter(m_Common.DSN, m_JobId, StartParameterType.FilePath, programmPath)
process.Start(programmPath)
Catch ex As Exception
Throw ex
End Try
End Sub
'Starts a service. But before, it gets all start parameters from db it needs
Private Sub StartService()
Try
Dim serviceName As String, machineName As String
DataAccess.Job.GetStartParameter(m_Common.DSN, m_JobId, StartParameterType.ServiceName, serviceName)
DataAccess.Job.GetStartParameter(m_Common.DSN, m_JobId, StartParameterType.ServerName, machineName)
Dim serviceController As New System.ServiceProcess.ServiceController(serviceName, machineName)
If Not serviceController.Status = ServiceProcess.ServiceControllerStatus.Running Then
serviceController.Start()
End If
Catch ex As Exception
Throw ex
End Try
End Sub
'Starts a sql query. But before, it gets all start parameters from db it needs
Private Sub StartSqlQuery()
Dim sqlConn As New SqlConnection
Try
Dim connectionString As String, sqlQuery As String
DataAccess.Job.GetStartParameter(m_Common.DSN, m_JobId, StartParameterType.ConnectionString, connectionString)
DataAccess.Job.GetStartParameter(m_Common.DSN, m_JobId, StartParameterType.SQLQuery, sqlQuery)
Dim sqlCom As New SqlCommand
sqlConn.ConnectionString = connectionString
sqlConn.Open()
sqlCom.CommandType = CommandType.Text
sqlCom.Connection = sqlConn
sqlCom.CommandText = sqlQuery
sqlCom.ExecuteNonQuery()
sqlConn.Close()
Catch ex As Exception
If sqlConn.State = ConnectionState.Open Then
sqlConn.Close()
End If
Throw ex
End Try
End Sub
#End Region
End Class

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used forserialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ServiceProcessInstaller.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Assembly</value>
</data>
<data name="ServiceProcessInstaller.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Assembly</value>
</data>
<data name="ServiceProcessInstaller.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</data>
<data name="ServiceInstaller.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Assembly</value>
</data>
<data name="ServiceInstaller.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Assembly</value>
</data>
<data name="ServiceInstaller.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>188, 17</value>
</data>
<data name="$this.Name">
<value>ProjectInstaller</value>
</data>
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Assembly</value>
</data>
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
</root>

View File

@@ -0,0 +1,60 @@
Imports System.ComponentModel
Imports System.Configuration.Install
<RunInstaller(True)> Public Class ProjectInstaller
Inherits System.Configuration.Install.Installer
#Region " Component Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Installer overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Component Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Component Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
Friend WithEvents ServiceProcessInstaller As System.ServiceProcess.ServiceProcessInstaller
Friend WithEvents ServiceInstaller As System.ServiceProcess.ServiceInstaller
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ServiceProcessInstaller = New System.ServiceProcess.ServiceProcessInstaller
Me.ServiceInstaller = New System.ServiceProcess.ServiceInstaller
'
'ServiceProcessInstaller
'
Me.ServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem
Me.ServiceProcessInstaller.Password = Nothing
Me.ServiceProcessInstaller.Username = Nothing
'
'ServiceInstaller
'
Me.ServiceInstaller.DisplayName = "EDKB10"
Me.ServiceInstaller.ServiceName = "BMSService"
'
'ProjectInstaller
'
Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller, Me.ServiceInstaller})
End Sub
#End Region
End Class

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<root>
<config>
<!-- The maximum duration a start job can take before a starter error occures -->
<MaximumStartDuration>1</MaximumStartDuration>
<!-- Check interval in minutes for starter -->
<StartJobInterval>2</StartJobInterval>
<!-- Check interval in minutes for watcher -->
<WatchJobInterval>2</WatchJobInterval>
<!-- The number of Starter-Errors notifications should be activated until the job runs successful next time -->
<MaxStarterNotifications>2</MaxStarterNotifications>
<!-- The number of Watch-Errors notifications should be activated until the job runs successful next time -->
<MaxWatcherNotifications>3</MaxWatcherNotifications>
<!-- Name of the system event log where service should write his entries -->
<EventLogName>BMS</EventLogName>
<!-- The target where messages should be written to.
Valid log targets are:
- 1: System EventLog
- 2: Database EventLog table
-->
<LogTarget>1</LogTarget>
<!-- Mail Server to send eMails from BMS -->
<MailServer>tkbdev01</MailServer>
<!-- Mail sender name -->
<MailFrom>bms@tkb.ch</MailFrom>
<!-- Mail Server authentication method.
Valid methods are:
- 0: Anonymous
- 1: Basic Authentication (clear text authentication!)
-->
<MailServerAuth>
<Method>0</Method>
<UserName>mailUser</UserName>
<Password>mailPassword</Password>
</MailServerAuth>
</config>
</root>