fix autoindexing not replacing new placeholders, fix skipping, fix damaged datatable, correct default value of nameconvention

This commit is contained in:
Jonathan Jenne 2020-04-01 13:49:55 +02:00
parent 825cc03f66
commit 92757c55d4
3 changed files with 307 additions and 445 deletions

View File

@ -18,6 +18,8 @@ Public Class ClassWindream
Const VARIABLEN = 2
Const WMObjectStreamOpenModeReadWrite = 2
Const STREAM_BinaryObject = "BinaryObject"
Public Const WMObjectVariableValueTypeUndefined = 0
Public Const WMObjectVariableValueTypeString = 1
Public Const WMObjectVariableValueTypeInteger = 2
@ -295,69 +297,7 @@ Public Class ClassWindream
End Try
End Function
''' <summary>
''' Liefert alle Objekttypen des aktuellen Servers als Array aus Strings.
''' </summary>
''' <returns>Array mit allen Objekttypen als Strings</returns>
''' <remarks></remarks>
Public Function GetObjecttypesAsStrings() As String()
Try
Dim objektTypenStr(_DocumentTypes.Count) As String
For i As Integer = 0 To _DocumentTypes.Count
objektTypenStr(i) = _DocumentTypes.Item(i).aName
Next
Return objektTypenStr
Catch ex As Exception
MsgBox("Fehlernachricht:" & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Unexpected error inm Auslesen der Objekttypen als String")
Return Nothing
End Try
End Function
Public Function GetTypeOfIndex(ByVal indexname As String) As Integer
Try
Dim oAttribute = _session.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, indexname)
Dim vType = oAttribute.getVariableValue("dwAttrType")
Return vType
Catch ex As Exception
Return Nothing
End Try
End Function
Public Shared Function GetSystemIndices(ByVal name As String)
Dim oObjectType As WMObject
' den Objekttyp laden
oObjectType = _session.GetWMObjectByName(WMEntityObjectType, name)
Dim msg As String
Dim oSystemIndexes = oObjectType.GetVariableNames(1, False)
msg = "System indices (internal column names): " & vbNewLine
For Each oSystemIndex In oSystemIndexes
msg = msg & vbNewLine & oSystemIndex
Next
MsgBox(msg)
End Function
Public Shared Function GetTypIndexNames(ByVal name As String)
Dim oObjectType As WMObject
' den Objekttyp laden
oObjectType = _session.GetWMObjectByName(WMEntityObjectType, name)
Dim msg As String
Dim oSystemIndexes = oObjectType.GetVariableNames(2, False)
msg = "Type Indices (type Index names): " & vbNewLine
For Each oSystemIndex In oSystemIndexes
msg = msg & vbNewLine & oSystemIndex
Next
MsgBox(msg)
End Function
''' <summary>
''' Liefert alle Indexe eines Objekttypen.
''' </summary>
@ -406,31 +346,6 @@ Public Class ClassWindream
Return Nothing
End Try
End Function
''' <summary>
''' Liefert einen Objekttyp als WMObject an Hand dessen Name.
''' </summary>
''' <param name="objekttypName">Name des Objekttyps</param>
''' <returns>Objekttyp als WMObject</returns>
''' <remarks></remarks>
Public Function GetObjecttypeByName(ByVal objekttypName As String) As WMObject
Try
' alle Objekttypen auslesen
Dim oObjectTypes As WMObjects = _session.GetWMObjectTypes(WINDREAMLib.WMEntity.WMEntityDocument)
' alle Objekttypen durchlaufen und nach dem mit dem angegebenen Namen suchen
For Each oObjectType As WMObject In oObjectTypes
If oObjectType.aName = objekttypName Then
Return oObjectType
End If
Next
Return Nothing
Catch ex As Exception
MsgBox("Es konnte ein Objekttyp nicht erstellt werden." & vbNewLine & vbNewLine & "Fehlernachricht:" & vbNewLine & ex.Message, MsgBoxStyle.Exclamation, "Objekttyp konnte nicht erstellt werden")
Return Nothing
End Try
End Function
''' <summary>
''' Überprüft ob der angegebene Index im Objekttyp existiert
@ -490,117 +405,66 @@ Public Class ClassWindream
Return ""
End Function
''' <summary>
''' Liefert das Windream-Laufwerk des windream-Servers, in Form '[Laufwerksbuchstabe]:'. (z.B. 'W:')
''' </summary>
''' <returns>Laufwerksbuchstabe mit Doppelpunkt als String</returns>
''' <remarks></remarks>
'Public Function GetWindreamDriveLetter() As String
' Try
' Dim oControl As AISCONTROLDATACOMLib.AISControlData
' Dim sDrive As String = ""
' oControl = New AISCONTROLDATACOMLib.AISControlData
' sDrive = oControl.GetStringValue(&H10040003)
' Return sDrive & ":"
' Catch ex As Exception
' MsgBox("Fehlernachricht: " & ex.Message, MsgBoxStyle.Critical, "Unexpected error inm Auslesen des windream-Laufwerks")
' End Try
' Return ""
'End Function
''' <summary>
''' Liefert den Typen eines Indexes als Integer.
''' </summary>
''' <param name="indexname">Name des zu überprüfenden Indexfeldes</param>
''' <returns>Liefert eine Zahl, die einen Typen beschreibt</returns>
''' <remarks></remarks>
Public Function GetValuesfromAuswahlliste(ByVal _auswahlliste As String) As Object
Try
'Dim oAttribute = Me.oSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, indexname)
'Dim vType = oAttribute.getVariableValue("vItems")
'Return vType
Dim oChoiceList = _session.GetWMObjectByName(WMEntityChoiceList, _auswahlliste)
If Err.Number = 0 And TypeName(oChoiceList) <> "Nothing" Then
Dim Values = oChoiceList
Values = oChoiceList.GetVariableValue("vItems")
Dim anz As Integer = 0
For Each CLItem In Values
If oChoiceList.aName IsNot Nothing Then
anz += 1
End If
Next
Dim strListe(anz - 1)
Dim zahl As Integer = 0
For Each CLItem In Values
If oChoiceList.aName IsNot Nothing Then
strListe(zahl) = CLItem
zahl += 1
End If
Next
Return strListe
Else
MsgBox("Auswahlliste: " & _auswahlliste & " nicht gefunden!", MsgBoxStyle.Critical, "Fehler:")
Return Nothing
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler in GetValuesfromAuswahlliste:")
Return Nothing
End Try
End Function
#End Region
Public Shared Function Stream_File(ByVal SourceFilePath As String, ByVal NewFileName As String)
On Error Resume Next
_currentWMObject = Nothing
Dim oDestination As String = Path.GetDirectoryName(NewFileName)
Dim oWindreamFilename As String = NewFileName
Dim oFileName As String = NewFileName
If NewFileName.StartsWith("W:") Then
oFileName = NewFileName.Replace("W:", vWLaufwerk)
oWindreamFilename = NewFileName.Replace("W:", String.Empty)
Else
oWindreamFilename = NewFileName.Replace(vWLaufwerk, String.Empty)
End If
Dim oSourceFilename As String = Path.GetFileName(SourceFilePath)
Dim oDestination As String = Path.GetDirectoryName(oFileName)
If My.Computer.FileSystem.DirectoryExists(oDestination) = False Then
My.Computer.FileSystem.CreateDirectory(oDestination)
LOGGER.Info(" - Zielverzeichnis neu erzeugt!")
End If
Const STREAM_BinaryObject = "BinaryObject"
LOGGER.Info(" ...Stream_File wurde gestartet")
Dim oWindreamFilename As String = ""
' Objekt für Datei und Zielverzeichnis anlegen
Dim oSourceFilename As String = Path.GetFileName(SourceFilePath)
LOGGER.Info(" ...Quelldatei gelesen")
'"Version-KZ entfernen
NewFileName = NewFileName.Replace("\\", "\")
oWindreamFilename = NewFileName.Substring(2)
If oWindreamFilename.Contains("[%Version]") Then
oWindreamFilename = oWindreamFilename.Replace("[%Version]", "")
NewFileName = oWindreamFilename
End If
'If oWindreamFilename.Contains("[%Version]") Then
' oWindreamFilename = oWindreamFilename.Replace("[%Version]", "")
' NewFileName = oWindreamFilename
'End If
'If NewFileName.StartsWith("W:") Then
' NewFileName = NewFileName.Replace("W:", vWLaufwerk)
' oWindreamFilename = NewFileName.Replace(vWLaufwerk, String.Empty)
'End If
If My.Computer.FileSystem.DirectoryExists(oDestination) Then
LOGGER.Info(" ...targetPath existiert")
' Überprüfen ob der zu Kopieren notwendige Speicherplatz auf Ziellaufwerk vorhanden ist
Dim oDriveInfo As New DriveInfo(vWLaufwerk & ":")
Dim oFreeSpace = oDriveInfo.TotalFreeSpace
Dim oFileInfo As New FileInfo(SourceFilePath)
' Get length of the file.
Dim oFileLength As Long = oFileInfo.Length
If oFreeSpace < oFileLength Then
If USER_LANGUAGE = "de-DE" Then
MsgBox("Auf dem Zielverzeichnis ist nicht genug Speicherplatz zum Übertragen frei.", MsgBoxStyle.Exclamation, "Nicht genug Speicherplatz")
Else
MsgBox("Not enough diskspace in Target-Directory.", MsgBoxStyle.Exclamation, "Not enough diskspace")
End If
Return -10
End If
'If vWLaufwerk.Count = 1 Then
' Dim oDriveInfo As New DriveInfo(vWLaufwerk & ":")
' Dim oFreeSpace = oDriveInfo.TotalFreeSpace
' If oFreeSpace < oFileLength Then
' If USER_LANGUAGE = "de-DE" Then
' MsgBox("Auf dem Zielverzeichnis ist nicht genug Speicherplatz zum Übertragen frei.", MsgBoxStyle.Exclamation, "Nicht genug Speicherplatz")
' Else
' MsgBox("Not enough diskspace in Target-Directory.", MsgBoxStyle.Exclamation, "Not enough diskspace")
' End If
' Return -10
' End If
'End If
LOGGER.Info(" ...Datei kopieren von '" & SourceFilePath & "' nach '" & NewFileName & "'.")
Dim Connect
@ -696,25 +560,6 @@ Public Class ClassWindream
End If
End Select
'If CURRENT_DOKART_DUPLICATE_HANDLING = "Default" Or CURRENT_DOKART_DUPLICATE_HANDLING = "Question" Then
' ''##########
' Dim msg = String.Format("Eine Datei mit identischem Namen " & vbNewLine & "'{0}'" & vbNewLine & "existiert bereits!" & vbNewLine & "Wollen Sie die bestehende Datei ersetzen?", newfilename)
' If USER_LANGUAGE <> "de-DE" Then
' msg = "There is already a file with the same name! Would You like to replace the file?"
' End If
' Dim result As MsgBoxResult
' result = MessageBox.Show(msg, "File alredy exists:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
' If result = MsgBoxResult.No Then
' windreamFilename = ClassFilehandle.Versionierung_Datei(newfilename).ToString.Substring(2)
' Else
' If Delete_WDFile(windreamFilename) = False Then
' Return False
' End If
' End If
'ElseIf CURRENT_DOKART_DUPLICATE_HANDLING = "New version" Then
' windreamFilename = ClassFilehandle.Versionierung_Datei(newfilename).ToString.Substring(2)
'End If
WMObject = Session.GetNewWMObjectFS(1, oWindreamFilename, 31) 'WMEntityDocument, windreamFilename, WMObjectEditModeObject
If Err.Number > 0 Then
LOGGER.Info(" FEHLER: Neues WMObject (Kopie) konnte nicht erzeugt werden - Error: '" & Err.Description & "'")
@ -724,7 +569,7 @@ Public Class ClassWindream
End If
LOGGER.Info(" ...ENDGÜLTIGER DATEINAME => " & oWindreamFilename)
If WMObject IsNot Nothing Then
NewFileName = vWLaufwerk & ":" & oWindreamFilename
'NewFileName = vWLaufwerk & ":" & oWindreamFilename
' lock object for file system access (to change the file itself)
WMObject.lock()
' set fileIO the local source file
@ -796,27 +641,31 @@ Public Class ClassWindream
'MsgBox(Err.Description)
End If
'DATEI GRÖSSE ERMITTELN - MANCHMAL KOMMT ES VOR DAS DATEIGRÖße 0 ist
Dim info2 As New FileInfo(NewFileName)
Dim info2 As New FileInfo(oFileName)
Dim length1 As Long = info2.Length
LOGGER.Info(" ...Length der Zieldatei: " & length1.ToString)
If oFileLength > 0 And Err.Number = 0 Then
Dim p As String
If oWindreamFilename.StartsWith("\") Then
If oWindreamFilename.StartsWith("\\") Then
p = oWindreamFilename.Replace("\\", "\")
Else
p = oWindreamFilename
End If
Else
p = "\" & oWindreamFilename
End If
CURRENT_NEWFILENAME = vWLaufwerk & ":" & p
'Dim p As String
'If oWindreamFilename.StartsWith("\") Then
' If oWindreamFilename.StartsWith("\\") Then
' p = oWindreamFilename.Replace("\\", "\")
' Else
' p = oWindreamFilename
' End If
'Else
' p = "\" & oWindreamFilename
'End If
'CURRENT_NEWFILENAME = vWLaufwerk & ":" & p
CURRENT_NEWFILENAME = oFileName
LOGGER.Info(" >> Datei '" & CURRENT_NEWFILENAME & "' wurde erfolgreich importiert!")
_currentWMObject = WMObject
Return True
Else
Delete_WDFile(oWindreamFilename)
Console.WriteLine(Err.Number.ToString)
LOGGER.Info("Error Number: [{0}]", Err.Number)
LOGGER.Info(" Unexpected error in Datei-Übertragen - FileLength ist 0, Übertragene Datei wurde gelöscht")
Return False
End If

View File

@ -272,7 +272,7 @@ Public Class frmAdministration
MyDataset.TBDD_DOKUMENTART.ERSTELLTWERColumn.DefaultValue = Environment.UserName
MyDataset.TBDD_DOKUMENTART.OBJEKTTYPColumn.DefaultValue = ""
MyDataset.TBDD_DOKUMENTART.NAMENKONVENTIONColumn.DefaultValue = "[%vOFilename]-[%vYY_MM_DD]-[%Version]"
MyDataset.TBDD_DOKUMENTART.NAMENKONVENTIONColumn.DefaultValue = "[%vOFilename]-[%vYY_MM_DD]"
MyDataset.TBDD_DOKUMENTART.DUPLICATE_HANDLINGColumn.DefaultValue = "New version"
IsInsert = True
End Sub
@ -674,9 +674,9 @@ Public Class frmAdministration
lbFileparameter.Visible = True
btnAddWindowsVariable.Visible = True
End If
If IsInsert = False Then
Save_IndexAuto()
End If
'If IsInsert = False Then
' Save_IndexAuto()
'End If
End If
End Sub

View File

@ -28,6 +28,8 @@ Public Class frmIndex
Private NewFileString As String
Private CancelAttempts As Integer = 0
Private Const MaxCancelAttempts = 2
Private Property ViewerString As String
#End Region
@ -234,7 +236,7 @@ Public Class frmIndex
End Try
End Function
Function GetAutomaticIndexSQLValue(vsqlstatement As String, vconnectionID As Integer, vProvider As String) As String
Function GetAutomaticIndexSQLValue(SQLCommand As String, vconnectionID As Integer, vProvider As String) As String
Try
Dim oConnectionString As String
oConnectionString = ClassFormFunctions.GetConnectionString(vconnectionID)
@ -243,9 +245,9 @@ Public Class frmIndex
Dim oErgebnis
'Welcher Provider?
If vProvider.ToLower = "oracle" Then
oErgebnis = ClassDatabase.OracleExecute_Scalar(vsqlstatement, oConnectionString)
oErgebnis = ClassDatabase.OracleExecute_Scalar(SQLCommand, oConnectionString)
Else 'im Moment nur SQL-Server
oErgebnis = ClassDatabase.Execute_Scalar(vsqlstatement, oConnectionString)
oErgebnis = ClassDatabase.Execute_Scalar(SQLCommand, oConnectionString)
End If
If LogErrorsOnly = False Then
@ -768,8 +770,6 @@ Public Class frmIndex
Return False
End If
End If
Catch ex As Exception
LOGGER.Info("Unvorhergesehener Unexpected error in Write_Indizes - Fehler: " & vbNewLine & ex.Message)
LOGGER.Error(ex.Message)
@ -1356,7 +1356,13 @@ Public Class frmIndex
'TODO: Load License from DB
DocumentViewer1.Init(LOGCONFIG, VIEWER_LICENSE)
If DropType Is Nothing Then
LOGGER.Warn("File with Id [{0}] was not found in TBGI_FILES_USER. Exiting.")
CancelAttempts = MaxCancelAttempts
Close()
Else
CURRENT_DROPTYPE = DropType.Replace("|", "")
If DropType = "|DROPFROMFSYSTEM|" Then
checkItemDeleteSource.Enabled = True
checkItemDeleteSource.Checked = CURR_DELETE_ORIGIN
@ -1438,6 +1444,9 @@ Public Class frmIndex
BarButtonItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End If
End If
Catch ex As Exception
LOGGER.Info(" - Unexpected error in Öffnen des Formulares - Fehler: " & vbNewLine & ex.Message)
LOGGER.Error(ex.Message)
@ -1785,6 +1794,10 @@ Public Class frmIndex
LOGGER.Info(" oSqlResult afrer first Replace: " & oSqlResult)
End If
'TODO: Replace Windream Patterns?
oSqlResult = ClassPatterns.ReplaceControlValues(oSqlResult, pnlIndex)
oSqlResult = ClassPatterns.ReplaceInternalValues(oSqlResult)
' Ergebnis: Es wurden alle einfachen Platzhalter ersetzt, jetzt haben wir einen SQL Befehl,
' der nur noch vektorfelder-platzhalter enthält