project name record_organizer
This commit is contained in:
78
app/DD-Record-Organiser/ClassHelper.vb
Normal file
78
app/DD-Record-Organiser/ClassHelper.vb
Normal file
@@ -0,0 +1,78 @@
|
||||
Imports System.IO
|
||||
|
||||
Public Class ClassHelper
|
||||
Public Shared Function CheckDBNull(input As Object, back_Value As String)
|
||||
If IsDBNull(input) Then
|
||||
If back_Value = "String" Then
|
||||
Return ""
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
Else
|
||||
If back_Value = "String" Then
|
||||
Return input.ToString
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
Public Shared Function Get_TempFilename()
|
||||
'Eine tempfile generieren
|
||||
Dim tempFilename = My.Computer.FileSystem.GetTempFileName()
|
||||
'Nur den Filenamen ohne Erweiterung
|
||||
Dim tempName = Path.GetDirectoryName(tempFilename) & "\" & Path.GetFileNameWithoutExtension(tempFilename)
|
||||
'tempfile lsöchen
|
||||
If My.Computer.FileSystem.FileExists(tempFilename) Then
|
||||
My.Computer.FileSystem.DeleteFile(tempFilename)
|
||||
End If
|
||||
Return tempName
|
||||
End Function
|
||||
|
||||
Public Shared Function GetConnectionString(id As Integer)
|
||||
Dim connectionString As String = ""
|
||||
Try
|
||||
'Me.TBCONNECTIONTableAdapter.FillByID(Me.DD_DMSLiteDataSet.TBCONNECTION, id)
|
||||
Dim DTConnection As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM TBPMO_CONNECTION WHERE GUID = " & id)
|
||||
If DTConnection.Rows.Count = 1 Then
|
||||
Select Case DTConnection.Rows(0).Item("SQL_PROVIDER")
|
||||
Case "MS-SQLServer"
|
||||
connectionString = "Data Source=" & DTConnection.Rows(0).Item("SERVER") & ";Initial Catalog= " & DTConnection.Rows(0).Item("DATABASE") & ";User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
|
||||
Case "Oracle"
|
||||
If DTConnection.Rows(0).Item("COMMENT").ToString.Contains("without tnsnames") Then
|
||||
connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & DTConnection.Rows(0).Item("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" & _
|
||||
DTConnection.Rows(0).Item("DATABASE") & ")));User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
|
||||
Else
|
||||
connectionString = "Data Source=" & DTConnection.Rows(0).Item("SERVER") & ";Persist Security Info=True;User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";Unicode=True"
|
||||
End If
|
||||
'Dim conn As New OracleConnectionStringBuilder
|
||||
|
||||
'If chkOR_ohne_TNS.Checked Then
|
||||
' connstr = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & SERVERTextBox.Text & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" & _
|
||||
' DATABASETextBox.Text & ")));User Id=" & USERNAMETextBox.Text & ";Password=" & PASSWORDTextBox.Text & ";"
|
||||
'Else
|
||||
' conn.DataSource = DATABASETextBox.Text
|
||||
' conn.UserID = USERNAMETextBox.Text
|
||||
' conn.Password = PASSWORDTextBox.Text
|
||||
' conn.PersistSecurityInfo = True
|
||||
' conn.ConnectionTimeout = 120
|
||||
' connstr = conn.ConnectionString
|
||||
'End If
|
||||
|
||||
|
||||
|
||||
'Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;
|
||||
|
||||
Case Else
|
||||
ClassLogger.Add(" - ConnectionType nicht integriert", False)
|
||||
MsgBox("ConnectionType nicht integriert", MsgBoxStyle.Critical, "Bitte Konfiguration Connection überprüfen!")
|
||||
End Select
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add(" - Unvorhergesehener Fehler bei GetConnectionString - Fehler: " & vbNewLine & ex.Message)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler bei GetConnectionString:")
|
||||
|
||||
End Try
|
||||
Return connectionString
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user