Prepare for Version 2.0.0.0
This commit is contained in:
183
app/DD_Clipboard_Searcher/ctrlApplicationAssignment.vb
Normal file
183
app/DD_Clipboard_Searcher/ctrlApplicationAssignment.vb
Normal file
@@ -0,0 +1,183 @@
|
||||
Imports DD_LIB_Standards
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DigitalData.Controls.RegexEditor
|
||||
|
||||
Public Class ctrlApplicationAssignment
|
||||
|
||||
Private Current_ProfileId As Integer
|
||||
Private Current_ProcessName As String
|
||||
|
||||
Private Sub ctrlApplicationAssignment_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
TBCW_PROFILE_PROCESSTableAdapter.Connection.ConnectionString = MyConnectionString
|
||||
TBCW_PROF_REL_WINDOWTableAdapter.Connection.ConnectionString = MyConnectionString
|
||||
|
||||
AddHandler RepositoryItemRegexEdit.ButtonClick, AddressOf RepositoryItemRegexEdit_Click
|
||||
End Sub
|
||||
|
||||
Public Function Process_Load(ProfileId As Integer) As Boolean
|
||||
Try
|
||||
Current_ProfileId = ProfileId
|
||||
|
||||
TBCW_PROFILE_PROCESSTableAdapter.Fill(MyDataset.TBCW_PROFILE_PROCESS, ProfileId)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Process_CreateAssignment(ProfileId As Integer) As Boolean
|
||||
Dim oForm As New frmProcessCapture()
|
||||
Dim oResult = oForm.ShowDialog()
|
||||
|
||||
If oResult = DialogResult.OK Then
|
||||
Try
|
||||
Dim oWindowTitle As String = GetSQLFriendlyString(oForm.WindowTitle)
|
||||
Dim oProcessName As String = oForm.ProcessName
|
||||
|
||||
If oProcessName <> "" Then
|
||||
Dim oSQL = String.Format("INSERT INTO TBCW_PROFILE_PROCESS (PROFILE_ID,PROC_NAME,ADDED_WHO) VALUES ({0},'{1}','{2}')", ProfileId, oProcessName, Environment.UserName)
|
||||
If clsDatabase.Execute_non_Query(oSQL) = False Then
|
||||
Return False
|
||||
Else
|
||||
oSQL = String.Format("INSERT INTO TBCW_PROF_REL_WINDOW (PROFILE_ID, DESCRIPTION, PROCESS_NAME, REGEX, ADDED_WHO) VALUES ({0}, '{1}', '{2}','^{3}$','{4}')", ProfileId, oProcessName, oProcessName, oWindowTitle, Environment.UserName)
|
||||
If clsDatabase.Execute_non_Query(oSQL) = False Then
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Process_Load(Current_ProfileId)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function Process_DeleteAssignment() As Boolean
|
||||
Try
|
||||
Dim oProcessId = GridViewProcessProfile.GetFocusedRowCellValue(GridViewProcessProfile.Columns("GUID"))
|
||||
Dim oSQL = String.Format("EXEC PRCW_DELETE_PROCESS {0}", oProcessId)
|
||||
If clsDatabase.Execute_non_Query(oSQL) Then
|
||||
Process_Load(Current_ProfileId)
|
||||
Return True
|
||||
End If
|
||||
|
||||
Return False
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Window_Load() As Boolean
|
||||
Try
|
||||
TBCW_PROF_REL_WINDOWTableAdapter.Fill(MyDataset.TBCW_PROF_REL_WINDOW, Current_ProcessName, Current_ProfileId)
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub RepositoryItemRegexEdit_Click(sender As Object, e As ButtonPressedEventArgs)
|
||||
Dim oButtonEdit As ButtonEdit = sender
|
||||
Dim oGridControl As GridControl = oButtonEdit.Parent
|
||||
Dim oGridView As GridView = oGridControl.FocusedView
|
||||
Dim oRowHandle As Integer = oGridView.FocusedRowHandle
|
||||
|
||||
Dim oForm As New frmRegexEditor(oButtonEdit.EditValue)
|
||||
If oForm.ShowDialog() = DialogResult.OK Then
|
||||
oButtonEdit.EditValue = oForm.RegexString
|
||||
End If
|
||||
Console.WriteLine()
|
||||
End Sub
|
||||
|
||||
Public Function Window_CreateAssignment(ProfileId As Integer) As Boolean
|
||||
Dim oForm As New frmProcessCapture()
|
||||
Dim oResult = oForm.ShowDialog()
|
||||
|
||||
If oResult = DialogResult.OK Then
|
||||
Try
|
||||
Dim oWindowTitle As String = GetSQLFriendlyString(oForm.WindowTitle)
|
||||
Dim oProcessName As String = oForm.ProcessName
|
||||
|
||||
If oWindowTitle <> "" Then
|
||||
Dim insert = String.Format("INSERT INTO TBCW_PROF_REL_WINDOW (PROFILE_ID, DESCRIPTION, PROCESS_NAME, REGEX, ADDED_WHO) VALUES ({0}, '{1}', '{2}','^{3}$','{4}')", ProfileId, oProcessName, oProcessName, oWindowTitle, Environment.UserName)
|
||||
If clsDatabase.Execute_non_Query(insert) = False Then
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
|
||||
Window_Load()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function Window_DeleteAssignment() As Boolean
|
||||
Try
|
||||
Dim oGuid = GridView_Window.GetFocusedRowCellValue(GridView_Window.Columns("GUID"))
|
||||
Dim oSQL = String.Format("DELETE FROM TBCW_PROF_REL_WINDOW WHERE GUID = {0}", oGuid)
|
||||
If clsDatabase.Execute_non_Query(oSQL) Then
|
||||
Process_Load(Current_ProfileId)
|
||||
Return True
|
||||
End If
|
||||
|
||||
Return False
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Window_SaveAssignment() As Boolean
|
||||
Try
|
||||
TBCW_PROF_REL_WINDOWBindingSource.EndEdit()
|
||||
If Not IsNothing(MyDataset.TBCW_PROF_REL_WINDOW.GetChanges) Then
|
||||
TBCW_PROF_REL_WINDOWBindingSource.EndEdit()
|
||||
TBCW_PROF_REL_WINDOWTableAdapter.Update(MyDataset.TBCW_PROF_REL_WINDOW)
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub GridViewProcessProfile_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewProcessProfile.FocusedRowChanged
|
||||
If e.FocusedRowHandle < 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oSelectedRow As DataRow = GridViewProcessProfile.GetDataRow(e.FocusedRowHandle)
|
||||
Dim oProcessName As String = oSelectedRow.Item("PROC_NAME")
|
||||
Current_ProcessName = oProcessName
|
||||
|
||||
If Window_Load() = False Then
|
||||
MsgBox($"Error while loading windows for process {oProcessName}", vbCritical, "")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function GetSQLFriendlyString(UnfriendlyString As String) As String
|
||||
Return UnfriendlyString.
|
||||
Trim().
|
||||
Replace(vbNullChar, "")
|
||||
End Function
|
||||
|
||||
|
||||
Public Class RegexEdit
|
||||
Inherits BaseEdit
|
||||
|
||||
End Class
|
||||
End Class
|
||||
Reference in New Issue
Block a user