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
|
Private Sub procVerifFichier()
Dim i As Integer
Dim sFiles() As String
Dim FreeF As Integer
Dim str() As String
Dim tmp() As String
Do
Try
'System.Threading.Thread.Sleep(5000)
If Not File.Exists(f_in & "\pomail.lock") Then
'pour avoir les noms des fichiers et des sous-répertoires
sFiles = Directory.GetFiles(f_in)
For i = 0 To sFiles.GetUpperBound(0)
If InStr(sFiles(i), ".txt") > 0 Then
'System.Threading.Thread.Sleep(5000)
FreeF = FreeFile() 'Possibilité de mettre 1************
FileOpen(FreeF, sFiles(i), OpenMode.Input) 'Ouverture du fichier créé**********
str = Split(InputString(FreeF, FileLen(sFiles(i))), Chr(10)) 'Séparation des lignes du fichier***
FileClose(FreeF)
File.Delete(archive & sFiles(i).Substring(27, sFiles(i).Length - 27))
File.Move(sFiles(i), archive & sFiles(i).Substring(27, sFiles(i).Length - 27))
'MsgBox(sFiles(i), archive & sFiles(i))
With txtwatch
.SelectionStart = Len(txtwatch.Text)
.SelectionProtected = False
.SelectionStart = Len(txtwatch.Text) + 1
.SelectionColor = System.Drawing.Color.Red
.SelectedText = "Fichier créé : " & Replace(sFiles(i), f_in, "") & " " & Date.Now & vbCrLf
.SelectionProtected = True
.Focus()
.SelectionStart = txtwatch.Text.Length
.ScrollToCaret()
End With
tmp = Split(Replace(Replace(str(0), Chr(34), ""), "'", " "), ";")
'If tmp(2).ToUpper <> "V" Then
'Exit Sub
'end if
If tmp(2).ToUpper = "V" Then
fct_fill_sql(str, sFiles(i).Substring(27, 2).ToUpper)
fct_fill_excel(str, sFiles(i).Substring(27, 2).ToUpper)
End If
End If
If File.Exists(f_in & "\pomail.lock") Then Exit For
Next
End If
Catch ex As Exception
fct_send_mail(envoyeur, warning, "ERREUR PO VIA MAIL " & Replace(sFiles(i), f_in, ""), 0, ex.ToString, "none")
'# erreur no 1
fct_exec_sql("UPDATE pur_order SET err=1 WHERE pur_order.po_number='0'")
End Try
Exit Do
Loop
End Sub |
Partager