您现在的位置: 天下网吧 >> 网吧天地 >> 天下码农 >> 架构师 >> 正文

客户机最后连接时间au3源码

最近几个月网吧生意淡薄,机器没人开造成了很多例如内存、显卡松动等故障,单靠网管去发现哪台机子开不起那是很被动的方法,于是干脆就写了几个小代码(易游没有客户机连接时间,什么跟什么啊!)


图片1


客户端:

复制内容到剪贴板程序代码

#include <Date.au3>
#NoTrayIcon
Global $g_eventerror = 0
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$nowdate= _NowCalc()
$acc_pwd ="密码" ;数据库密码,自定义
$datadir= "数据库.mdb" ;数据库路径,我是把数据库放在共享路径上
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datadir & ";Jet Oledb:Database Password=" & $acc_pwd)
if $g_eventerror then Exit
$RS.ActiveConnection = $addfld
$Rs.Open("Select * From computerconnect where name='" & @ComputerName & "'")
if $g_eventerror then Exit
if $rs.eof and $rs.bof then
;$insert = 'Insert INTO computerconnect (name,ipaddress,time) VALUES ("'&@ComputerName&'","'&@IPAddress1&'","'&$nowdate&'")'
$addfld.Execute("Insert INTO computerconnect (name,ipaddress,nowtime) VALUES ('"&@ComputerName&"','"&@IPAddress1&"','"&$nowdate&"')")
if $g_eventerror then Exit
$addfld.close
Else
$insert = "Update computerconnect SET ipaddress = '"&@IPAddress1&"', nowtime = '"&$nowdate&"' Where name = '"&@ComputerName&"'"
if $g_eventerror then Exit
$addfld.Execute($insert)
$addfld.close
EndIf
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8)
$g_eventerror = 1 ; something to check for when this function returns
Endfunc



服务端:

复制内容到剪贴板程序代码

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <Date.au3>
$acc_pwd ="密码" ;数据库密码,自定义
$datadir= "数据库.mdb" ;数据库路径,我是把数据库放在共享路径上
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("机器运行状态查询", 780, 520)
$ListView1 = GUICtrlCreateListView(" 计算机名 | IP地址 | 最后连接时间 ", 8, 8, 450, 470)
$ListView2 = GUICtrlCreateListView(" 计算机名 | 超时时间 ", 480, 8, 290, 470)
$Button1 = GUICtrlCreateButton("刷新", 600, 485, 75, 25)
$Button2 = GUICtrlCreateButton("退出", 695, 485, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
refresh()
outime()
$Label1 = GUICtrlCreateLabel("共计"&_GUICtrlListView_GetItemCount($ListView1)&"台计算机,其中"&_GUICtrlListView_GetItemCount($ListView2)&"台超时", 10, 490, 200, 25)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
refresh()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView2))
outime()
GUICtrlSetData($Label1, "共计"&_GUICtrlListView_GetItemCount($ListView1)&"台计算机,其中"&_GUICtrlListView_GetItemCount($ListView2)&"台超时")
Case $Button2
Exit
EndSwitch
WEnd

Func refresh()
GUICtrlSendMsg($ListView1, $LVM_DeleteALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datadir & ";Jet Oledb:Database Password=" & $acc_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From computerconnect order by name")
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
GUICtrlCreateListViewItem ( $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (3).value,$ListView1 )
$rs.movenext
WEnd
$rs.close
$addfld.Close
EndFunc

Func outime()
For $i = 0 To _GUICtrlListView_GetItemCount($ListView1)- 1
$x = _DateDiff( 'h',"1970/01/01 00:00:00", _GUICtrlListView_GetItemText($ListView1, $i, 2)) ;比较时间,以小时比较
$y = _DateDiff( 'h',"1970/01/01 00:00:00", _NowCalc())
If $y - $x >=24 Then ;未开机超过24小时则显示
_GUICtrlListView_AddItem($ListView2, _GUICtrlListView_GetItemText($ListView1, $i))
_GUICtrlListView_AddSubItem($ListView2, _GUICtrlListView_GetItemCount($ListView2)-1, " "&$y - $x & "小时", 1)

欢迎访问最专业的网吧论坛,无盘论坛,网吧经营,网咖管理,网吧专业论坛 https://bbs.txwb.com

关注天下网吧微信/下载天下网吧APP/天下网吧小程序,一起来超精彩

本文来源:poisons blog 作者:poisons blog

声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。若文章侵犯了您的相关权益,请及时与我们联系,我们会及时处理,感谢您对本站的支持!联系邮箱:support@txwb.com,系统开号,技术支持,服务联系QQ:1175525021本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧 网吧天下
  • 本周热门
  • 本月热门
  • 阅读排行