Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv
- #Warn
- #SingleInstance Force
- SetWorkingDir %A_ScriptDir%
- SetBatchLines -1
- FileDelete, ReadErrors.html
- global readPerc := 1
- global PercentInputBool := 0
- global PCX_List_Array := [ ]
- Loop, Read, PCX_List.txt
- PCX_List_Array.Push(A_LoopReadLine)
- global test_ip := PCX_List_Array[1]
- global connectionTestStatus := 0
- Hotkey, ^1, Exit
- Hotkey, ^!5, PercentInputStatus
- ReadConfig(){
- IniRead, readPerc, config.ini, Settings, ReadErrorPercent
- if(readPerc = "ERROR"){
- readPerc := 1
- }
- }
- WriteConfig(){
- IniWrite, %readPerc%, config.ini, Settings, ReadErrorPercent
- }
- PercentInputStatus(){
- PercentInputBool := 1
- }
- PercentInput(){
- InputBox, readPerc, Percent Check, `% = %readPerc%`nNew Input :,,,,,,10
- if(readPerc/1 != readPerc or readPerc < 0 or readPerc > 100){
- readPerc := 1
- }
- WriteConfig()
- Sleep, 1000
- }
- ConnectionTest(){
- if(connectionTestStatus = 0){
- connectionTestStatus := 1
- FileDelete, connectTest.bat
- FileDelete, ConnectTest.txt
- FileAppend, ping -n 4 -w 500 %test_ip%>ConnectTest.txt, connectTest.bat
- Run, connectTest.bat,,Hide,pID
- Loop,{
- Process, Exist, %pID%
- if(ErrorLevel = 0){
- break
- }
- }
- tL := ""
- FileReadLine, tL, ConnectTest.txt, 9
- if not(InStr(tL, "Received = 4", true, 1) > 0){
- MsgBox,,ERROR, No Connection to PCX, 3
- Exit()
- }
- else{
- DownloadingScannerReads()
- SetTimer, ConnectionTest, 15000
- }
- FileDelete, connectTest.bat
- FileDelete, ConnectTest.txt
- connectionTestStatus := 0
- }
- }
- Exit(){
- if(PercentInputBool = 1){
- PercentInput()
- }
- FileDelete, connectTest.bat
- FileDelete, ConnectTest.txt
- ExitApp
- }
- DownloadingScannerReads(){
- SetWorkingDir %A_ScriptDir%/pcxLogs
- xPos := A_ScreenWidth*3.2/4.0
- yPos := A_ScreenHeight*0.3/4.0
- Progress, b w200 x%xPos% y%yPos%, , Downloading..., Loading Bar
- pInd := 0
- MaxVal := PCX_List_Array.MaxIndex()
- Loop % PCX_List_Array.MaxIndex(){
- pcxNum := A_Index
- pcx_address := PCX_List_Array[A_Index]
- UrlDownloadToFile, http://%pcx_address%/station/index.html, PCX_%pcxNum%.txt
- pInd += (100/MaxVal)
- Progress, %pInd%
- }
- Progress, Off
- SetWorkingDir %A_ScriptDir%
- textVar1=
- (
- <style type="text/css">
- .tg {border-collapse:collapse;border-color:#aaa;border-spacing:0;}
- .tg td{background-color:#fff;border-color:#aaa;border-style:solid;border-width:1px;color:#333;
- font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:8px 13px;word-break:normal;}
- .tg th{background-color:#f38630;border-color:#aaa;border-style:solid;border-width:1px;color:#fff;
- font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:8px 13px;word-break:normal;}
- .tg .tg-xyoc{font-family:"Arial Black", Gadget, sans-serif !important;font-size:18px;font-weight:bold;text-align:center;
- vertical-align:middle}
- .tg .tg-xyod{font-family:"Arial Black", Gadget, sans-serif !important;font-size:26px;font-weight:bold;text-align:center;
- vertical-align:middle}
- .tg .tg-xyop{color:#5179aa;font-family:"Arial Black", Gadget, sans-serif !important;font-size:72px;font-weight:bold;text-align:center;
- vertical-align:middle}
- .tg .tg-vqva{background-color:#f5e6e6;border-color:inherit;font-family:"Arial Black", Gadget, sans-serif !important;font-size:14px;
- text-align:center;vertical-align:middle}
- .tg .tg-dibh{background-color:#f5e6e6;border-color:inherit;color:#fe0000;font-family:"Arial Black", Gadget, sans-serif !important;
- font-size:14px;text-align:center;vertical-align:middle}
- </style>
- <h1 style="text-align: center;"><a title='PCX Scanners List' href='file:///%A_ScriptDir%/scannerList.pdf' target="_blank"><span class="tg"><em class="tg-xyop">
- <strong> - PCX SCANNERS - </strong> </em></span></a></h1>
- )
- FileAppend, %textVar1%`n, ReadErrors.html
- SetWorkingDir %A_ScriptDir%/pcxLogs
- fileName := ""
- addressName := ""
- xPos := A_ScreenWidth*3.2/4.0
- yPos := A_ScreenHeight*0.3/4.0
- Progress, b w200 x%xPos% y%yPos%, , Reading..., Loading Bar
- pInd := 0
- Loop % PCX_List_Array.MaxIndex(){
- pcxNum := A_Index
- fileName = PCX_%pcxNum%.txt
- pcx_address := PCX_List_Array[A_Index]
- addressName = http://%pcx_address%
- ;MsgBox, %fileName%
- pcxFileLine := 50
- pcxHeader:=0
- endTable:=0
- Loop{
- ;MsgBox, %pcxFileLine%
- FileReadLine, line, %fileName%, %pcxFileLine%
- if (ErrorLevel != 0){
- ;MsgBox, Error
- if(endTable == 1){
- textVar4=
- (
- </tbody>
- </table>
- )
- SetWorkingDir %A_ScriptDir%
- FileAppend, %textVar4%`n, ReadErrors.html
- SetWorkingDir %A_ScriptDir%/pcxLogs
- endTable:=0
- }
- break
- }
- if (InStr(line, "<tr><td><a href=""/station/statistic/", true, 1) > 0){
- scannerNamePos := InStr(line, "/station/statistic/", true, 1)
- scannerNamePos := scannerNamePos + 19
- i := 1
- Loop{
- if(SubStr(line, scannerNamePos + i, 1) != Chr(46)){
- i++
- }
- else{
- break
- }
- }
- scannerName := SubStr(line, scannerNamePos, i)
- filePos := InStr(line, "</a></td><td>", false, 0)
- filePos := filePos + 13
- i := 1
- Loop{
- if(SubStr(line, filePos + i, 1) != Chr(60)){
- i++
- }
- else{
- break
- }
- }
- totalScan := SubStr(line, filePos, i)
- ;MsgBox, %totalScan%
- filePos := filePos + 9 + i
- i := 1
- Loop{
- if(SubStr(line, filePos + i, 1) != Chr(60)){
- i++
- }
- else{
- break
- }
- }
- readErr := SubStr(line, filePos, i)
- ;MsgBox, %readErr%
- readErrPercent := Round(((readErr/totalScan)*100), 2)
- UrlDownloadToFile, %addressName%/station/statistic/%scannerName%.html, LastHourScanner_%fileName%.txt
- LastHrLine := 160
- readErrLastHrReadTotal := 0
- readErrLastHrErrTotal := 0
- Loop, {
- FileReadLine, line2, LastHourScanner_%fileName%.txt, %LastHrLine%
- if(ErrorLevel != 0){
- break
- }
- if(InStr(line2, "<b>Time</b>", true, 1) > 0){
- ;MsgBox, Time Found
- LastHrLine += 5
- Loop, {
- FileReadLine, line2, LastHourScanner_%fileName%.txt, %LastHrLine%
- if(Instr(line2, "</p>", false, 1) = 0){
- LastHrLine += 1
- }
- else{
- break
- }
- }
- ;MsgBox, Found1
- iT := 1
- Loop, {
- if(iT = 3){
- LastHrLine += 100
- break
- }
- LastHrLine -= 1
- FileReadLine, line2, LastHourScanner_%fileName%.txt, %LastHrLine%
- subPos := Instr(line2, "</td><td>", true, 1)
- subPos += 9
- iL := 1
- Loop, {
- if(SubStr(line2, subPos + iL, 1) != Chr(60)){
- iL++
- }
- else{
- break
- }
- }
- temp := SubStr(line2, subPos, iL)
- ;MsgBox, %temp%
- readErrLastHrReadTotal += temp
- subPos := InStr(line2, "</td><td>", true, 1, 2)
- subPos += 9
- iL := 1
- Loop, {
- if(SubStr(line2, subPos + iL, 1) != Chr(60)){
- iL++
- }
- else{
- break
- }
- }
- temp := SubStr(line2, subPos, iL)
- ;MsgBox, %temp%
- readErrLastHrErrTotal += temp
- iT += 1
- }
- }
- LastHrLine += 1
- }
- ;MsgBox, %readErrLastHrReadTotal%`n%readErrLastHrErrTotal%
- LastHourPercent := readErrLastHrErrTotal/readErrLastHrReadTotal*100
- LastHourPercent := Round(LastHourPercent,2)
- if(readErrPercent > readPerc or LastHourPercent > readPerc){
- SetWorkingDir %A_ScriptDir%
- if(pcxHeader == 0){
- textVar2=
- (
- <h2><a title='PCX %pcxNum% Scanners' href='%addressName%/station/index.html' target="_blank">
- <span class="tg"><em class="tg-xyod"> <strong> PCX %pcxNum%</strong></em></span></a></h2>
- <table class="tg">
- <tbody>
- <tr>
- <td class="tg-xyoc">Scanner Name</td>
- <td class="tg-xyoc">Read Errors</td>
- <td class="tg-xyoc">Read Error `%</td>
- <td class="tg-xyoc">Read Errors in Last Hour</td>
- <td class="tg-xyoc">Read Error `% in Last Hour</td>
- </tr>
- )
- FileAppend, %textVar2%`n, ReadErrors.html
- pcxHeader=1
- endTable=1
- }
- ;MsgBox, %addressName%/station/statistic/%scannerName%.html
- textVar3=
- (
- <tr>
- <td class="tg-vqva"><span style="color:#3166FF">%scannerName%</span></td>
- <td class="tg-vqva">%readErr%</td>
- <td class="tg-dibh"><span style="color:#FE0000">%readErrPercent%</span></td>
- <td class="tg-vqva">%readErrLastHrErrTotal%</td>
- <td class="tg-dibh">%LastHourPercent%</td>
- </tr>
- )
- FileAppend, %textVar3%`n, ReadErrors.html
- SetWorkingDir %A_ScriptDir%/pcxLogs
- }
- }
- pcxFileLine := pcxFileLine + 1
- }
- pInd += (100/MaxVal)
- Progress, %pInd%
- }
- Progress, Off
- Sleep, 500
- SetWorkingDir %A_ScriptDir%
- If WinExist("ReadErrors.html"){
- WinActivate, ReadErrors.html
- Sleep, 300
- Send {F5}
- }
- else{
- Run, ReadErrors.html
- }
- Run, copyToLog.bat
- Exit()
- }
- ReadConfig()
- ConnectionTest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement