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
| '------------------------
'Declaration variables
'------------------------
Dim Centre, Plaque, Fold, Log, oFl
Dim objFSO, oFSO, FileLog, oShell, oFS, Lock
Dim stRep,
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = Wscript.CreateObject("Wscript.Shell")
Set objArgs = Wscript.Arguments
VERSION="1.00"
centre = objArgs(0)
Select Case Centre
Case "1"
Plaque="Paris"
Case "2"
Plaque="Paris"
Case "3"
Plaque="Province"
Case "4"
Plaque="Paris"
Case "5"
Plaque="Province"
Case Else
Wscript.echo "Erreur dans le parametre"
wscript.quit(2)
End Select
MyDate = Year(Now) & "" & Month(Now) & "" & Day(Now) & "_" & Hour(Now)& "" & Minute(Now)
LOG="C:\Appli\Log\stat.vbs_"& MyDate &".log"
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set FileLog = FSO.CreateTextFile(Log)
Traitement="C:\Appli\Plaque_" & plaque & "\Centre_" & Centre & "\temp\Traitement"
Xmlin_temp="C:\Appli\Plaque_" & plaque & "\Centre_" & Centre & "\temp"
Zip_cmd = "D:\7-Zip\7z.exe"
Lock="C:\Fichiers_doublons\" & file_name & ".lock"
'--------------------------------------------
'Initialisation des log pour chaque centre
'--------------------------------------------
Sub Msglog(severite,code,label)
wscript.echo Mydate & "-" & time & " " & severite & " " & code & " " & label
FileLog.WriteLine(Mydate & "-" & time & " " & severite & " " & code & " " & label)
End sub
'--------------------------------------------------------------------
'Test de la présence de fichier zip pour chaque centre
'--------------------------------------------------------------------
sub Verif_ZIP
Set oFSO = CreateObject("Scripting.FileSystemObject")
stRep = "C:\Appli\Plaque_" & plaque & "\Centre_" & Centre & "\temp"
If oFSO.FolderExists(stRep) Then
For each oFl in oFSO.GetFolder(stRep).Files
file_name=oFl.Name
wscript.echo file_name 'verification du nom du fichier.zip
Next
MSGLog 0,"0003","Verification de la présence du fichier zip "
if not FSO.FileExists (file_name) Then
MSGLog 0,"0003","Pas de fichier zip."
FileLog.Close
Wscript.quit
End If
End If
End sub
'--------------------------------------------
'Vérification du lock pour chaque centre
'--------------------------------------------
Sub Verif_Lock
msglog "0","0000","-Debut: Verification de la non presence du Lock pour le centre " & centre
If objFSO.FileExists ("C:\Fichiers_doublons\" & file_name & ".lock") Then
'wscript.echo (Lock)
msglog "1","0001","WARNING: Programme deja lance pour le centre " & centre
wscript.quit (8)
else
Set FSys = CreateObject("Scripting.FileSystemObject")
msglog "0","0000","-Debut: Pose Lock " & Lock & " pour le centre " & centre
Set MonFic = FSys.CreateTextFile("C:\Fichiers_doublons\" & file_name & ".lock")
msglog "0","0000","-Fin: Pose du Lock " & Lock & " pour le centre " & centre
end if
msglog "0","0000","-Fin: Verification de la non presence du Lock pour le centre " & centre
end sub
'------------------------------------
'Decompression du xml.zip
'------------------------------------
Sub Decompress
MSGLog 0,"0003","Décompression du fichier "
if not FSO.FileExists (file_name) Then
wscript.echo file_name
MSGLog 0,"0003","Pas de fichier zip."
FileLog.Close
Wscript.quit
End If
oShell.Run Zip_cmd & "\7z.exe x "file_name" -o "Traitement"", true ' On décompresse le fichier vers le dossier Traitement
End sub
'---------------------
' Corps su script
'---------------------
msglog "0","0000","---Debut:------- xml.vbs "
Verif_ZIP
Verif_Lock
Decompress
msglog "0","0000","---Fin:--------- xml.vbs"
FileLog.Close |