Compare commits

..

3 Commits

Author SHA1 Message Date
a159516c6b Modules.Jobs: Version 3.9.1.0 2026-11-09 14:02:25 +01:00
462600d1b3 Modules.Jobs: Dateien löschen, falls Prüfung fehlschlägt 2026-11-09 14:01:33 +01:00
Developer01
a6ae874873 Verbesserung der Fehlerbehandlung und Protokollierung
Neue Konstanten und Wiederholungslogik in `ActiveDirectoryInterface.vb` hinzugefügt, um vorübergehende AD-Fehler zu handhaben. Funktion `IsTransientAdException` implementiert. Verbesserte Benutzer-Synchronisierungslogik in `SyncUsers.MSSQL.vb`, um unnötige Löschvorgänge zu vermeiden. Versionsnummern in `AssemblyInfo.vb` aktualisiert. Warnmeldungen und Index-Typ-Überprüfung in `Windream.vb` verbessert. NLog-Verwaltung in `Windream.vbproj` auf NuGet umgestellt und entsprechende Referenz aus `packages.config` entfernt.
2026-11-03 10:36:24 +01:00
9 changed files with 202 additions and 129 deletions

View File

@@ -1,6 +1,8 @@
Imports System.DirectoryServices Imports System.DirectoryServices
Imports System.DirectoryServices.AccountManagement Imports System.DirectoryServices.AccountManagement
Imports System.Runtime.InteropServices
Imports System.Text.RegularExpressions Imports System.Text.RegularExpressions
Imports System.Threading
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
@@ -13,6 +15,9 @@ Public Class ActiveDirectoryInterface
Private _rootNode As DirectoryEntry Private _rootNode As DirectoryEntry
Private Const SEARCH_LIMIT = 50000 Private Const SEARCH_LIMIT = 50000
Private Const AD_RETRY_COUNT = 3
Private Const AD_RETRY_DELAY_MS = 5000
Private Const LDAP_SERVER_NOT_OPERATIONAL As Integer = &H8007203A
Private Const SAMACCOUNTNAME = "samaccountname" Private Const SAMACCOUNTNAME = "samaccountname"
Private Const OBJECTCLASS = "objectClass" Private Const OBJECTCLASS = "objectClass"
@@ -47,9 +52,7 @@ Public Class ActiveDirectoryInterface
End Function End Function
Public Function SyncUsersForGroup(GroupName As String, AttributeMappings As List(Of AttributeMapping), MSSQL As MSSQLServer, Optional Filter As String = DEFAULT_USER_FILTER) As List(Of ADUser) Public Function SyncUsersForGroup(GroupName As String, AttributeMappings As List(Of AttributeMapping), MSSQL As MSSQLServer, Optional Filter As String = DEFAULT_USER_FILTER) As List(Of ADUser)
Dim oUsers As New List(Of ADUser) Dim oUsers As List(Of ADUser)
Dim oSyncedUsers As New List(Of ADUser)
Dim oGroupId As Int64 = Nothing
Dim oSQLSync As New SyncUsers.SyncUsersMSSQL(_logConfig, MSSQL) Dim oSQLSync As New SyncUsers.SyncUsersMSSQL(_logConfig, MSSQL)
Dim oSyncedUsersMSSQL As List(Of ADUser) Dim oSyncedUsersMSSQL As List(Of ADUser)
@@ -57,13 +60,18 @@ Public Class ActiveDirectoryInterface
Try Try
_logger.Debug("Fetching users from ActiveDirectory") _logger.Debug("Fetching users from ActiveDirectory")
oUsers = ListUsers(GroupName, AttributeMappings, Filter) oUsers = ListUsers(GroupName, AttributeMappings, Filter)
If oUsers Is Nothing Then
_logger.Warn("ActiveDirectory query failed for group [{0}]. Sync skipped.", GroupName)
Return Nothing
End If
_logger.Debug("Found {0} users", oUsers.Count) _logger.Debug("Found {0} users", oUsers.Count)
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
Return Nothing Return Nothing
End Try End Try
' Do the actual sync into MSSQL
If MSSQL IsNot Nothing Then If MSSQL IsNot Nothing Then
oSyncedUsersMSSQL = oSQLSync.SyncUsers(GroupName, oUsers, AttributeMappings) oSyncedUsersMSSQL = oSQLSync.SyncUsers(GroupName, oUsers, AttributeMappings)
If oSyncedUsersMSSQL.Count > 0 Then If oSyncedUsersMSSQL.Count > 0 Then
@@ -138,11 +146,11 @@ Public Class ActiveDirectoryInterface
Public Async Function ListUsersAsync(GroupName As String, Optional Filter As String = DEFAULT_USER_FILTER) As Task(Of List(Of ADUser)) Public Async Function ListUsersAsync(GroupName As String, Optional Filter As String = DEFAULT_USER_FILTER) As Task(Of List(Of ADUser))
Return Await Task.Run(Function() ListUsers(GroupName, Filter)) Return Await Task.Run(Function() ListUsers(GroupName, Filter))
End Function End Function
Public Function ListUsers(GroupName As String, AttributeMappings As List(Of AttributeMapping), Optional Filter As String = DEFAULT_USER_FILTER) As List(Of ADUser) Public Function ListUsers(GroupName As String, AttributeMappings As List(Of AttributeMapping), Optional Filter As String = DEFAULT_USER_FILTER) As List(Of ADUser)
For oAttempt As Integer = 1 To AD_RETRY_COUNT
Try
Dim oUsers As New List(Of ADUser) Dim oUsers As New List(Of ADUser)
Try
Using oContext As New PrincipalContext(ContextType.Domain) Using oContext As New PrincipalContext(ContextType.Domain)
Using oGroupPrincipal As GroupPrincipal = GroupPrincipal.FindByIdentity(oContext, IdentityType.Name, GroupName) Using oGroupPrincipal As GroupPrincipal = GroupPrincipal.FindByIdentity(oContext, IdentityType.Name, GroupName)
If oGroupPrincipal Is Nothing Then If oGroupPrincipal Is Nothing Then
@@ -166,33 +174,23 @@ Public Class ActiveDirectoryInterface
_logger.Debug("User [{0}] was skipped out due to user filter.", oUserEx.SamAccountName) _logger.Debug("User [{0}] was skipped out due to user filter.", oUserEx.SamAccountName)
Continue For Continue For
End If End If
_logger.Debug("User [{0}] passed the filter.", oUserEx.SamAccountName)
' TODO: Figure out why oUserEx can be nothing for certain users
If oUserEx IsNot Nothing Then If oUserEx IsNot Nothing Then
For Each oMap As AttributeMapping In AttributeMappings For Each oMap As AttributeMapping In AttributeMappings
Dim oAttributeValue = oUserEx.GetAttributeValue(oMap.AttributeName) Dim oAttributeValue = oUserEx.GetAttributeValue(oMap.AttributeName)
If oAttributeValue <> String.Empty Then If oAttributeValue <> String.Empty Then
_logger.Debug("Attribute [{0}] is not empty.", oMap.AttributeName)
oCustomAttributes.Add(New ADUser.CustomAttribute() With { oCustomAttributes.Add(New ADUser.CustomAttribute() With {
.Name = oMap.AttributeName, .Name = oMap.AttributeName,
.Value = oAttributeValue, .Value = oAttributeValue,
.FirebirdSyskey = oMap.FirebirdSyskey, .FirebirdSyskey = oMap.FirebirdSyskey,
.MSSQLColumn = oMap.MSSQLColumn .MSSQLColumn = oMap.MSSQLColumn
}) })
Else
_logger.Debug("Attribute [{0}] is empty.", oMap.AttributeName)
End If End If
Next Next
Else
_logger.Debug("Could not fetch CustomAttributes for user [{0}]", oUser)
End If End If
_logger.Debug("Trying to add User [{0}] to user list", oUser) oUsers.Add(New ADUser With {
Dim oNewUser As New ADUser With {
.SId = oUser.Sid, .SId = oUser.Sid,
.samAccountName = oUser.SamAccountName, .samAccountName = oUser.SamAccountName,
.Middlename = oUser.MiddleName, .Middlename = oUser.MiddleName,
@@ -201,9 +199,7 @@ Public Class ActiveDirectoryInterface
.GUID = oUser.Guid, .GUID = oUser.Guid,
.Email = oUser.EmailAddress, .Email = oUser.EmailAddress,
.CustomAttributes = oCustomAttributes .CustomAttributes = oCustomAttributes
} })
oUsers.Add(oNewUser)
End If End If
Catch ex As Exception Catch ex As Exception
_logger.Warn("User could not be processed") _logger.Warn("User could not be processed")
@@ -216,10 +212,46 @@ Public Class ActiveDirectoryInterface
Return oUsers Return oUsers
Catch ex As Exception Catch ex As Exception
If IsTransientAdException(ex) AndAlso oAttempt < AD_RETRY_COUNT Then
_logger.Warn("ActiveDirectory unavailable (attempt {0}/{1}) for group [{2}]. Retrying in {3} ms.", oAttempt, AD_RETRY_COUNT, GroupName, AD_RETRY_DELAY_MS)
Thread.Sleep(AD_RETRY_DELAY_MS)
Continue For
End If
_logger.Error(ex) _logger.Error(ex)
Return oUsers
If IsTransientAdException(ex) Then
_logger.Warn("ActiveDirectory unavailable after {0} attempts for group [{1}]. Returning Nothing.", AD_RETRY_COUNT, GroupName)
Return Nothing
End If
Return New List(Of ADUser)
End Try End Try
Next
Return Nothing
End Function End Function
Private Function IsTransientAdException(ex As Exception) As Boolean
Dim oCurrent = ex
While oCurrent IsNot Nothing
If TypeOf oCurrent Is COMException Then
Dim oComEx = DirectCast(oCurrent, COMException)
If oComEx.ErrorCode = LDAP_SERVER_NOT_OPERATIONAL Then
Return True
End If
End If
If oCurrent.Message IsNot Nothing AndAlso oCurrent.Message.IndexOf("The server is not operational", StringComparison.OrdinalIgnoreCase) >= 0 Then
Return True
End If
oCurrent = oCurrent.InnerException
End While
Return False
End Function
Private Function GetPartFromFirstOU(dnString As String) As String Private Function GetPartFromFirstOU(dnString As String) As String
Dim keyword As String = "OU=" Dim keyword As String = "OU="
Dim index As Integer = dnString.IndexOf(keyword) Dim index As Integer = dnString.IndexOf(keyword)

