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
| Set objFSO = CreateObject("Scripting.FileSystemObject")
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = "\(.*\)$|[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"
Dim serviceManager
Dim Desktop
Dim Fichier
Dim sheet
objStartFolder = "E:\GIT\FVS"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
' Fichier de commande pour intégration
FichierCMD = objStartFolder & "\command_OO.txt"
Set NewFichier = objFSO.CreateTextFile(FichierCMD,TRUE)
'Création d'une instance Open Office
Set serviceManager = CreateObject("com.sun.star.serviceManager")
Set Desktop = serviceManager.createInstance("com.sun.star.frame.Desktop")
For Each objFile in colFiles
If UCase(objFSO.GetExtensionName(objFile.name)) = "XLS" Then
FileName = objFSO.GetFileName(objFile.Path)
'wscript.echo FileName
'wscript.echo objFile
adresseDoc = convertToURL(objFile)
wscript.echo "l'URL du fichier au format OpenOffice est: " & adresseDoc
Set Document = Desktop.loadComponentFromURL(adresseDoc, "_blank", 0, Array())
Set Sheets = Document.getSheets()
Set Sheet = Sheets.getByIndex(1)
ServiceReplace
IP_Replace
Sauvegarde
End If
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' FONCTIONS
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''
'ConvertToURL'
''''''''''''''
Function ConvertToURL(objFile)
Dim sTmpFile
If Left(objFile, 7) = "file://" Then
ConvertToURL = objFile
Exit Function
End If
ConvertToURL = "file:///"
sTmpFile = objFSO.GetAbsolutePathName(objFile)
'replace any "\" by "/"
sTmpFile = Replace(sTmpFile,"\","/")
' replace any % by %25
sTmpFile = Replace(sTmpFile,"%","%25")
'replace any " " by "%20"
sTmpFile = Replace(sTmpFile," ","%20")
ConvertToURL = ConvertToURL & sTmpFile
End Function
''''''''''''''''
'ServiceReplace'
''''''''''''''''
Function ServiceReplace ()
For row=24 to 55
If Sheet.getCellByPosition(0,row).String = "Services" And Sheet.getCellByPosition(1,row).String <> "Remote Procedure Call (RPC)(RpcSs)" Then
services_long=Sheet.getCellByPosition(1,row).String
'wscript.echo services_long
services_short = myRegExp.Replace(services_long, "")
Sheet.getCellByPosition(1,row).String = services_short
'wscript.echo services_short
End If
If Sheet.getCellByPosition(0,row).String = "Services" And Sheet.getCellByPosition(1,row).String = "Remote Procedure Call (RPC)(RpcSs)" Then
Sheet.getCellByPosition(1,row).String = "Remote Procedure Call (RPC)"
End If
Next
End Function
''''''''''''
'Sauvegarde'
''''''''''''
Function Sauvegarde
if Document.hasLocation then
adresseDoc = Document.Location
else
adresseDoc = convertToURL(objFile)
end if
if Document.isModified then
Document.storeAsURL adresseDoc, Array()
end if
Document.setModified(True)
Document.store
'Closing the document.
Document.Close (True)
Set Document = Nothing
End function
''''''''''''
'IP_Replace'
''''''''''''
Function IP_Replace
IP = Sheet.getCellByPosition(1,4).Value
wscript.echo "IP found in original file:" & IP
Set Matches = myRegExp.Execute(IP)
wscript.echo "Number of IP found:" & Matches.count
If Matches.Count > 1 Then
IP1 = Matches(0)
IP2 = Matches(1)
'wscript.echo "IP1 is:" & IP1
'wscript.echo "IP2 is:" & IP2
'boucle pour l'AFPA
If Instr(FileName,"AFPA") <> 0 Then
'wscript.echo "client AFPA: " & FileName
For each match in Matches
IP1 = Matches(0)
IP2 = Matches(1)
If Instr(IP1,"10.150") Or Instr(IP1,"172.24") <> 0 Then
Sheet.getCellByPosition(1,4).Value = IP1
wscript.echo "New IP is:" & IP1
'ecriture ligne de cmd integration
ElseIf Instr(IP2,"10.150") Or Instr(IP2,"172.24") <> 0 Then
Sheet.getCellByPosition(1,4).Value = IP2
wscript.echo "New IP is:" & IP2
End If
Next
If Instr(FileName,"WINDOWS") <> 0 Then
'wscript.echo "Serveur Windows: " & FileName
CMD = "C:\php\php.exe D:\IBR_TOOLS\php_depot\company\sitescope\integration\integration_socle_technique.php --conf D:\IBR_TOOLS\conf_clients\sitescope\AFPA_sitescope_serveurs_prod.xml --sitescope_utilise PMON1APPV05 --code_client AFPA --methode_connexion WMI --verbose --fichier_fvs " & Chr(34) & objDestFolder & FileName & Chr(34)
NewFichier.WriteLine(CMD)
Else
'wscript.echo "Serveur Linux: " & FileName
CMD = "C:\php\php.exe D:\IBR_TOOLS\php_depot\company\sitescope\integration\integration_socle_technique.php --conf D:\IBR_TOOLS\conf_clients\sitescope\AFPA_sitescope_serveurs_prod.xml --sitescope_utilise PMON1APPV05 --code_client AFPA --verbose --fichier_fvs " & Chr(34) & objDestFolder & FileName & Chr(34)
NewFichier.WriteLine(CMD)
End If
End If
'boucle pour CPL
If Instr(FileName,"CANAL") Or Instr(FileName,"CPL") <> 0 Then
wscript.echo "client CPL: " & FileName
For each match in Matches
IP1 = Matches(0)
IP2 = Matches(1)
If Instr(IP1,"10.0") Or Instr(IP1,"172.") Or Instr(IP1,"194.4") <> 0 Then
Sheet.getCellByPosition(1,4).Value = IP1
wscript.echo "New IP is:" & IP1
ElseIf Instr(IP2,"10.0") Or Instr(IP2,"172.") Or Instr(IP1,"194.4") <> 0 Then
Sheet.getCellByPosition(1,4).Value = IP2
wscript.echo "New IP is:" & IP2
End If
Next
If Instr(FileName,"WINDOWS") Or Instr(FileName,"VIRTUALISATION") <> 0 Then
'wscript.echo "Serveur Windows: " & FileName
CMD = "C:\php\php.exe D:\IBR_TOOLS\php_depot\company\sitescope\integration\integration_socle_technique.php --conf D:\IBR_TOOLS\conf_clients\sitescope\CPL_sitescope_serveurs_prod.xml --sitescope_utilise FRCP00VPD0040 --code_client CPL --methode_connexion WMI --verbose --fichier_fvs " & Chr(34) & objDestFolder & FileName & Chr(34)
NewFichier.WriteLine(CMD)
Else
'wscript.echo "Serveur Linux: " & FileName
CMD = "C:\php\php.exe D:\IBR_TOOLS\php_depot\company\sitescope\integration\integration_socle_technique.php --conf D:\IBR_TOOLS\conf_clients\sitescope\CPL_sitescope_serveurs_prod.xml --sitescope_utilise FRCP00VPD0041 --code_client CPL --verbose --fichier_fvs " & Chr(34) & objDestFolder & FileName & Chr(34)
NewFichier.WriteLine(CMD)
End If
End If
'boucle pour MTES
If Instr(FileName,"MTES") <> 0 Then
'wscript.echo "client MTES: " & FileName
For each match in Matches
IP1 = Matches(0)
IP2 = Matches(1)
If Instr(IP1,"10.1") Or Instr(IP1,"10.2") Or Instr(IP1,"10.3") Or Instr(IP1,"10.4") Or Instr(IP1,"10.5") Or Instr(IP1,"10.6") Or Instr(IP1,"10.7") Or Instr(IP1,"10.8") Or Instr(IP1,"10.9") <> 0 Then
Sheet.getCellByPosition(1,4).Value = IP1
wscript.echo "New IP is:" & IP1
ElseIf Instr(IP1,"10.1") Or Instr(IP1,"10.2") Or Instr(IP1,"10.3") Or Instr(IP1,"10.4") Or Instr(IP1,"10.5") Or Instr(IP1,"10.6") Or Instr(IP1,"10.7") Or Instr(IP1,"10.8") Or Instr(IP1,"10.9") <> 0 Then
Sheet.getCellByPosition(1,4).Value = IP2
wscript.echo "New IP is:" & IP2
End If
Next
If Instr(FileName,"WINDOWS") <> 0 Then
'wscript.echo "Serveur Windows: " & FileName
CMD = "C:\php\php.exe D:\IBR_TOOLS\php_depot\company\sitescope\integration\integration_socle_technique.php --conf D:\IBR_TOOLS\conf_clients\sitescope\MTES_sitescope_serveurs_prod.xml --sitescope_utilise PROSIS010093 --code_client MTES --verbose --methode_connexion WMI --fichier_fvs " & Chr(34) & objDestFolder & FileName & Chr(34)
NewFichier.WriteLine(CMD)
Else
'wscript.echo "Serveur Linux: " & FileName
CMD = "C:\php\php.exe D:\IBR_TOOLS\php_depot\company\sitescope\integration\integration_socle_technique.php --conf D:\IBR_TOOLS\conf_clients\sitescope\MTES_sitescope_serveurs_prod.xml --sitescope_utilise PROSIS020093 --code_client MTES --verbose --fichier_fvs " & Chr(34) & objDestFolder & FileName & Chr(34)
NewFichier.WriteLine(CMD)
End If
End If
End If
End function |
Partager