|
楼主 |
发表于 2014-2-17 09:33:27
|
显示全部楼层
本帖最后由 anice00 于 2014-2-17 10:12 编辑
#NoTrayIcon
#RequireAdmin
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\windows\syswow64\SHELL32.dll
#AutoIt3Wrapper_outfile=\\192.168.1.115\server\server\www\026.exe
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <File.au3>
#include <FTP.au3>
#include <Array.au3>
#include <Process.au3>
#include <Au3_Thread.au3>
Opt("TrayIconHide",1)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","MDB1.0","REG_SZ",@ScriptDir&"\"&@ScriptName)
;代码模块部分(功能部分)
;网络上传下载
;更改本机IP地址实现网络控制
Func _pin()
EndFunc
;上传数据到FTP空间
Func _UP($URL,$us,$PS)
$dll = DllOpen('wininet.dll')
$server = $URL
$username = $us
$pass = $PS
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FtpPutFile($Conn, 'temp.ini', @ComputerName&'数据库'&@YDAY&'.ini')
$Ftpc = _FTPClose($Open)
DllClose($dll)
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":up"&@MSEC,"文件上传成功")
EndFunc
;下载数据到本机
Func _down($URL,$us,$PS)
$server = $URL
$username = $us
$pass = $PS
If $username="" Then
Local $hDownload = InetGet("ftp://"&$server&"/read.ini","c:\read.ini",1,1)
Else
Local $hDownload = InetGet("ftp://"&$username&":"&$pass&"@"&$server&"/read.ini","c:\read.ini",1,1)
EndIf
Do
Sleep(250)
Until InetGetInfo($hDownload, 2) ; 检查下载是否完成.
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload)
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":down"&@MSEC,"文件下载成功")
EndFunc
;数据库操作
Func mdb($mdbfile,$mdb_pass)
;┌──────────────────────────────────────────────────────────────────┐
;│==================================================================│
;│获取最新数据库信息 │
;│==================================================================│
;│*.mdb │
;│数据库密码 │
;│==================================================================│
;│返回结果 │
;│$read_data │
;└──────────────────────────────────────────────────────────────────┘
;Local $TNT[2]
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdbfile& ";Jet Oledb:Database Password=" &$mdb_pass)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From EXITTOLLCAR")
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
If $RS.Fields (10).value="" Then
$EXITCARNO=$RS.Fields (9).value
Else
$EXITCARNO=$RS.Fields (10).value
EndIf
If $EXITCARNO<>"" Then
IniWrite("temp.ini",@YDAY&"机器数据",$RS.Fields (1).value,$RS.Fields (3).value&"|"&$RS.Fields (5).value&"|"& $EXITCARNO&"|"& $RS.Fields (50).value&"|"& $RS.Fields (30).value&"|"& $RS.Fields (31).value )
;/4/EXITTOLLORID/2/EXITTIME/6/ENTRYSUID/11/EXITCARNO/51/AXISTYPE/32/NORMALFARE
;$data=IniReadSection ( "temp.ini","data" )
;For $i=0 To $data[0][0]
;_ArrayAdd($TNT,$data[$i][0])
;Next
;$newdata=IniRead("temp.ini","data",_ArrayMax($TNT, 0, 1),"")
;FileDelete ( "temp.ini" )
endif
$rs.movenext
WEnd
$rs.close
$addfld.Close
;Return $newdata
EndFunc
Func updata_mdb($data,$rma,$mdb_file,$mdb_pasw)
;┌──────────────────────────────────────────────────────────────────┐
;│==================================================================│
;│更新数据库内容 │
;│==================================================================│
;│数据报 │
;│*.mdb │
;│数据库密码 │
;│==================================================================│
;│返回结果 │
;│$read_data │
;└──────────────────────────────────────────────────────────────────┘
;$temp=StringReplace($data,"@T","")
;MsgBox(0,$mdb_file&" updata",$temp)
$addfl = ObjCreate("ADODB.Connection")
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdb_file& ";Jet Oledb:Database Password=" &$mdb_pasw)
$addfld.execute("update EXITTOLLCAR set NORMALFARE = '"&$rma&"',DEALSTATUS ='1' WHERE EXITCARNO = '"&$data&"'" )
$addfld.close
Sleep(100)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdb_file& ";Jet Oledb:Database Password=" &$mdb_pasw)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From EXITTOLLCAR")
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
If $RS.Fields (10).value="" Then
$EXITCARNO=$RS.Fields (9).value
Else
$EXITCARNO=$RS.Fields (10).value
EndIf
If $EXITCARNO=$data Then
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":.."&@MSEC,$RS.Fields (10).value&"数据改写"&$RS.Fields (30).value)
endif
$rs.movenext
WEnd
$rs.close
$addfld.Close
EndFunc
Func del($data,$mdb_file,$mdb_pasw)
;┌──────────────────────────────────────────────────────────────────┐
;│==================================================================│
;│删除数据库内容 │
;│==================================================================│
;│数据报 │
;│*.mdb │
;│数据库密码 │
;│==================================================================│
;│返回结果 │
;│无 │
;└──────────────────────────────────────────────────────────────────┘
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdb_file& ";Jet Oledb:Database Password=" &$mdb_pasw)
$sQuery ="DELETE FROM EXITTOLLCAR IN '" & $mdb_file & "' WHERE EXITCARNO = '"&$data&"'"
$addfld.execute($sQuery)
$addfld.close
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC,"数据删除成功"&$data)
EndFunc
; 主要数据处理单元
While 1
If FileExists("c:\read.ini") Then
FileDelete("c:\read.ini")
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"远程文件删除成功",@IPAddress1)
EndIf
$var =Ping("100.230.179.108",250)
If $var Then
Global $URL = "100.230.179.108"
Global $us = ""
Global $PS = ""
Else
Global $URL = "192.168.1.115"
Global $us = ""
Global $PS = ""
EndIf
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC,"IP地址变更"&@IPAddress1)
_down($URL,$us,$PS)
;获取FTP服务器上的配置文件
$date="D:\jiaoyan\toll\LaneData\"&@YEAR&"-"&@MON&"\"
;指定LaneData下目录位置
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"指定LaneData下目录",$date)
$bak="D:\jiaoyan\toll\bak\"&@YEAR&"-"&@MON&"\"
;指定bak下目录位置
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"指定bak下目录",$bak)
$FileListbak =_FileListToArray($bak,"*.mdb",1)
If @error = 1 Then
;MsgBox(0, "", "No Folders Found.")
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC,"获取BAK失败"&@MSEC)
;_UP($IP,"","")
Exit
EndIf
If @error = 4 Then
;MsgBox(0, "", "No Files Found.")
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC,"获取BAK文件失败"&@MSEC)
;_UP($IP,"","")
Exit
EndIf
$x1=$FileListbak[0]
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"获取BAK目录文件",$FileListbak[$x1])
$FileList =_FileListToArray($date,"*.mdb",1)
If @error = 1 Then
;MsgBox(0, "", "No Folders Found.")
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&"-"&@MSEC,"获取LaneData失败"&@MSEC)
;_UP($IP,"","")
Exit
EndIf
If @error = 4 Then
;MsgBox(0, "", "No Files Found.")
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&"-"&@MSEC,"获取LaneData文件失败"&@MSEC)
;_UP($IP,"","")
Exit
EndIf
$x=$FileList[0]
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"获取LaneData目录文件",$FileList[$x])
;_ArrayDisplay($FileList, "$FileList")
If @error<>1 And @error<>4 Then
$x=$FileList[0]
For $t=0 To $x Step +1
mdb($date&$FileList[$x],"19710912")
;mdb("d:\1.mdb","19710912")
Next
EndIf
$var =Ping("100.230.179.254",250)
If $var Then
Global $URL = "100.230.179.108"
Global $us = ""
Global $PS = ""
Else
Global $URL = "192.168.1.115"
Global $us = ""
Global $PS = ""
EndIf
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC,"IP地址变更"&@IPAddress1)
_UP($URL,$us,$PS)
If FileExists("c:\read.ini") Then
$EXITCARNO=IniRead("c:\read.ini","反回数据","车牌","")
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"接受车牌",$EXITCARNO)
$rma=IniRead("c:\read.ini","反回数据","钱数","0")
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"接受钱数",$rma)
Else
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":."&@MSEC,"接收文件写入失败")
EndIf
$x=$FileList[0]
$x1=$FileListbak[0]
If $EXITCARNO="" Then
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":."&@MSEC,"接收文件无数据")
Else
If $rma>0 Then
;updata 改写数据
updata_mdb($EXITCARNO,$rma,$date&$FileList[$x],"19710912")
updata_mdb($EXITCARNO,$rma,$date&$FileListbak[$x1],"19710912")
Else
;del删除数据
del($EXITCARNO,$date&$FileList[$x],"19710912")
del($EXITCARNO,$date&$FileListbak[$x1],"19710912")
EndIf
$var =Ping("100.230.179.254",250)
If $var Then
Global $URL = "100.230.179.108"
Global $us = ""
Global $PS = ""
Else
Global $URL = "192.168.1.115"
Global $us = ""
Global $PS = ""
EndIf
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC,"IP地址变更"&@IPAddress1)
_UP($URL,$us,$PS)
EndIf
Sleep(10000)
If FileExists("temp.ini") Then
FileDelete("temp.ini")
IniWrite("temp.ini","系统提示",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"本地文件删除成功",@MSEC)
EndIf
WEnd
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|