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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
Option Explicit
'***********************************************************************************
'*Contrôle : MiseJourFichiers *
'*Projet : Configurateur *
'*Date : 04/07/2006 *
'*Auteur : *
'***********************************************************************************
'* *
'* *
'* *
'***********************************************************************************
Event AprèsSupprime()
Private m_Création As Boolean
Private m_TypeListe As ListeTypeObjet
Private m_NuméroInfo As Long
Dim StrScanFolderFtp As String
Dim CancelAction As Boolean
Public Function AddSlash(ByVal SlashStr As String) As String
'-- Ajouter un "\" dans un path
If Len(SlashStr) = 0 Then Exit Function
If Right$(SlashStr, 1) <> "\" Then SlashStr = SlashStr & "\"
AddSlash = SlashStr
End Function
Sub WaitExecute(InetCtl As Inet)
'-- Attendre la fin d'execution d'une instruction d'un controle Inet
While InetCtl.StillExecuting
DoEvents
Wend
End Sub
Public Function ScanFolderFtp(Optional FolderPath As String = "", Optional Filename As String = "", Optional SubFold As Boolean = True) As Long
'-- Fonction récursive pour l'exploration des répertoires Ftp
Dim StrPath() As String
Dim subFolders As New Collection
Dim i As Integer
With Inet1
If .UserName = "" Then
AfficheErreurUserName
ElseIf .Password = "" Then
AfficheErreurPassword
ElseIf .URL = "" Then
AfficheErreurURL
End If
.Execute , "DIR "
WaitExecute Inet1
StrPath = Split(Replace(StrScanFolderFtp, "/", "\"), vbCrLf)
For i = 0 To UBound(StrPath) - 1
'-- Affichage dans la listbox
If InStr(1, StrPath(i), ".\") = 0 And Len(StrPath(i)) > 0 Then
MiseJourFichiers.List1.AddItem AddSlash(FolderPath) & StrPath(i)
End If
'-- Remplir la collection des sous-dossiers du dossier en cours
If Right(StrPath(i), 1) = "\" And InStr(1, StrPath(i), ".\") = 0 Then
subFolders.Add Left(StrPath(i), Len(StrPath(i)) - 1)
End If
Next
'-- Renvoie le nombre d'éléments du dossier en cours
ScanFolderFtp = UBound(StrPath)
'--Recherche dans les sous-dossiers
If SubFold Then
For i = 1 To subFolders.Count
Debug.Print subFolders.Item(i)
.Execute , "CD " & subFolders.Item(i)
WaitExecute Inet1
DoEvents
If CancelAction Then Exit Function
ScanFolderFtp = ScanFolderFtp + ScanFolderFtp(AddSlash(FolderPath) & subFolders.Item(i), , SubFold)
.Execute , "CDUP"
WaitExecute Inet1
Next i
End If
'-- Vide la collection des sous-dossiers
Set subFolders = Nothing
End With
End Function
Private Sub Ajouter_Click(Index As Integer)
Dim FichPres As Boolean
Dim i As Integer
FichPres = False
If List1.ListIndex >= 0 Then
For i = 0 To List2.ListCount - 1
If List1.List(List1.ListIndex) = List2.List(i) Then
FichPres = True 'Fichier présent dans la List2
End If
Next i
If Not FichPres Then
List2.AddItem List1.List(List1.ListIndex)
List1.RemoveItem (List1.ListIndex)
End If
End If
'Load SaisieNouveau
'SaisieNouveau.InitSaisie mFichiers, 0, Trim("om")
'SaisieNouveau.Show vbModal, Me
End Sub
Private Sub Annuler_Click(Index As Integer)
m_Création = False
Unload Me
End Sub
Private Sub Supprime_Click()
If List2.ListIndex >= 0 Then
List2.RemoveItem (List2.ListIndex)
End If
Load EffaceObjet
With EffaceObjet
.InitSaisie m_TypeListe, m_NuméroInfo, Trim("om"), SQL_Delete_Fichiers_par_Index
.Show vbModal, Me
RaiseEvent AprèsSupprime
End With
End Sub
Private Sub Command2_Click()
With Inet1
List1.Clear
.AccessType = icDirect
.Protocol = icFTP
.URL = txtURL.Text
.UserName = txtName.Text
.Password = txtPassword.Text
ScanFolderFtp
.Execute , "CLOSE"
WaitExecute Inet1
End With
End Sub
Private Sub Form_Load()
txtURL.Text =
txtName.Text =
txtPassword.Text =
LoadResStrings Me
AfficheInfoFichiers
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
' Récupère la réponse du serveur à l'aide de
' la méthode GetChunk lorsque State = 12.
Dim vtData As Variant ' Variable Data.
Select Case State
Case icError ' 11
' En cas d'erreur, renvoie ResponseCode et
' ResponseInfo.
vtData = Inet1.ResponseCode & ":" & _
Inet1.ResponseInfo
Case icResponseCompleted
Dim strData As String
Dim bDone As Boolean: bDone = False
' Lecture du premier segment
vtData = Inet1.GetChunk(1024, icString)
DoEvents
' Lecture des segments suivants
Do While Not bDone
strData = strData & vtData
vtData = Inet1.GetChunk(1024, icString)
DoEvents
If Len(vtData) = 0 Then
bDone = True
End If
Loop
StrScanFolderFtp = strData
End Select
End Sub
Private Sub AfficheInfoFichiers()
Dim ItemX As ListItem
Dim Cpte As Integer
Dim ListeFichiersCréés As New clsListeObjet
DoEvents
'Constitution de la liste des fichiers déclarés
'**********************************************
ListeFichiersCréés.Populate mFichiers
With ListeFichiersCréés
With ListeFichiersCréés
If .Count <> 0 Then
'Il y a des modules déclarés
'***************************
For Cpte = 1 To .Count
List2.AddItem .Item(Cpte).Nom
Next Cpte
End If
End With
End With
End Sub
Private Sub AfficheErreurPassword()
mMessage.ForeColor = vbRed
mMessage.Caption = LoadRessourceString(IDErreurPassword)
End Sub
Private Sub AfficheErreurUserName()
mMessage.ForeColor = vbRed
mMessage.Caption = LoadRessourceString(IDErreurUser)
End Sub
Private Sub AfficheErreurURL()
mMessage.ForeColor = vbRed
mMessage.Caption = LoadRessourceString(IDErreurURL)
End Sub |
Partager