From 2991b52c17ad37481e5dcf08d415b68cd122e030 Mon Sep 17 00:00:00 2001 From: Developer01 Date: Fri, 16 May 2025 11:54:14 +0200 Subject: [PATCH 1/4] MS Parameter renaming --- Database/Adapters/MSSQLServer.vb | 7 +++++++ Database/Queries.vb | 3 +++ 2 files changed, 10 insertions(+) diff --git a/Database/Adapters/MSSQLServer.vb b/Database/Adapters/MSSQLServer.vb index 0ec2564f..ccb0c711 100644 --- a/Database/Adapters/MSSQLServer.vb +++ b/Database/Adapters/MSSQLServer.vb @@ -159,6 +159,13 @@ Public Class MSSQLServer Return oGDPicture End Using End Function + Public Function GetDDCatalog() As DataTable + Using oConnection As SqlConnection = GetSQLConnection() + Dim oSQL = Queries.DD_ECM.DD_SELECTS.TBDD_CATALOG + Dim oDT_CATALOG As DataTable = GetDatatable(oSQL) + Return oDT_CATALOG + End Using + End Function Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String Dim oConnectionString As String = String.Empty diff --git a/Database/Queries.vb b/Database/Queries.vb index 637d518b..a8188bcd 100644 --- a/Database/Queries.vb +++ b/Database/Queries.vb @@ -4,6 +4,9 @@ Public Const GdPictureLicense As String = "SELECT COALESCE(MAX(LICENSE),'') FROM TBDD_3RD_PARTY_MODULES WHERE ACTIVE = 1 AND NAME = 'GDPICTURE' AND [VERSION] = '11.2024'" Public Const GdPictureLicense_REGULAR As String = "SELECT COALESCE(MAX(LICENSE),'') FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE' AND ACTIVE = 1" End Class + Public Class DD_SELECTS + Public Const TBDD_CATALOG As String = "SELECT * FROM TBDD_CATALOG" + End Class Public Class Connections Public Const AllConnections As String = "SELECT * FROM TBDD_CONNECTION AND AKTIV = 1" From ffa8850bf1916a07d881460535add6fbdea97f38 Mon Sep 17 00:00:00 2001 From: Developer01 Date: Wed, 21 May 2025 08:08:32 +0200 Subject: [PATCH 2/4] Modules FileParams --- Patterns/Modules/Internal.vb | 5 ++++ Patterns/Patterns.vb | 49 +++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Patterns/Modules/Internal.vb b/Patterns/Modules/Internal.vb index c7cc56d7..03778803 100644 --- a/Patterns/Modules/Internal.vb +++ b/Patterns/Modules/Internal.vb @@ -13,6 +13,11 @@ Namespace Modules Public Const INT_VALUE_DOMAIN = "DOMAIN" Public Const INT_VALUE_DATE = "DATE" + Public Const INT_VALUE_FILENAME_EXT = "FILENAME_EXT" + Public Const INT_VALUE_FILENAME = "FILENAME_ONLY" + Public Const INT_VALUE_FILE_DATE = "FILE_DATE" + Public Const INT_VALUE_FILEEXT = "FILE_EXT" + Public Const INT_VALUE_DATE_YYYY = "YYYY" Public Const INT_VALUE_DATE_MM = "MM" Public Const INT_VALUE_DATE_DD = "DD" diff --git a/Patterns/Patterns.vb b/Patterns/Patterns.vb index c5fac360..859c27ff 100644 --- a/Patterns/Patterns.vb +++ b/Patterns/Patterns.vb @@ -1,4 +1,5 @@ -Imports System.Text.RegularExpressions +Imports System.IO +Imports System.Text.RegularExpressions Imports System.Windows.Forms Imports DigitalData.Modules.Logging Imports DigitalData.Modules.ZooFlow @@ -36,6 +37,12 @@ Public Class ClassPatterns Public Const INT_VALUE_DOMAIN = "DOMAIN" Public Const INT_VALUE_DATE = "DATE" + Public Const INT_VALUE_FILENAME_EXT = "FILENAME_EXT" + Public Const INT_VALUE_FILENAME = "FILENAME" + Public Const INT_VALUE_FILEEXT = "FILE_EXT" + Public Const INT_VALUE_FILE_DATE = "FILE_DATE" + + Public Const CLIPBOARD_VALUE_DE = "@Zwischenablage" Public Const CLIPBOARD_VALUE_EN = "@Clipboard" @@ -44,6 +51,7 @@ Public Class ClassPatterns Public Const MAX_TRY_COUNT = 100 + Public _handled_File As String = Nothing Public ReadOnly Property PatternRegex As Regex Get @@ -132,6 +140,45 @@ Public Class ClassPatterns oResult = ReplacePattern(oResult, PATTERN_INT, Now.ToShortDateString) End While + While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_FILENAME_EXT) + If Not IsNothing(_handled_File) Then + If File.Exists(_handled_File) Then + Dim oFileName As String = Path.GetFileName(_handled_File) + oResult = ReplacePattern(oResult, PATTERN_INT, oFileName) + End If + + End If + + End While + + While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_FILENAME) + If Not IsNothing(_handled_File) Then + If File.Exists(_handled_File) Then + Dim oFileName As String = Path.GetFileNameWithoutExtension(_handled_File) + oResult = ReplacePattern(oResult, PATTERN_INT, oFileName) + End If + End If + End While + While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_FILEEXT) + If Not IsNothing(_handled_File) Then + If File.Exists(_handled_File) Then + Dim oFileExt As String = Path.GetExtension(_handled_File).Substring(1) + oResult = ReplacePattern(oResult, PATTERN_INT, oFileExt) + End If + End If + End While + While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_FILE_DATE) + If Not IsNothing(_handled_File) Then + If File.Exists(_handled_File) Then + Dim oCreationDate As DateTime = File.GetCreationTime(_handled_File) + Dim oDateOnlyString As String = oCreationDate.ToString("yyyy-MM-dd") + oResult = ReplacePattern(oResult, PATTERN_INT, oDateOnlyString) + End If + End If + End While + + + Return oResult Catch ex As Exception _Logger.Error(ex) From 766737b4b5a3e706434fe85cbb219321ef61743b Mon Sep 17 00:00:00 2001 From: Developer01 Date: Wed, 21 May 2025 13:11:13 +0200 Subject: [PATCH 3/4] Interfaces V 2.3 --- Interfaces/ActiveDirectoryInterface.vb | 25 +++++++++++++++---------- Interfaces/My Project/AssemblyInfo.vb | 6 +++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Interfaces/ActiveDirectoryInterface.vb b/Interfaces/ActiveDirectoryInterface.vb index 0c8a04c3..9375aa5d 100644 --- a/Interfaces/ActiveDirectoryInterface.vb +++ b/Interfaces/ActiveDirectoryInterface.vb @@ -221,9 +221,12 @@ Public Class ActiveDirectoryInterface End Try End Function - Public Function FindUserWithFilter(User As UserPrincipalEx, Filter As String) As Boolean + Public Function FindUserWithFilter(pUser As UserPrincipalEx, pFilter As String) As Boolean Try - Dim oRootPath = String.Join(","c, User.DistinguishedName.Split(","c).Skip(1)) + Dim oRootPath = String.Join(","c, pUser.DistinguishedName.Split(","c).Skip(1)) + _logger.Debug("FindUserWithFilter: pUser.DistinguishedName: [{0}]", pUser.DistinguishedName) + _logger.Debug("FindUserWithFilter: oRootPath from User.DistinguishedName - oRootPath: [{0}]", oRootPath) + Dim oPlaceholder = "@SAMACCOUNTNAME" Dim oProtocol = "LDAP://" Dim oEntry As New DirectoryEntry(oProtocol & oRootPath) With { @@ -231,22 +234,24 @@ Public Class ActiveDirectoryInterface .Password = Nothing, .AuthenticationType = AuthenticationTypes.Secure } - - If Filter = String.Empty Then - _logger.Debug("FindUserWithFilter: Filter was empty, returning True for User [{0}]", User.SamAccountName) + _logger.Debug("FindUserWithFilter: got oDirectoryEntry (Path): [{0}]", oProtocol & oRootPath) + If pFilter = String.Empty Then + _logger.Debug("FindUserWithFilter: Filter was empty, returning True for User [{0}]", pUser.SamAccountName) Return True End If - If Filter.Contains(oPlaceholder) Then - Filter = Filter.Replace(oPlaceholder, User.SamAccountName) + If pFilter.Contains(oPlaceholder) Then + pFilter = pFilter.Replace(oPlaceholder, pUser.SamAccountName) + _logger.Debug("FindUserWithFilter: Filter.Contains(oPlaceholder) [{0}]", pFilter) Else _logger.Warn("FindUserWithFilter: Placeholder [{0}] was not found in filter. Results may not be correct.") End If - Dim oSearcher As New DirectorySearcher(oEntry, Filter) + Dim oSearcher As New DirectorySearcher(oEntry, pFilter) + _logger.Debug("FindUserWithFilter: oSearcher created! Now executing DirectoryServices.SearchResult with .FindOne ...") Dim oResult As SearchResult = oSearcher.FindOne() - - If oResult IsNot Nothing AndAlso oResult.Path.Replace(oProtocol, String.Empty) = User.DistinguishedName Then + _logger.Debug("FindUserWithFilter: We have an oResult - oResult.Path: [{0}]", oResult.Path) + If oResult IsNot Nothing AndAlso oResult.Path.Replace(oProtocol, String.Empty) = pUser.DistinguishedName Then Return True Else Return False diff --git a/Interfaces/My Project/AssemblyInfo.vb b/Interfaces/My Project/AssemblyInfo.vb index 52957d41..370f119b 100644 --- a/Interfaces/My Project/AssemblyInfo.vb +++ b/Interfaces/My Project/AssemblyInfo.vb @@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + From f7f4b05df5b2512e83bb8da735ded1dce9f98492 Mon Sep 17 00:00:00 2001 From: Developer01 Date: Wed, 21 May 2025 14:00:44 +0200 Subject: [PATCH 4/4] ActiveDirectoryInterfaces Split Distinguished Name --- Interfaces/ActiveDirectoryInterface.vb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Interfaces/ActiveDirectoryInterface.vb b/Interfaces/ActiveDirectoryInterface.vb index 9375aa5d..ff5ea47a 100644 --- a/Interfaces/ActiveDirectoryInterface.vb +++ b/Interfaces/ActiveDirectoryInterface.vb @@ -220,12 +220,22 @@ Public Class ActiveDirectoryInterface Return oUsers End Try End Function + Private Function GetPartFromFirstOU(dnString As String) As String + Dim keyword As String = "OU=" + Dim index As Integer = dnString.IndexOf(keyword) + If index <> -1 Then + Return dnString.Substring(index) + Else + Return "No_Result_from_GetPartFromFirstOU" + End If + End Function Public Function FindUserWithFilter(pUser As UserPrincipalEx, pFilter As String) As Boolean Try - Dim oRootPath = String.Join(","c, pUser.DistinguishedName.Split(","c).Skip(1)) + 'Dim oRootPath = String.Join(","c, pUser.DistinguishedName.Split(","c).Skip(1)) + Dim oRootPath = GetPartFromFirstOU(pUser.DistinguishedName) _logger.Debug("FindUserWithFilter: pUser.DistinguishedName: [{0}]", pUser.DistinguishedName) - _logger.Debug("FindUserWithFilter: oRootPath from User.DistinguishedName - oRootPath: [{0}]", oRootPath) + _logger.Debug("FindUserWithFilter: oRootPath from User.DistinguishedName: [{0}]", oRootPath) Dim oPlaceholder = "@SAMACCOUNTNAME" Dim oProtocol = "LDAP://" @@ -250,8 +260,9 @@ Public Class ActiveDirectoryInterface Dim oSearcher As New DirectorySearcher(oEntry, pFilter) _logger.Debug("FindUserWithFilter: oSearcher created! Now executing DirectoryServices.SearchResult with .FindOne ...") Dim oResult As SearchResult = oSearcher.FindOne() - _logger.Debug("FindUserWithFilter: We have an oResult - oResult.Path: [{0}]", oResult.Path) + If oResult IsNot Nothing AndAlso oResult.Path.Replace(oProtocol, String.Empty) = pUser.DistinguishedName Then + _logger.Debug("FindUserWithFilter: We have an oResult - oResult.Path: [{0}]", oResult.Path) Return True Else Return False