网站导航免费论文 原创论文 论文搜索 原创论文 网学软件 学术大家 资料中心 会员中心 问题解答 原创论文 论文素材 设计下载 最新论文 下载排行 论文上传 在线投稿 联系我们
返回网学首页
网学联系
最新论文 推荐专题 热门论文 素材专题
当前位置: 网学 > 编程文档 > VB.net > 正文
VB.NET开发扫描客户端服务工具
来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/15
下载{$ArticleTitle}原创论文样式
iplist As Xml.XmlNode

Dim ipitem As Xml.XmlNode

Dim DBinfoF As New Xml.XmlDocument()

Dim DBinfo As Xml.XmlNode

Dim LanID As String

Dim i As Integer

Dim timestart As Integer

Dim ThreadCounterStarted As Integer


ThreadCounterStarted = 0

ThreadCounterStopped = 0

Dim server As String

Dim database As String

Dim uid As String

Dim pwd As String

Dim table As String

Dim connstr, connstr1 As String

Dim ServiceName As String

Dim Purgestr As String

Try

DBinfoF.Load(dbf) ‘读取数据库信息文件

Catch nodb As Exception

MsgBox(nodb.Message & "Wrong DB info file name.")

Exit Sub

End Try

Try

iplistF.Load(ipf) ‘读取IP列表文件

Catch noip As Exception

MsgBox(noip.Message & "Wrong IP list file name.")

Exit Sub

End Try

‘分析数据库信息文件

DBinfo = DBinfoF.ChildNodes(0)

server = DBinfo.ChildNodes(0).InnerText

database = DBinfo.ChildNodes(1).InnerText

uid = DBinfo.ChildNodes(2).InnerText

pwd = DBinfo.ChildNodes(3).InnerText

ServiceName = DBinfo.ChildNodes(4).InnerText

table = DBinfo.ChildNodes(4).Attributes(0).Value

‘根据分析所得,构造连接字符串

connstr1 = "server=" & server & ";database=" & database & ";uid=" & uid & ";password=" & pwd

conn1 = New SqlClient.SqlConnection(connstr1) ‘实例化数据库连接

conn1.Open() ‘打开数据库连接

Dim sa As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("select * from " & table, conn1)

Dim combu As New SqlClient.SqlCommandBuilder(sa)

sa.Fill(ds, table) ‘填充DataSet

ds.Clear() ‘清空旧的数据

Dim IPAddress As String

‘分析IP列表文件

iplist = iplistF.ChildNodes(0)

Dim Ai As Integer

Dim ipexcepCount As Integer

Dim ipexcep As Xml.XmlNode

For Each ipitem In iplist.ChildNodes

Dim Excep(2, 83) As Integer

LanID = ipitem.Attributes(0).Value‘得到网络ID

For i = 2 To 254 ‘从2到254,根据每个网络ID构造IP地址

Ai = 0

‘以下判断是为了跳过保留地址段

If ipitem.HasChildNodes Then

ipexcepCount = ipitem.ChildNodes.Count

ReDim Excep(2, ipexcepCount - 1)

For Each ipexcep In ipitem.ChildNodes

Excep(0, Ai) = CInt(ipexcep.Attributes(0).Value)

Excep(1, Ai) = CInt(ipexcep.Attributes(1).Value)

Ai = Ai + 1

Next

End If

For Ai = 0 To ipexcepCount - 1

If i >= Excep(0, Ai) And i <= Excep(1, Ai) Then

Console.WriteLine("跳过保留地址: " & LanID & i.ToString)

GoTo SkipIP

End If

Next

machineIP = LanID & i.ToString ‘IP地址

‘以下触发线程以,得到服务状态

Dim getSt As New GetStatus(machineIP, ServiceName, table)

Dim GetStThread As New Thread(New ThreadStart(AddressOf getSt.GetStausF))

GetStThread.Start()

ThreadCounterStarted = ThreadCounterStarted + 1‘启动线程数加1

Console.WriteLine("线程" & machineIP & " 启动。检测 " & ServiceName)

‘每启动100个线程,程序主线程停止15秒,避免太多线程造成内存溢出

If (ThreadCounterStarted Mod 100) = 0 Then

Console.WriteLine("等待 .")

Thread.CurrentThread.Sleep(15000)

GC.Collect() ''force garbage collection to aviod outOfMemory when run with long IP list

End If

SkipIP:

Next

Next

Console.WriteLine("Exiting program ") ‘所有线程都已触发

F
  • 上一篇资讯: VB.NET中的变量范围差异
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号