You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
189 lines
6.2 KiB
189 lines
6.2 KiB
Imports System
|
|
Imports System.Data
|
|
Imports System.Data.OracleClient
|
|
|
|
Namespace Avaloq
|
|
|
|
Public Class SST
|
|
Const queryString As String = "k.tkb$out_dsp_in#.edoka_in"
|
|
Const queryStringOpenSession As String = "k.session#.open_session"
|
|
Const queryStringCloseSession As String = "k.session#.close_session"
|
|
Const avqOracleUser As String = "TKB$I_EDOKA"
|
|
Const avqSecUserId As Integer = 34
|
|
Const avqBuId As Integer = 1
|
|
|
|
Const edkDokBezeichnungKey As String = "edk_bez"
|
|
Const edkDokBezeichnungDflt As String = "Antworttalon"
|
|
Dim connStrg As String
|
|
|
|
|
|
Private _hasErrors As Boolean
|
|
Private _edkDokBezeichnung As String
|
|
Private _qrcode As String
|
|
Private _hasQrCode As Boolean
|
|
Private _bpnr As String
|
|
|
|
|
|
|
|
Public Sub New()
|
|
oread = System.IO.File.OpenText(DivFnkt.ApplicationPath + "avaloqconn.cfg")
|
|
connStrg = oread.ReadLine
|
|
oread.Close()
|
|
|
|
End Sub
|
|
|
|
|
|
Public ReadOnly Property hasErrors() As Boolean
|
|
Get
|
|
Return _hasErrors
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property edkDokBezeichnung As String
|
|
Get
|
|
Return _edkDokBezeichnung
|
|
End Get
|
|
End Property
|
|
|
|
Public Property hasQrCode As Boolean
|
|
Get
|
|
Return _hasQrCode
|
|
End Get
|
|
Set(value As Boolean)
|
|
_hasQrCode = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Sub Prepare(ByVal BPNr As String, ByVal Instructions As String)
|
|
_hasErrors = False
|
|
_bpnr = BPNr
|
|
_qrcode = Instructions
|
|
|
|
If Len(_qrcode) > 0 Then
|
|
_hasQrCode = True
|
|
|
|
'EDOKA-Dokument-Bezeichnung auslesen
|
|
Try
|
|
For Each pairs As String In _qrcode.Split(";"c)
|
|
Dim values As String() = pairs.Split(":"c)
|
|
If values(0) = edkDokBezeichnungKey Then
|
|
_edkDokBezeichnung = values(1)
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
_hasErrors = True
|
|
_edkDokBezeichnung = edkDokBezeichnungDflt
|
|
End Try
|
|
Else
|
|
_hasErrors = True
|
|
_edkDokBezeichnung = edkDokBezeichnungDflt
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub SendData()
|
|
|
|
If Len(_bpnr) = 0 Or _hasQrCode = False Then
|
|
_hasErrors = True
|
|
Return
|
|
End If
|
|
|
|
|
|
_hasErrors = True 'wird bei erfolgreicher Übermittlung auf false gesetellt
|
|
|
|
Dim dataReader As OracleDataReader
|
|
Dim connectionSession As New OracleConnection
|
|
|
|
connectionSession.ConnectionString = connStrg
|
|
'OracleConnection.ClearAllPools()
|
|
Dim command As OracleCommand = connectionSession.CreateCommand()
|
|
|
|
command.Parameters.Clear()
|
|
|
|
command.CommandText = queryStringOpenSession
|
|
command.CommandType = CommandType.StoredProcedure
|
|
command.Parameters.Add(New OracleParameter("i_sec_user_id", OracleType.Int32)).Value = avqSecUserId
|
|
command.Parameters.Add(New OracleParameter("i_oracle_user", OracleType.VarChar)).Value = avqOracleUser
|
|
command.Parameters.Add(New OracleParameter("i_bu_id", OracleType.Int32)).Value = avqBuId
|
|
Try
|
|
connectionSession.Open()
|
|
'connectionSession.Open()
|
|
'connectionSession.open
|
|
'dataReader =
|
|
command.ExecuteReader()
|
|
'dataReader.Read()
|
|
'dataReader.Close()
|
|
'dataReader.Dispose()
|
|
Catch ex As Exception
|
|
If connectionSession.State = ConnectionState.Closed Then
|
|
connectionSession.Open()
|
|
command.ExecuteReader()
|
|
End If
|
|
End Try
|
|
|
|
|
|
command.Parameters.Clear()
|
|
|
|
command.CommandText = queryString
|
|
command.CommandType = CommandType.StoredProcedure
|
|
command.Parameters.Add(New OracleParameter("i_bp_nr", OracleType.VarChar)).Value = _bpnr
|
|
command.Parameters.Add(New OracleParameter("i_instructions", OracleType.VarChar)).Value = _qrcode
|
|
command.Parameters.Add(New OracleParameter("o_ret_val", OracleType.VarChar, 20)).Direction = ParameterDirection.Output
|
|
|
|
Try
|
|
If connectionSession.State = ConnectionState.Open Then
|
|
'nothing
|
|
Else
|
|
connectionSession.Open()
|
|
End If
|
|
|
|
|
|
dataReader = command.ExecuteReader()
|
|
dataReader.Read()
|
|
|
|
Dim result As String = command.Parameters.Item(2).Value
|
|
If result = "OK" Then
|
|
_hasErrors = False
|
|
Else
|
|
_hasErrors = True
|
|
End If
|
|
|
|
dataReader.Close()
|
|
dataReader.Dispose()
|
|
connectionSession.Close()
|
|
connectionSession.Dispose()
|
|
'ACHTUNG
|
|
connectionSession = Nothing
|
|
dataReader = Nothing
|
|
command = Nothing
|
|
|
|
'ACHTUNG
|
|
|
|
Catch ex As Exception
|
|
Console.WriteLine(ex.Message)
|
|
If connectionSession.State = ConnectionState.Open Then
|
|
command.Parameters.Clear()
|
|
command.CommandText = "k.session#.close_session"
|
|
command.CommandType = CommandType.StoredProcedure
|
|
Try
|
|
dataReader = command.ExecuteReader()
|
|
dataReader.Read()
|
|
dataReader.Close()
|
|
dataReader.Dispose()
|
|
Catch ex1 As Exception
|
|
|
|
End Try
|
|
|
|
command.Dispose()
|
|
connectionSession.Close()
|
|
connectionSession.Dispose()
|
|
Console.WriteLine(connectionSession.State)
|
|
End If
|
|
End Try
|
|
End Sub
|
|
End Class
|
|
|
|
|
|
|
|
End Namespace
|
|
|