demon contacts import

SUPA PUPA DUPA COPYPASTE FILES IMPORT SYSTEM
This commit is contained in:
sShemet
2026-03-19 17:43:18 +05:00
parent 48ca6f2d85
commit 2e01e57e70
7 changed files with 105 additions and 39 deletions

View File

@@ -1,6 +1,7 @@
Imports System.IO
Imports System.Text
Imports System.IO.Compression
Imports System.Text
Imports Newtonsoft.Json
Partial Class Form1
@@ -635,6 +636,63 @@ Partial Class Form1
End Using
End Function
Public Function GetRelatedContacts(filePath As String) As List(Of Integer)
Dim directory As String = Path.GetDirectoryName(filePath)
Dim contactsFilePath As String = Path.Combine(directory, "contacts_copy.json")
If Not File.Exists(contactsFilePath) Then
Throw New FileNotFoundException($"contacts_copy.json not found in {directory}")
End If
Dim jsonContent As String = File.ReadAllText(contactsFilePath)
Dim contactsData As List(Of List(Of String)) = JsonConvert.DeserializeObject(Of List(Of List(Of String)))(jsonContent)
Dim fileName As String = Path.GetFileName(filePath)
' First 8 letters (0864_034)
Dim filePrefix As String = ""
If fileName.Length >= 8 Then
filePrefix = fileName.Substring(0, 8)
Else
Throw New ArgumentException($"Filename {fileName} too short")
End If
Dim targetGroup As List(Of String) = Nothing
For Each group As List(Of String) In contactsData
For Each contactFile As String In group
If contactFile.StartsWith(filePrefix) Then
targetGroup = group
Exit For
End If
Next
If targetGroup IsNot Nothing Then Exit For
Next
If targetGroup Is Nothing Then
Return New List(Of Integer)() ' Возвращаем пустой список
End If
Dim result As New List(Of Integer)
For Each contactFile As String In targetGroup
If contactFile.StartsWith(filePrefix) Then
Continue For
End If
Dim parts As String() = contactFile.Split("_"c)
If parts.Length >= 2 Then
Dim number As Integer
If Integer.TryParse(parts(1), number) Then
result.Add(number)
End If
End If
Next
Return result
End Function
End Class