► Afficher le textetext
#include <IE.au3>
#include <IE.au3>
#include <FTP.au3>
Dim Const $NewfilFromSyno = OptArgs($CmdLine, "namefile", "undef")
Dim Const $CDGuser = IniRead("conf.ini", "CDGACCOUNT", "user", "")
Dim Const $CDGpwd = IniRead("conf.ini", "CDGACCOUNT", "password", "")
Dim Const $FTPlink = IniRead("conf.ini", "FTP_VENITIEUX", "ip", "")
Dim Const $FTPuser01 = IniRead("conf.ini", "FTP_VENITIEUX", "user01", "")
Dim Const $connect2 = IniRead("conf.ini", "FRENCH", "connexion", "")
Dim Const $downConfirm = IniRead("conf.ini", "FRENCH", "download", "")
Dim Const $saveAs = IniRead("conf.ini", "FRENCH", "save", "")
Dim Const $chosefile= IniRead("conf.ini","FRENCH","chose","")
Dim Const $backupUser = IniRead("conf.ini","BACKUPACCOUNT","user","")
Dim Const $backupPWD = IniRead("conf.ini","BACKUPACCOUNT","password","")
$split = StringSplit($NewfilFromSyno, "\")
_CDGUp()
_ftpBackup($NewfilFromSyno, "/backup/venitieux/CDGUP/" & @YEAR & "/" & @MON & "/" & @MDAY & "/" & $split[2])
Func _CDGUp()
;Ferme les process ie existant
If ProcessExists("iexplore.exe") Then ProcessClose("iexplore.exe")
;ouvre une nouvelle page ie
sleep(10000)
Local $oIE
$oIE = _IEcreate("https://suppliers.renault.com/ree_cdg/",0,1,0)
Local $User, $Password
$User = $CDGuser
$PassWord = $CDGpwd
;Login session
WinWait ($connect2)
ControlSetText($connect2, "", "Edit2", $User )
ControlSetText($connect2, "", "Edit3", $PassWord )
ControlClick ($connect2,"","Button2")
;Navigation
_IELoadWait($oIE)
_IENavigate($oIE,"https://suppliers.renault.com/ree_cdg/c ... chargement")
_IELoadWait($oIE)
_IENavigate($oIE,"https://suppliers.renault.com/ree_cdg/c ... MANAGEMENT")
_IELoadWait($oIE)
_IENavigate($oIE,"javascript:getBarCodeData();")
Local $oForm = _IEFormGetObjByName($oIE, "SaveOnUnloadingForm")
Local $oInputFile = _IEFormElementGetObjByName($oForm, "barcodefile")
; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")
Send($NewfilFromSyno)
;Fermer ie
_EmptyIEHistory()
_EmptyIECache()
_IEQuit($OiE)
Return
EndFunc ;==> rentourne le chemin du fichier qu'il vient de récupéré
Func _EmptyIEHistory()
; Lecture de la clé dans la base de registre pour la compatibilité Vista/Seven
$IEHistory = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "History")
If $IEHistory = "" Then
SetError(1)
Return 0
EndIf
; Au cas ou la clé serait écrite avec la variable %userprofile%
$IEHistory = StringReplace($IEHistory, "%userprofile%", @UserProfileDir) & "\History.IE5"
; Suppression de l'historique IE
_FileAndDirectoryDelete($IEHistory)
$Size = DirGetSize($IEHistory, 1)
If $Size[2] <> 0 Then ; Vérifie que le répertoire est vide.
SetError(1)
Return 0
Else
Return 1
EndIf
EndFunc ;==>_EmptyIEHistory
Func _EmptyIECache()
; Lecture de la clé dans la base de registre pour la compatibilité Vista/Seven
$IECache = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Cache")
If $IECache = "" Then
SetError(1)
Return 0
EndIf
; Au cas ou la clé serait écrite avec la variable %userprofile%
$IECache = StringReplace($IECache, "%userprofile%", @UserProfileDir)
; Suppression du cache IE
_FileAndDirectoryDelete($IECache)
; Suppression du contenu du répertoire Content.IE5.
run(@ComSpec & ' /c rd /s /q "' & $IECache & '\Content.IE5"',$IECache,@SW_HIDE)
$Size = DirGetSize($IECache & '\Content.IE5', 1)
If $Size[2] <> 0 Then ; Vérifie que le répertoire est vide.
SetError(1)
Return 0
Else
Return 1
EndIf
EndFunc ;==>_EmptyIEHistory
Func _FileAndDirectoryDelete($sDir)
$search = FileFindFirstFile($sDir & "\*")
If @error Then Exit
While 1
$Next = FileFindNextFile($Search)
If @error Then ExitLoop
$Next = $sDir & "\" & $Next
$att = FileGetAttrib($Next)
If StringInStr($att, "d") Then
FileSetAttrib($Next, "-RSH", 1)
DirRemove($Next, 1)
Else
FileSetAttrib($Next, "-RSH")
FileDelete($Next)
EndIf
WEnd
FileClose($search)
EndFunc
Func OptArgs($args, $opt, $default)
$arraySize = UBound($args)
If $arraySize <= 0 Then
Return $default
EndIf
For $i = 0 to $arraySize-1
If StringRegExp($args[$i], "^[-/]"&$opt&"$") Then
Return True
EndIf
If StringRegExp($args[$i], "^[-/]"&$opt&"[:=]") Then
Return StringRegExpReplace($args[$i],"^[-/]"&$opt&"[:=]","")
EndIf
Next
Return $default
EndFunc
Func _ftpBackup($fileFrom, $fileTo)
local $Open = _FTPOpen("BACKUP")
local $Conn = _FTPConnect($Open, $FTPlink, $backupUser, $backupPWD)
local $creatFolderYear = _FTPMakeDir($Conn,"/backup/venitieux/CDGUP/" & @YEAR)
local $creatFolderMonth = _FTPMakeDir($Conn,"/backup/venitieux/CDGUP/" & @YEAR & "/" & @MON )
local $CreatFolderDays = _FTPMakeDir($Conn,"/backup/venitieux/CDGUP/" & @YEAR & "/" & @MON & "/" & @MDAY)
local $Ftpp = _FtpPutFile($Conn, $fileFrom , $fileTo)
local $Ftpc = _FTPClose($Open)
EndFunc
#include <IE.au3>
#include <FTP.au3>
Dim Const $NewfilFromSyno = OptArgs($CmdLine, "namefile", "undef")
Dim Const $CDGuser = IniRead("conf.ini", "CDGACCOUNT", "user", "")
Dim Const $CDGpwd = IniRead("conf.ini", "CDGACCOUNT", "password", "")
Dim Const $FTPlink = IniRead("conf.ini", "FTP_VENITIEUX", "ip", "")
Dim Const $FTPuser01 = IniRead("conf.ini", "FTP_VENITIEUX", "user01", "")
Dim Const $connect2 = IniRead("conf.ini", "FRENCH", "connexion", "")
Dim Const $downConfirm = IniRead("conf.ini", "FRENCH", "download", "")
Dim Const $saveAs = IniRead("conf.ini", "FRENCH", "save", "")
Dim Const $chosefile= IniRead("conf.ini","FRENCH","chose","")
Dim Const $backupUser = IniRead("conf.ini","BACKUPACCOUNT","user","")
Dim Const $backupPWD = IniRead("conf.ini","BACKUPACCOUNT","password","")
$split = StringSplit($NewfilFromSyno, "\")
_CDGUp()
_ftpBackup($NewfilFromSyno, "/backup/venitieux/CDGUP/" & @YEAR & "/" & @MON & "/" & @MDAY & "/" & $split[2])
Func _CDGUp()
;Ferme les process ie existant
If ProcessExists("iexplore.exe") Then ProcessClose("iexplore.exe")
;ouvre une nouvelle page ie
sleep(10000)
Local $oIE
$oIE = _IEcreate("https://suppliers.renault.com/ree_cdg/",0,1,0)
Local $User, $Password
$User = $CDGuser
$PassWord = $CDGpwd
;Login session
WinWait ($connect2)
ControlSetText($connect2, "", "Edit2", $User )
ControlSetText($connect2, "", "Edit3", $PassWord )
ControlClick ($connect2,"","Button2")
;Navigation
_IELoadWait($oIE)
_IENavigate($oIE,"https://suppliers.renault.com/ree_cdg/c ... chargement")
_IELoadWait($oIE)
_IENavigate($oIE,"https://suppliers.renault.com/ree_cdg/c ... MANAGEMENT")
_IELoadWait($oIE)
_IENavigate($oIE,"javascript:getBarCodeData();")
Local $oForm = _IEFormGetObjByName($oIE, "SaveOnUnloadingForm")
Local $oInputFile = _IEFormElementGetObjByName($oForm, "barcodefile")
; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")
Send($NewfilFromSyno)
;Fermer ie
_EmptyIEHistory()
_EmptyIECache()
_IEQuit($OiE)
Return
EndFunc ;==> rentourne le chemin du fichier qu'il vient de récupéré
Func _EmptyIEHistory()
; Lecture de la clé dans la base de registre pour la compatibilité Vista/Seven
$IEHistory = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "History")
If $IEHistory = "" Then
SetError(1)
Return 0
EndIf
; Au cas ou la clé serait écrite avec la variable %userprofile%
$IEHistory = StringReplace($IEHistory, "%userprofile%", @UserProfileDir) & "\History.IE5"
; Suppression de l'historique IE
_FileAndDirectoryDelete($IEHistory)
$Size = DirGetSize($IEHistory, 1)
If $Size[2] <> 0 Then ; Vérifie que le répertoire est vide.
SetError(1)
Return 0
Else
Return 1
EndIf
EndFunc ;==>_EmptyIEHistory
Func _EmptyIECache()
; Lecture de la clé dans la base de registre pour la compatibilité Vista/Seven
$IECache = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Cache")
If $IECache = "" Then
SetError(1)
Return 0
EndIf
; Au cas ou la clé serait écrite avec la variable %userprofile%
$IECache = StringReplace($IECache, "%userprofile%", @UserProfileDir)
; Suppression du cache IE
_FileAndDirectoryDelete($IECache)
; Suppression du contenu du répertoire Content.IE5.
run(@ComSpec & ' /c rd /s /q "' & $IECache & '\Content.IE5"',$IECache,@SW_HIDE)
$Size = DirGetSize($IECache & '\Content.IE5', 1)
If $Size[2] <> 0 Then ; Vérifie que le répertoire est vide.
SetError(1)
Return 0
Else
Return 1
EndIf
EndFunc ;==>_EmptyIEHistory
Func _FileAndDirectoryDelete($sDir)
$search = FileFindFirstFile($sDir & "\*")
If @error Then Exit
While 1
$Next = FileFindNextFile($Search)
If @error Then ExitLoop
$Next = $sDir & "\" & $Next
$att = FileGetAttrib($Next)
If StringInStr($att, "d") Then
FileSetAttrib($Next, "-RSH", 1)
DirRemove($Next, 1)
Else
FileSetAttrib($Next, "-RSH")
FileDelete($Next)
EndIf
WEnd
FileClose($search)
EndFunc
Func OptArgs($args, $opt, $default)
$arraySize = UBound($args)
If $arraySize <= 0 Then
Return $default
EndIf
For $i = 0 to $arraySize-1
If StringRegExp($args[$i], "^[-/]"&$opt&"$") Then
Return True
EndIf
If StringRegExp($args[$i], "^[-/]"&$opt&"[:=]") Then
Return StringRegExpReplace($args[$i],"^[-/]"&$opt&"[:=]","")
EndIf
Next
Return $default
EndFunc
Func _ftpBackup($fileFrom, $fileTo)
local $Open = _FTPOpen("BACKUP")
local $Conn = _FTPConnect($Open, $FTPlink, $backupUser, $backupPWD)
local $creatFolderYear = _FTPMakeDir($Conn,"/backup/venitieux/CDGUP/" & @YEAR)
local $creatFolderMonth = _FTPMakeDir($Conn,"/backup/venitieux/CDGUP/" & @YEAR & "/" & @MON )
local $CreatFolderDays = _FTPMakeDir($Conn,"/backup/venitieux/CDGUP/" & @YEAR & "/" & @MON & "/" & @MDAY)
local $Ftpp = _FtpPutFile($Conn, $fileFrom , $fileTo)
local $Ftpc = _FTPClose($Open)
EndFunc
- Code final pour la pstérité
Merci de votre aide





