Index: ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/EmployeesDatabaseMapper.vb
===================================================================
diff -u -r1743 -r1756
--- ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/EmployeesDatabaseMapper.vb (.../EmployeesDatabaseMapper.vb) (revision 1743)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/EmployeesDatabaseMapper.vb (.../EmployeesDatabaseMapper.vb) (revision 1756)
@@ -1,42 +1,29 @@
Imports System.Data.SqlClient
+Imports ActiviteitenOpvolging.ServiceAgents
+Imports ActiviteitenOpvolging.ServiceAgents.Implementations
Module EmployeesDatabaseMapper
Private _sqlConnection As SqlConnection
#Region "Help functions"
- '''
- ''' Helpfunction to open SQL connection to database.
- '''
- Private Sub ConnectToDatabase()
- Try
- If _sqlConnection Is Nothing Then
- 'Build connection string. Looks something like this "Server=...;database=...;user=...;Pwd=..."
- Dim connectionString = $"Server={My.Resources.EmployeesDatabaseServerName}; database={My.Resources.EmployeesDatabase};
- user={My.Resources.EmployeesDatabaseUsername}; Pwd={My.Resources.EmployeesDatabasePassword}"
- 'Initialise connection.
- _sqlConnection = New SqlConnection(connectionString)
- End If
- 'Check if connection state is already open.
- If Not _sqlConnection.State = ConnectionState.Open Then
- 'If not, open the connection.
- _sqlConnection.Open()
- End If
- Catch ex As Exception
- Throw New Exception($"Can't reach the Employees database: {vbNewLine}{ex.Message}")
- End Try
+
+ Private ReadOnly _activiteitPerBatchServiceAgent As IActiviteitPerBatchServiceAgent
+
+ Sub New()
+ _activiteitPerBatchServiceAgent = New ActiviteitPerBatchServiceAgent
End Sub
'''
''' Execution of a query into a data reader.
'''
''' The query
''' The SQL data reader
- Private Function ExecuteIntoDataReader(query As String) As SqlDataReader
+ Private Function ExecuteIntoDataSet() As DataSet
+
Try
- ConnectToDatabase()
- Return New SqlCommand(query, _sqlConnection).ExecuteReader()
+ Return _activiteitPerBatchServiceAgent.GeefWerknemers()
Catch ex As Exception
- Throw New Exception($"Could not get data reader from the employees database.{vbNewLine}{ex.Message}")
+ Throw New Exception($"Could not get dataset from the Caché webservice.{vbNewLine}{ex.Message}")
End Try
End Function
@@ -52,7 +39,7 @@
''' Whether or not the value is required
''' Optional default value of the value. Standard 'Nothing' or the default value of the type
''' The value converted to the type of
- Private Function ExtractItemFromDataReader(Of T)(ByRef dr As SqlDataReader, key As String, isRequired As Boolean, Optional defaultValue As T = Nothing) As T
+ Private Function ExtractItemFromDataReader(Of T)(ByRef dr As DataTableReader, key As String, isRequired As Boolean, Optional defaultValue As T = Nothing) As T
Dim value As Object
Try
'Extract the value with the key. Column will always be present.
@@ -86,33 +73,27 @@
''' A collection of employees
Public Function FetchEmployees() As ICollection(Of IEmployee)
'Define the query.
- Dim query = "SELECT [PersNr]
- ,[Foto]
- ,[Achternaam]
- ,[Voornaam]
- ,Initialen
- FROM [WieIsWie].[dbo].[tmpWieisWie]
- WHERE Bedrijf='Halux nv'"
'Initialise the list with employees.
Dim employees As New List(Of IEmployee)
'Declare SQL data reader.
- Dim dr As SqlDataReader = Nothing
+ Dim dataReader As DataTableReader = Nothing
Try
'Fetch the data reader with the query.
- dr = ExecuteIntoDataReader(query)
+ Dim CacheDataSet As DataSet = ExecuteIntoDataSet()
+ dataReader = CacheDataSet.CreateDataReader()
- While dr.Read()
+ While dataReader.Read()
'Initialise new Employee.
Dim employee As New Employee
With employee
- .PersonelNumber = ExtractItemFromDataReader(Of Integer)(dr, "PersNr", True)
- .Picture = ExtractItemFromDataReader(Of String)(dr, "Foto", True, String.Empty)
- .FirstName = ExtractItemFromDataReader(Of String)(dr, "Voornaam", False, String.Empty)
- .LastName = ExtractItemFromDataReader(Of String)(dr, "Achternaam", False, String.Empty)
- .Initials = ExtractItemFromDataReader(Of String)(dr, "Initialen", True)
+ .PersonelNumber = ExtractItemFromDataReader(Of Integer)(dataReader, "PersNr", True)
+ .Picture = ExtractItemFromDataReader(Of String)(dataReader, "Foto", True, String.Empty)
+ .FirstName = ExtractItemFromDataReader(Of String)(dataReader, "Voornaam", False, String.Empty)
+ .LastName = ExtractItemFromDataReader(Of String)(dataReader, "Achternaam", False, String.Empty)
+ .Initials = ExtractItemFromDataReader(Of String)(dataReader, "Initialen", True)
End With
'Add new employee to list.
@@ -124,8 +105,8 @@
Throw New Exception($"An error occured while fetching the employees.{vbNewLine}{ex.Message}")
Finally
'Close connection if datareader is not nothing.
- If Not IsNothing(dr) Then
- dr.Close()
+ If Not IsNothing(dataReader) Then
+ dataReader.Close()
End If
End Try
End Function
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/IActiviteitPerBatchServiceAgent.vb
===================================================================
diff -u -r1752 -r1756
--- ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/IActiviteitPerBatchServiceAgent.vb (.../IActiviteitPerBatchServiceAgent.vb) (revision 1752)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/IActiviteitPerBatchServiceAgent.vb (.../IActiviteitPerBatchServiceAgent.vb) (revision 1756)
@@ -7,7 +7,8 @@
Sub PauseActionsFromApp()
- Function GeefDataSetVoorQuery(ByVal QueryNaam As String) As System.Data.DataSet
+ Function GeefDataSetVoorQuery(ByVal QueryNaam As String) As DataSet
+ Function GeefWerknemers() As DataSet
End Interface
End NameSpace
\ No newline at end of file
FishEye: Tag 1756 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/Implementations/ActiviteitPerBatchServer.vb'.
FishEye: No comparison available. Pass `N' to diff?
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/Implementations/ActiviteitPerBatch.vb
===================================================================
diff -u -r1752 -r1756
--- ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/Implementations/ActiviteitPerBatch.vb (.../ActiviteitPerBatch.vb) (revision 1752)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/Implementations/ActiviteitPerBatch.vb (.../ActiviteitPerBatch.vb) (revision 1756)
@@ -36,6 +36,15 @@
"etVoorQuery", ReplyAction:="*")>
Function GeefDataSetVoorQueryAsync(ByVal AppNaam As String, ByVal ComputerNaam As String, ByVal QueryNaam As String) As System.Threading.Tasks.Task(Of System.Data.DataSet)
+
+ Function GeefWerknemers(ByVal AppNaam As String, ByVal ComputerNaam As String) As System.Data.DataSet
+
+
+ Function GeefWerknemersAsync(ByVal AppNaam As String, ByVal ComputerNaam As String) As System.Threading.Tasks.Task(Of System.Data.DataSet)
+
@@ -56,7 +65,7 @@
End Interface
-Public Interface ActiviteitPerBatchServerSoapChannel
+Public Interface ActiviteitPerBatchSoapChannel
Inherits ActiviteitPerBatch, System.ServiceModel.IClientChannel
End Interface
@@ -102,6 +111,14 @@
Return MyBase.Channel.GeefDataSetVoorQueryAsync(AppNaam, ComputerNaam, QueryNaam)
End Function
+ Public Function GeefWerknemers(ByVal AppNaam As String, ByVal ComputerNaam As String) As System.Data.DataSet Implements ActiviteitPerBatch.GeefWerknemers
+ Return MyBase.Channel.GeefWerknemers(AppNaam, ComputerNaam)
+ End Function
+
+ Public Function GeefWerknemersAsync(ByVal AppNaam As String, ByVal ComputerNaam As String) As System.Threading.Tasks.Task(Of System.Data.DataSet) Implements ActiviteitPerBatch.GeefWerknemersAsync
+ Return MyBase.Channel.GeefWerknemersAsync(AppNaam, ComputerNaam)
+ End Function
+
Public Function PauzeerActiesVanApp(ByVal AppNaam As String, ByVal ComputerNaam As String) As String Implements ActiviteitPerBatch.PauzeerActiesVanApp
Return MyBase.Channel.PauzeerActiesVanApp(AppNaam, ComputerNaam)
End Function
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/workplace.ico
===================================================================
diff -u
Binary files differ
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj
===================================================================
diff -u -r1753 -r1756
--- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1753)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1756)
@@ -62,6 +62,9 @@
On
+
+ workplace.ico
+
@@ -253,6 +256,7 @@
Always
+
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb
===================================================================
diff -u -r1752 -r1756
--- ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb (.../CacheMapper.vb) (revision 1752)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb (.../CacheMapper.vb) (revision 1756)
@@ -5,9 +5,7 @@
Module CacheMapper
#Region "Help functions"
- '''
- ''' Helpfunction to open SQL connection to Caché.
- '''
+
Private ReadOnly _activiteitPerBatchServiceAgent As IActiviteitPerBatchServiceAgent
Sub New()
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/Implementations/ActiviteitPerBatchServiceAgent.vb
===================================================================
diff -u -r1752 -r1756
--- ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/Implementations/ActiviteitPerBatchServiceAgent.vb (.../ActiviteitPerBatchServiceAgent.vb) (revision 1752)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/ServiceAgents/Implementations/ActiviteitPerBatchServiceAgent.vb (.../ActiviteitPerBatchServiceAgent.vb) (revision 1756)
@@ -43,5 +43,13 @@
End Try
End Function
+ Public Function GeefWerknemers() As DataSet Implements IActiviteitPerBatchServiceAgent.GeefWerknemers
+ Try
+ Return SoapClient().GeefWerknemers(ConfigsLoader.AppName, System.Net.Dns.GetHostName())
+ Catch ex As Exception
+ Throw New Exception($"Can't reach the Caché webservice: {vbNewLine}{ex.Message}")
+ End Try
+ End Function
+
End Class
End NameSpace
\ No newline at end of file