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
|
Imports System.Xml
Imports System.Text
PublicClass frmAnalyse
Public received_time AsString = ""
Public end_time AsString = ""
Public percentage_processed AsInteger = 0
Public description AsString = ""
Public index_command AsString = ""
PrivateSub frmAnalyse_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Try
timer1.Enabled = True
timer1.Start()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Erreur")
EndTry
EndSub
PrivateSub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tChekDrecompact.Tick
Try
Me.pbAnalyse.Maximum = 100
bwAnalyse.RunWorkerAsync()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Erreur")
EndTry
EndSub
PrivateSub ReadXML(ByVal xnod As XmlNode)
Dim xnodWorking As XmlNode
Dim strValue AsString = CType(xnod.Value, String)
If Len(strValue) > 0 Then
SelectCase xnod.ParentNode.LocalName
Case"received_time"
received_time = xnod.Value
IO.File.AppendAllText("C:\drecompact.log", received_time & vbNewLine)
Case"end_time"
end_time = xnod.Value
IO.File.AppendAllText("C:\drecompact.log", end_time & vbNewLine)
Case"percentage_processed"
percentage_processed = xnod.Value
IO.File.AppendAllText("C:\drecompact.log", percentage_processed & vbNewLine)
Case"description"
description = xnod.Value
IO.File.AppendAllText("C:\drecompact.log", description & vbNewLine)
Case"index_command"
index_command = xnod.Value
IO.File.AppendAllText("C:\drecompact.log", index_command & vbNewLine)
EndSelect
EndIf
If xnod.HasChildNodes Then
xnodWorking = xnod.FirstChild
DoUntil IsNothing(xnodWorking)
ReadXML(xnodWorking)
xnodWorking = xnodWorking.NextSibling
Loop
EndIf
EndSub
PrivateSub bwAnalyse_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bwAnalyse.DoWork
'Parse le fichier XML...
Dim xmlData AsNew XmlDocument
xmlData.Load(My.Computer.FileSystem.SpecialDirectories.Temp & "\drecompact.xml")
Dim xnod As XmlNode = xmlData.DocumentElement
ReadXML(xnod)
bwAnalyse.ReportProgress(percentage_processed)
EndSub
PrivateSub bwAnalyse_ProgressChanged(ByVal sender AsObject, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bwAnalyse.ProgressChanged
Me.pbAnalyse.Value = e.ProgressPercentage
EndSub
PrivateSub bwAnalyse_RunWorkerCompleted(ByVal sender AsObject, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bwAnalyse.RunWorkerCompleted
timer1.Stop()
timer1.Enabled = False
EndSub
EndClass
|
Partager