2025-12-05 14:02:41 +01:00

69 lines
2.4 KiB
VB.net

Imports CommandLine
Imports CommandLine.Text
Imports System.Text.RegularExpressions
Public Class ClassJumpRecord
Private Shared ProtocolRegex As New Regex("pmo://(?<constructorId>\d+)-(?<recordId>\d+)")
'Aufruf: PMO.exe --data pmo://10-60
Class Options
<[Option]("d", "data")>
Public Property data As String
End Class
Public Shared Sub ParseArgs()
Try
Dim args() As String = Environment.GetCommandLineArgs()
Dim options As New Options()
Dim type_ID As Integer
Dim recordId As Integer
If args.Length <> 3 Then
Exit Sub
End If
If (Parser.Default.ParseArguments(args, options)) Then
Dim data As String = options.data
Dim match = ProtocolRegex.Match(data)
If Not match.Success Then
Exit Sub
End If
type_ID = match.Groups("constructorId").Value
recordId = match.Groups("recordId").Value
JumpToRecord(type_ID, recordId)
Else
Exit Sub
End If
Catch ex As Exception
MsgBox("Error in ParseArgs:" & vbNewLine & ex.Message)
Exit Sub
End Try
End Sub
Public Shared Sub JumpToRecord(STATE_ID As Integer, recordId As Integer)
Try
Dim recordIdExists As Boolean = MYDB_ECM.GetScalarValue(String.Format("SELECT GUID FROM TBPMO_RECORD WHERE GUID = {0}", recordId))
'If constructorIdExists = False Or recordIdExists = False Then
' MsgBox("Das angegebene Formular konnte nicht geöffnet werden. Grund: Die ConstructorID oder die RecordID wurde nicht gefunden." & vbNewLine & "constructorId: " & constructorId & ", recordId: " & recordId, MsgBoxStyle.Exclamation, "URL Handler")
' Exit Sub
'End If
If Not recordIdExists Then
MsgBox(String.Format("RecordId {0} could not be found. Record will not be loaded.", recordId))
Exit Sub
End If
JUMP_STATE = STATE_ID
JUMP_ID = recordId
'OpenFormConstructor(constructorId, recordId)
OpenRecordView()
Catch ex As Exception
MsgBox("Error in JumpToRecord:" & vbNewLine & ex.Message)
Exit Sub
End Try
End Sub
End Class