View File

@@ -26,6 +26,11 @@ Namespace SyncUsers
Dim oCreatedUsers As New List(Of ADUser) Dim oCreatedUsers As New List(Of ADUser)
Dim oUpdatedUsers As New List(Of ADUser) Dim oUpdatedUsers As New List(Of ADUser)
If Users Is Nothing Then
_logger.Warn("SyncUsers aborted: Users is Nothing. Skipping sync and delete step for group [{0}].", GroupName)
Return oSyncedUsers
End If
Try Try
_logger.Debug("Getting group Id for group {0}", GroupName) _logger.Debug("Getting group Id for group {0}", GroupName)
oGroupId = GetGroupId(GroupName) oGroupId = GetGroupId(GroupName)
@@ -45,7 +50,6 @@ Namespace SyncUsers
Dim oUserId As Long Dim oUserId As Long
Dim oUserExists As Boolean Dim oUserExists As Boolean
' Check if user already exists
Try Try
_logger.Debug("Checking if user [{0}] exists", oUser) _logger.Debug("Checking if user [{0}] exists", oUser)
oUserId = GetUserId(oUser.samAccountName) oUserId = GetUserId(oUser.samAccountName)
@@ -57,38 +61,32 @@ Namespace SyncUsers
Continue For Continue For
End Try End Try
' Collect user ids from existing users
If oUserExists Then
oSyncedUserIds.Add(oUserId)
End If
' Create or update user
Try Try
If Not oUserExists Then If Not oUserExists Then
_logger.Debug("Creating new user for [{0}]", oUser) _logger.Debug("Creating new user for [{0}]", oUser)
oUserId = CreateUser(oUser) oUserId = CreateUser(oUser)
_logger.Debug("User created with Id [{0}]", oUserId) _logger.Debug("User created with Id [{0}]", oUserId)
_logger.Info("Added new User [{0}]", oUser) _logger.Info("Added new User [{0}]", oUser)
oCreatedUsers.Add(oUser) oCreatedUsers.Add(oUser)
Else Else
_logger.Debug("Updating user [{0}]", oUser) _logger.Debug("Updating user [{0}]", oUser)
oUserId = UpdateUser(oUser) oUserId = UpdateUser(oUser)
If oUserId <> 0 Then If oUserId <> 0 Then
_logger.Debug("User created with Id [{0}]", oUserId) _logger.Debug("User updated with Id [{0}]", oUserId)
_logger.Info("Updated User [{0}]", oUser) _logger.Info("Updated User [{0}]", oUser)
oUpdatedUsers.Add(oUser) oUpdatedUsers.Add(oUser)
End If End If
End If End If
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
_logger.Warn("Could Not create/update user [{0}]. Skipping.", oUser) _logger.Warn("Could Not create/update user [{0}]. Skipping.", oUser)
Continue For Continue For
End Try End Try
' Add custom attributes to user If oUserId > 0 Then
oSyncedUserIds.Add(oUserId)
End If
Try Try
AddCustomAttributesToUser(oUser, oUserId) AddCustomAttributesToUser(oUser, oUserId)
Catch ex As Exception Catch ex As Exception
@@ -96,7 +94,6 @@ Namespace SyncUsers
_logger.Debug("Could Not add custom attributes to user {0}. Continuing.", oUser) _logger.Debug("Could Not add custom attributes to user {0}. Continuing.", oUser)
End Try End Try
' Add the user to group
Try Try
If AddUserToGroup(oUserId, oGroupId) Then If AddUserToGroup(oUserId, oGroupId) Then
_logger.Info("User [{0}] added to group [{1}]", oUser, GroupName) _logger.Info("User [{0}] added to group [{1}]", oUser, GroupName)
@@ -110,26 +107,33 @@ Namespace SyncUsers
oSyncedUsers.Add(oUser) oSyncedUsers.Add(oUser)
Next Next
' Delete users that are assigned to the group but no longer exist in active directory ' Safety: never delete relations on empty source result
Dim oUserIdString = String.Join(",", oSyncedUserIds) If Users.Count = 0 Then
If oSyncedUserIds.Count = 0 Then _logger.Warn("Safety stop: AD returned 0 users for group [{0}]. Delete step skipped.", GroupName)
_logger.Info("Group {0} does not contain any users.", GroupName) Return oSyncedUsers
oUserIdString = 0
End If End If
If oSyncedUserIds.Count > 0 Then
Dim oUserIdString = String.Join(",", oSyncedUserIds.Distinct())
Dim oSQL As String = $"DELETE FROM TBDD_GROUPS_USER WHERE USER_ID NOT IN ({oUserIdString}) AND GROUP_ID = {oGroupId}" Dim oSQL As String = $"DELETE FROM TBDD_GROUPS_USER WHERE USER_ID NOT IN ({oUserIdString}) AND GROUP_ID = {oGroupId}"
Dim oDeletedRelations = _mssql.GetScalarValue(oSQL) Dim oDeleteResult = _mssql.ExecuteNonQuery(oSQL)
If oDeleteResult Then
_logger.Info("User-group relations cleanup executed for group [{0}].", GroupName)
Else
_logger.Warn("User-group relations cleanup failed for group [{0}].", GroupName)
End If
Else
_logger.Warn("Safety stop: No synced user IDs collected for group [{0}]. Delete step skipped.", GroupName)
End If
If oCreatedUsers.Count > 0 Then If oCreatedUsers.Count > 0 Then
_logger.Info("Created [{0}] new users", oCreatedUsers.Count) _logger.Info("Created [{0}] new users", oCreatedUsers.Count)
End If End If
_logger.Info("Updated [{0}] users", oUpdatedUsers.Count) _logger.Info("Updated [{0}] users", oUpdatedUsers.Count)
If oDeletedRelations > 0 Then
_logger.Info("Removed [{0}] users from Group [{1}]", oDeletedRelations, GroupName)
End If
Return oSyncedUsers Return oSyncedUsers
End Function End Function
Private Function AddUserToGroup(UserId As Integer, GroupId As Integer) As Boolean Implements ISyncUsers.AddUserToGroup Private Function AddUserToGroup(UserId As Integer, GroupId As Integer) As Boolean Implements ISyncUsers.AddUserToGroup
Try Try
Dim oSQL = $"SELECT COUNT(*) FROM TBDD_GROUPS_USER WHERE USER_ID = {UserId} And GROUP_ID = {GroupId}" Dim oSQL = $"SELECT COUNT(*) FROM TBDD_GROUPS_USER WHERE USER_ID = {UserId} And GROUP_ID = {GroupId}"

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Interfaces")> <Assembly: AssemblyProduct("Modules.Interfaces")>
<Assembly: AssemblyCopyright("Copyright © 2026")> <Assembly: AssemblyCopyright("Copyright © 2026")>
<Assembly: AssemblyTrademark("2.5.1.0")> <Assembly: AssemblyTrademark("2.5.2.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.5.1.0")> <Assembly: AssemblyVersion("2.5.2.0")>
<Assembly: AssemblyFileVersion("2.5.1.0")> <Assembly: AssemblyFileVersion("2.5.2.0")>

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Jobs")> <Assembly: AssemblyProduct("Modules.Jobs")>
<Assembly: AssemblyCopyright("Copyright © 2026")> <Assembly: AssemblyCopyright("Copyright © 2026")>
<Assembly: AssemblyTrademark("3.9.0.0")> <Assembly: AssemblyTrademark("3.9.1.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern ' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
<Assembly: AssemblyVersion("3.9.0.0")> <Assembly: AssemblyVersion("3.9.1.0")>
<Assembly: AssemblyFileVersion("3.9.0.0")> <Assembly: AssemblyFileVersion("3.9.1.0")>

View File

@@ -868,6 +868,7 @@ Public Class ImportZUGFeRDFiles
_logger.Error("Could not save File to Disk!") _logger.Error("Could not save File to Disk!")
Dim oReasonString = "Could not save file " + newAttachmentFilename + " to disk." Dim oReasonString = "Could not save file " + newAttachmentFilename + " to disk."
AddRejectedState(pMessageId, oReasonString, "EMBEDDED FILE CONSISTENCY NOT OK", "Info GUI", pConnections.SQLServerTransaction) AddRejectedState(pMessageId, oReasonString, "EMBEDDED FILE CONSISTENCY NOT OK", "Info GUI", pConnections.SQLServerTransaction)
nextAttachmentIndex += 1
Continue For Continue For
End If End If
@@ -875,6 +876,11 @@ Public Class ImportZUGFeRDFiles
_logger.Error("Could not save File to Disk!") _logger.Error("Could not save File to Disk!")
Dim oReasonString = "Validation of file " + newAttachmentFilename + " on disk was NOT succesfully." Dim oReasonString = "Validation of file " + newAttachmentFilename + " on disk was NOT succesfully."
AddRejectedState(pMessageId, oReasonString, "EMBEDDED FILE CONSISTENCY NOT OK", "Info GUI", pConnections.SQLServerTransaction) AddRejectedState(pMessageId, oReasonString, "EMBEDDED FILE CONSISTENCY NOT OK", "Info GUI", pConnections.SQLServerTransaction)
' Datei ist Murks und muss gelöscht werden, wenn möglich
DeleteFileFromDisk(embeddedFilePath)
nextAttachmentIndex += 1
Continue For Continue For
End If End If
@@ -920,6 +926,20 @@ Public Class ImportZUGFeRDFiles
End Try End Try
End Function End Function
Private Function DeleteFileFromDisk(pEmbeddedFilePath As String) As Boolean
Try
Dim oFile As FileInfo = New FileInfo(pEmbeddedFilePath)
If oFile IsNot Nothing Then
oFile.Delete()
End If
Return True
Catch ex As Exception
_logger.Warn("Coul not delete file {0}.", pEmbeddedFilePath)
Return False
End Try
End Function
Private Function GetEmbeddedFileExtension(pMimeTypeValue As String) As String Private Function GetEmbeddedFileExtension(pMimeTypeValue As String) As String
If pMimeTypeValue.IsNullOrEmpty() Then If pMimeTypeValue.IsNullOrEmpty() Then

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.9.8.0")> <Assembly: AssemblyVersion("2.0.0.0")>
<Assembly: AssemblyFileVersion("1.9.8.0")> <Assembly: AssemblyFileVersion("2.0.0.0")>

View File

@@ -1244,7 +1244,7 @@ Public Class Windream
Dim oWMObject As IWMObject6 = GetFileByPath(Path) Dim oWMObject As IWMObject6 = GetFileByPath(Path)
If LockObject(oWMObject, WMObjectEditModeIndexEdit) = False Then If LockObject(oWMObject, WMObjectEditModeIndexEdit) = False Then
_logger.Warn("File {0} could not be locked") _logger.Warn("File {0} could not be locked", Path)
Return False Return False
End If End If
@@ -1254,7 +1254,14 @@ Public Class Windream
Try Try
Dim oType As Integer = GetIndexType(pIndexName) Dim oType As Integer = GetIndexType(pIndexName)
If Not IsNothing(oType) Then
' IsNothing() schlägt bei Integer (Werttyp) nie an – stattdessen auf Undefined (0) prüfen
If oType = WMObjectVariableValueTypeUndefined Then
_logger.Warn("Index '{0}' not found or has undefined type – SetFileIndex aborted for file '{1}'", pIndexName, Path)
UnlockObject(oWMObject)
Return False
End If
Dim oConvertedValue As Object = Helpers.ConvertIndexValue(oType, pStringValue) Dim oConvertedValue As Object = Helpers.ConvertIndexValue(oType, pStringValue)
oWMObject.SetVariableValue(pIndexName, oConvertedValue) oWMObject.SetVariableValue(pIndexName, oConvertedValue)
@@ -1265,11 +1272,8 @@ Public Class Windream
End If End If
Return True Return True
Else
Return False
End If
Catch ex As Exception Catch ex As Exception
_logger.Warn("Could not set value '{0}' for index '{1}' on file '{2}'", pStringValue, pIndexName, Path)
_logger.Error(ex) _logger.Error(ex)
UnlockObject(oWMObject) UnlockObject(oWMObject)
Return False Return False
@@ -1285,6 +1289,7 @@ Public Class Windream
_logger.Warn("File '{0}' does not exist", pPath) _logger.Warn("File '{0}' does not exist", pPath)
Return False Return False
End If End If
Dim oWMObject As IWMObject6 Dim oWMObject As IWMObject6
Try Try
@@ -1295,9 +1300,10 @@ Public Class Windream
_logger.Warn(ex.Message) _logger.Warn(ex.Message)
Return False Return False
End Try End Try
'Lock WMObject for changes 'Lock WMObject for changes
If LockObject(oWMObject, WMObjectEditModeIndexEdit) = False Then If LockObject(oWMObject, WMObjectEditModeIndexEdit) = False Then
_logger.Warn("File {0} could not be locked") _logger.Warn("File '{0}' could not be locked", pPath)
Return False Return False
End If End If
@@ -1307,9 +1313,18 @@ Public Class Windream
Try Try
Dim oType As Integer = GetIndexType(pIndexName) Dim oType As Integer = GetIndexType(pIndexName)
Dim oConvertedValues As New List(Of String)
Dim oArray As Object ' Gleicher Bug wie in SetFileIndex: Integer-Werttyp – IsNothing() greift nie
' Stattdessen auf Undefined (0) prüfen
If oType = WMObjectVariableValueTypeUndefined Then
_logger.Warn("Index '{0}' not found or has undefined type – SetFileIndexLoS aborted for file '{1}'", pIndexName, pPath)
UnlockObject(oWMObject)
Return False
End If
_logger.Debug("SetFileIndexLoS '{0}' - Indextype: {1} - Values.Count: {2} ... ", pIndexName, oType, pAttributeValues.Count) _logger.Debug("SetFileIndexLoS '{0}' - Indextype: {1} - Values.Count: {2} ... ", pIndexName, oType, pAttributeValues.Count)
Dim oArray As Object
ReDim oArray(pAttributeValues.Count - 1) ReDim oArray(pAttributeValues.Count - 1)
For oIndex = 0 To pAttributeValues.Count - 1 For oIndex = 0 To pAttributeValues.Count - 1
@@ -1322,13 +1337,14 @@ Public Class Windream
oWMObject.Save() oWMObject.Save()
If UnlockObject(oWMObject) = False Then If UnlockObject(oWMObject) = False Then
_logger.Warn("File {0} could not be unlocked", pPath) _logger.Warn("File '{0}' could not be unlocked", pPath)
End If End If
Return True Return True
Catch ex As Exception Catch ex As Exception
_logger.Warn("Could not set value for index '{0}' on file '{1}'", pIndexName, pPath)
_logger.Error(ex) _logger.Error(ex)
UnlockObject(oWMObject)
Return False Return False
End Try End Try
End Function End Function

View File

@@ -65,9 +65,6 @@
<EmbedInteropTypes>True</EmbedInteropTypes> <EmbedInteropTypes>True</EmbedInteropTypes>
</Reference> </Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.0.5\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
@@ -81,6 +78,11 @@
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="NLog">
<Version>5.0.5</Version>
</PackageReference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Import Include="Microsoft.VisualBasic" /> <Import Include="Microsoft.VisualBasic" />
<Import Include="System" /> <Import Include="System" />

View File

@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="DigitalData.Modules.Logging" version="2.6.5" targetFramework="net462" /> <package id="DigitalData.Modules.Logging" version="2.6.5" targetFramework="net462" />
<package id="NLog" version="5.0.5" targetFramework="net461" />
</packages> </packages>