MSBuildProblem_PM
This commit is contained in:
204
DD_PM_WINDREAM/frmSQL_DESIGNER.vb
Normal file
204
DD_PM_WINDREAM/frmSQL_DESIGNER.vb
Normal file
@@ -0,0 +1,204 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports Oracle.ManagedDataAccess.Client
|
||||
|
||||
Public Class frmSQL_DESIGNER
|
||||
Private _windreamPM As ClassPMWindream
|
||||
Private Sub TBPM_PROFILE_FINAL_INDEXINGBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
|
||||
Me.Validate()
|
||||
Me.TBPM_PROFILE_FINAL_INDEXINGBindingSource.EndEdit()
|
||||
Me.TableAdapterManager.UpdateAll(Me.DD_DMSLiteDataSet)
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub FillToolStripButton_Click(sender As Object, e As EventArgs)
|
||||
Try
|
||||
If CURRENT_DESIGN_TYPE = "FINAL_INDEX" Then
|
||||
Dim sql = "SELECT"
|
||||
End If
|
||||
Catch ex As System.Exception
|
||||
System.Windows.Forms.MessageBox.Show(ex.Message)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub frmSQL_FINAL_INDICES_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Try
|
||||
lblSaveFinalIndex.Visible = False
|
||||
'TODO: Diese Codezeile lädt Daten in die Tabelle "DD_DMSLiteDataSet.TBPM_CONNECTION". Sie können sie bei Bedarf verschieben oder entfernen.
|
||||
Me.TBPM_CONNECTIONTableAdapter.Connection.ConnectionString = MyConnectionString
|
||||
Me.TBPM_CONNECTIONTableAdapter.Fill(Me.DD_DMSLiteDataSet.TBPM_CONNECTION)
|
||||
Me.TBPM_PROFILE_FINAL_INDEXINGTableAdapter.Connection.ConnectionString = MyConnectionString
|
||||
cmbConnection.SelectedValue = CURRENT_DT_SQL_CONFIG_TABLE.Rows(0).Item("CONNECTION_ID")
|
||||
cmbConnection.FindStringExact(CURRENT_DT_SQL_CONFIG_TABLE.Rows(0).Item("CON_STRING"))
|
||||
SQL_COMMANDTextBox.Text = CURRENT_DT_SQL_CONFIG_TABLE.Rows(0).Item("SQL_COMMAND")
|
||||
Try
|
||||
' Windream instanziieren
|
||||
_windreamPM = New ClassPMWindream()
|
||||
'Windream initialisieren (Connection, Session, ... aufbauen)
|
||||
_windreamPM.Init()
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler bei Initialisieren von windream: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Achtung:")
|
||||
End Try
|
||||
cmbIndexe.Items.Clear()
|
||||
Dim indexe = _windreamPM.GetIndicesByObjecttype(CURRENT_OBJECTTYPE)
|
||||
If indexe IsNot Nothing Then
|
||||
For Each index As String In indexe
|
||||
Me.cmbIndexe.Items.Add(index)
|
||||
Next
|
||||
Me.cmbIndexe.SelectedIndex = -1
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error while loading form: " & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
Dim CurrentPosition As Integer = 0
|
||||
Dim CurrentPlaceholders As New Placeholders()
|
||||
Dim CurrentTableType As String
|
||||
Dim AtPlaceholderPattern As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}" '"\[%[0-9A-Za-z_-]{1,}\]"
|
||||
Public Class Placeholders
|
||||
Public Property RecordId As Integer
|
||||
Public Property ParentRecordId As Integer
|
||||
Public Property FormId As Integer
|
||||
End Class
|
||||
|
||||
Public Property Value() As String
|
||||
Get
|
||||
Return SQL_COMMANDTextBox.Text
|
||||
End Get
|
||||
Set(value As String)
|
||||
SQL_COMMANDTextBox.Text = value
|
||||
End Set
|
||||
End Property
|
||||
Private Sub SQL_COMMANDTextBox_TextChanged(sender As Object, e As EventArgs) Handles SQL_COMMANDTextBox.TextChanged, SQL_COMMANDTextBox.Click
|
||||
CurrentPosition = SQL_COMMANDTextBox.SelectionStart
|
||||
|
||||
If SQL_COMMANDTextBox.Text.Trim().Count = 0 Then
|
||||
dgvPlaceholders.Enabled = False
|
||||
Else
|
||||
dgvPlaceholders.Enabled = True
|
||||
End If
|
||||
|
||||
CheckForPlaceholders()
|
||||
End Sub
|
||||
Private Sub CheckForPlaceholders()
|
||||
Dim count As Integer = 0
|
||||
Dim text As String = Me.Value
|
||||
Dim atPlaceholderRegex = New Regex(AtPlaceholderPattern, RegexOptions.IgnoreCase)
|
||||
Dim matches As MatchCollection = atPlaceholderRegex.Matches(text)
|
||||
|
||||
dgvPlaceholders.Rows.Clear()
|
||||
|
||||
For Each match As Match In matches
|
||||
dgvPlaceholders.Rows.Add({match.Value, ""})
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub btnTestSQL_Click(sender As Object, e As EventArgs) Handles btnTestSQL.Click
|
||||
Dim query As String = SQL_COMMANDTextBox.Text
|
||||
|
||||
For Each row As DataGridViewRow In dgvPlaceholders.Rows
|
||||
Dim placeholder As String = row.Cells(0).Value
|
||||
Dim replacement As String = row.Cells(1).Value
|
||||
|
||||
' Wenn Ersetzung ausgefüllt wurde, Platzhalter damit ersetzen
|
||||
If Not String.IsNullOrEmpty(replacement) Then
|
||||
query = query.Replace(placeholder, replacement)
|
||||
Else
|
||||
MsgBox("Bitte geben Sie für den Platzhalter " & placeholder & " einen Wert an!", MsgBoxStyle.Exclamation, "Fehlende Platzhalter Ersetzung")
|
||||
Exit Sub
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim ds As DataSet = ExecuteWithConnection(cmbConnection.SelectedValue, query)
|
||||
|
||||
If ds IsNot Nothing Then
|
||||
dgvResult.DataSource = ds.Tables(0)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Private Function ExecuteWithConnection(connectionId As Integer, sql As String) As DataSet
|
||||
Try
|
||||
|
||||
Dim connectionString As String
|
||||
|
||||
connectionString = ClassDatabase.Get_ConnectionString(connectionId)
|
||||
|
||||
If connectionString <> "" Then
|
||||
|
||||
If connectionString.StartsWith("Server=") And connectionString.Contains("Database=") Then
|
||||
Dim sqlConnection As SqlClient.SqlConnection
|
||||
Dim sqlCommand As SqlClient.SqlCommand
|
||||
Dim sqlAdapter As New SqlClient.SqlDataAdapter
|
||||
Dim dataset As New DataSet
|
||||
|
||||
sqlConnection = New SqlClient.SqlConnection(connectionString)
|
||||
sqlConnection.Open()
|
||||
|
||||
sqlCommand = New SqlClient.SqlCommand(sql, sqlConnection)
|
||||
|
||||
sqlAdapter.SelectCommand = sqlCommand
|
||||
sqlAdapter.Fill(dataset)
|
||||
|
||||
Return dataset
|
||||
ElseIf connectionString.Contains("dsn=") Then 'ODBC-Connection
|
||||
Dim sqlConnection As Odbc.OdbcConnection
|
||||
Dim sqlCommand As Odbc.OdbcCommand
|
||||
Dim sqlAdapter As New Odbc.OdbcDataAdapter
|
||||
Dim dataset As New DataSet
|
||||
|
||||
sqlConnection = New Odbc.OdbcConnection(connectionString)
|
||||
sqlConnection.Open()
|
||||
|
||||
sqlCommand = New Odbc.OdbcCommand(sql, sqlConnection)
|
||||
|
||||
sqlAdapter.SelectCommand = sqlCommand
|
||||
sqlAdapter.Fill(dataset)
|
||||
|
||||
Return dataset
|
||||
Else
|
||||
If LogErrorsOnly = True Then ClassLogger.Add(" >> It's an Oracle-Connection (ExecuteWithConnection)", False)
|
||||
Dim sqlConnection As OracleConnection
|
||||
Dim sqlCommand As OracleCommand
|
||||
Dim sqlAdapter As New OracleDataAdapter
|
||||
Dim dataset As New DataSet
|
||||
|
||||
sqlConnection = New OracleConnection(connectionString)
|
||||
sqlConnection.Open()
|
||||
|
||||
sqlCommand = New OracleCommand(sql, sqlConnection)
|
||||
|
||||
sqlAdapter.SelectCommand = sqlCommand
|
||||
sqlAdapter.Fill(dataset)
|
||||
|
||||
Return dataset
|
||||
End If
|
||||
Else
|
||||
MsgBox("Keine gültige ConnectionID", MsgBoxStyle.Exclamation)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add(" - Unvorhergesehener Fehler bei TestSQL - Fehler: " & vbNewLine & ex.Message)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler bei TestSQL:")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
If cmbIndexe.SelectedIndex <> -1 Then
|
||||
Dim val As String = "[%" & cmbIndexe.Text & "]"
|
||||
Dim altePosition As Integer = Me.SQL_COMMANDTextBox.SelectionStart()
|
||||
Me.SQL_COMMANDTextBox.Text = Me.SQL_COMMANDTextBox.Text.Insert(altePosition, val)
|
||||
Me.SQL_COMMANDTextBox.SelectionStart = altePosition + val.Length
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub btnSaveSQLCommand_Click(sender As Object, e As EventArgs) Handles btnSaveSQLCommand.Click
|
||||
If CURRENT_DESIGN_TYPE = "FINAL_INDEX" Then
|
||||
TBPM_PROFILE_FINAL_INDEXINGTableAdapter.cmdUpdateSQL(cmbConnection.SelectedValue, SQL_COMMANDTextBox.Text, Environment.UserName, CURRENT_INDEX_ID)
|
||||
lblSaveFinalIndex.Visible = True
|
||||
lblSaveFinalIndex.Text = "SQL für finalen Index wurd erfolgreich gespeichert! " & Now.ToString
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user