1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
Imports System.IO
Module Traiter_Log
Public Sub TraiterLog(ByVal log As String, ByRef nlignes() As String, ByRef logtraiter() As Principal.LogTabSMS)
nlignes = log.Split(vbCrLf) 'Decoupe le texte principal par ligne
Dim i, j As Integer
Dim tampon(0) As String
Dim Taille As Integer
Dim tabTri() As String = log.Split(vbCrLf) 'Affectation du contenu du 1er Tableau pour preserver son contenu
'Determine la valeur de la ligne la plus longue
Taille = 0
For i = 0 To UBound(tabTri)
If Taille < tabTri(i).Length Then
Taille = tabTri(i).Length
End If
Next i
'Decoupe chaque ligne par mots
Dim tabSemifini(UBound(nlignes), Taille) As String
Dim LigneTempo As String = "" 'Tableau temporaire reçoit la ligne decoupé en chaînes
For i = 0 To UBound(nlignes)
LigneTempo = nlignes(i)
Dim Tabtempo() As String = LigneTempo.Split(" ")
For j = 0 To UBound(Tabtempo)
tabSemifini(i, j) = Tabtempo(j)
Next j
Next i
'Declaration des differents tableaux de categories
Dim strDate(UBound(nlignes)) As String
Dim strHeure(UBound(nlignes)) As String
Dim strEtat(UBound(nlignes)) As String
Dim strExpediteur(UBound(nlignes)) As String
Dim strDestinataire(UBound(nlignes)) As String
Dim strSMSC(UBound(nlignes)) As String
Dim strSVC(UBound(nlignes)) As String
Dim strACT(UBound(nlignes)) As String
Dim strFID(UBound(nlignes)) As String
Dim strBINF(UBound(nlignes)) As String
Dim strFlags(UBound(nlignes)) As String
Dim strUDH(UBound(nlignes)) As String
Dim strMsg(UBound(nlignes)) As String
Dim strTaille(UBound(nlignes)) As String
Dim strDLR(UBound(nlignes)) As String
'Classification et mise en forme des données traités dans les differents tableaux déclarés
Dim Elt1 As Char() = {"[", "]"}
Dim tampont As String
For i = 0 To UBound(tabSemifini, 1)
For j = 0 To UBound(tabSemifini, 2)
Dim eltact As Char() = {"[", "]", "A", "C", "T", ":", "a", "c", "t"}
Dim eltflags As Char() = {"[", "f", "l", "a", "g", "s", ":", "]", "F", "L", "A", "G", "S"}
Dim eldest As Char() = {"[", "t", "o", ":", "]", "T", "O"}
Dim eltail As Char() = {"[", ":", ":"}
Dim eltbinf As Char() = {"[", "B", "I", "N", "F", ":", "]"}
Dim y As Integer
If tabSemifini(i, j) <> "" Then
Select Case j
Case 0
strDate(i) = (tabSemifini(i, j))
Case 1
strHeure(i) = (tabSemifini(i, j))
Case 2
If tabSemifini(i, j) = "SENT" Then
strEtat(i) = tabSemifini(i, j)
Else
strEtat(i) = tabSemifini(i, j + 1)
End If
Case 4
tampont = tabSemifini(i, j)
tampont = tampont.Trim(Elt1)
tampont = tampont.Remove(0, 5)
strSMSC(i) = tampont
Case 5
tampont = tabSemifini(i, j)
tampont = tampont.Trim(Elt1)
tampont = tampont.Remove(0, 4)
strSVC(i) = tampont
Case 6
If tabSemifini(i, j) <> "[ACT:]" Then
strACT(i) = tabSemifini(i, j).Trim(eltact)
Else
strACT(i) = " "
End If
Case 7
If tabSemifini(i, j) <> "[BINF:]" Then
strBINF(i) = tabSemifini(i, j).Trim(eltbinf)
Else
strBINF(i) = " "
End If
Case 8
tampont = tabSemifini(i, j)
tampont = tampont.Trim(Elt1)
tampont = tampont.Remove(0, 4)
strFID(i) = tampont
Case 9
tampont = tabSemifini(i, j)
tampont = tampont.Trim(Elt1)
tampont = tampont.Remove(0, 5)
strExpediteur(i) = tampont
Case 10
tampont = tabSemifini(i, j)
tampont = tampont.Trim(Elt1)
tampont = tampont.Remove(0, 3)
strDestinataire(i) = tampont
Case 11
tampont = tabSemifini(i, j)
tampont = tampont.Trim(Elt1)
tampont = tampont.Remove(0, 6)
strFlags(i) = tampont
Dim valFlags() As String = strFlags(i).Split(":")
If valFlags(4) = "1" Then
strDLR(i) = "DELIVERED"
ElseIf valFlags(4) = "2" Then
strDLR(i) = "FAILED"
ElseIf valFlags(4) = "4" Then
strDLR(i) = "QUEUED"
ElseIf valFlags(4) = "8" Then
strDLR(i) = "ACCEPTED"
ElseIf valFlags(4) = "16" Then
strDLR(i) = "REJECTED"
Else
strDLR(i) = ""
End If
Case 12
If tabSemifini(i, j) = "[msg:4:ACK/]" Then
strTaille(i) = "4"
strMsg(i) = "ACK"
Else
tampont = tabSemifini(i, j)
tampont = tampont.Trim(eltail)
tampont = tampont.Remove(0, 4)
Dim TailleTemp() As String = tampont.Split(":")
Dim k As Short
Dim Temp As String = ""
For k = 0 To UBound(TailleTemp)
If k = 0 Then
strTaille(i) = CInt(TailleTemp(k))
Else
Temp = Temp & " " & TailleTemp(k)
End If
Next k
tabSemifini(i, j + 1) = Temp & " " & tabSemifini(i, j + 1)
For y = j + 1 To UBound(tabSemifini, 2)
If tabSemifini(i, y) <> "[udh:0:]" And tabSemifini(i, y) <> "" Then
strMsg(i) = strMsg(i) & " " & tabSemifini(i, y).Trim(Elt1)
Else
Dim Elt2 As Char() = {":", "u", "d", "h", "[", "]", "U", "D", "H"}
strUDH(i) = tabSemifini(i, y).Trim(Elt2)
Exit For
End If
Next y
End If
End Select
Else : Exit For
End If
Next j
Next i
'Exportation des données des differents tableaux du module vers le tableau logtraiter de type LogTABSMS déclaré dans le form principal
'Pour une utilisation ultérieure
For i = 0 To UBound(nlignes)
With logtraiter(i)
.LogACT = strACT(i) 'L erreur survient à cette étape
.LogBINF = strBINF(i)
.LogDate = strDate(i)
.LogDestinataire = strDestinataire(i)
.LogDLR = strDLR(i)
.LogEtat = strEtat(i)
.LogExpediteur = strExpediteur(i)
.LogFID = strFID(i)
.LogFlags = strFlags(i)
.LogMSG = strMsg(i)
.LogSMSC = strSMSC(i)
.logSVC = strSVC(i)
.LogTaille = strTaille(i)
.LogUDH = strUDH(i)
End With
Next i
End Sub
End Module |