Modul Analiza sistema
Iz SDMS
Redakcija dne 16:29, 2. oktober 2007 od Aleš Trtnik (pogovor | prispevki)
Klic
Sub UsageReport
Sub UsageReport
Dim I, J, K As Long, D As DateTime, Usg, Rpt As TStringList
Dim FL, SL As TStringlist
FL = CreateStringlist
Usg = CreateStringlist
FL.FindFiles (Datapath + 'logs\usage\', '*.ini', True)
For I = 0 To FL.Count - 1
Hint ('Reading: ' + IntToStr (I+1) + '/' + IntToStr (FL.Count))
SL = CreateStringlist
SL.Load (FL.Strings (I))
J = Length (FL.Strings (I))
D = EncodeDate (StrToInt (Copy (FL.Strings (I), J-13, 4)),
StrToInt (Copy (FL.Strings (I), J-8, 2)),
StrToInt (Copy (FL.Strings (I), J-5, 2)))
For J = 0 To SL.Count - 1
K = Pos ('$', SL.Strings (J))
If K > 0 Then
Usg.Add (Copy (SL.Strings (J), K+1, 8))
Usg.Data (Usg.Count-1) = Trunc (Date - D)
EndIf
Next
Destroy (SL)
Next
Destroy (FL)
Usg.Sorted = True
Rpt = CreateStringlist
Rpt.Add ('<html>')
Rpt.Add ('<head>')
Rpt.Add ('<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">')
Rpt.Add ('<meta http-equiv="Content-Language" content="sl">')
Rpt.Add ('<meta http-equiv="Expires" CONTENT="0">')
Rpt.Add ('<title></title>')
Rpt.Add ('<style>')
Rpt.Add ()
Rpt.Add ('</style>')
Rpt.Add ('</head>')
Rpt.Add ('<body>')
Rpt.Add ('
Analiza uporabe objektov v sistemu dne ' + DateTimeToStr (Now) + '
') Rpt.Add ('
| Ime | Uporabljen zadnjih 7 | 14 | 30 | 90 | 180 dni | 360 dni | vse dni |
|---|
')
UsageReportObject (, Usg, Rpt, Root.SelectFolder('Izberi mapo za analizo'))
Rpt.Add ('</body>')
Rpt.Add ('</html>')
Rpt.Save (Datapath + 'Analiza.htm')
ShowHTML('Analiza uporabe', Datapath + 'Analiza.htm')
Destroy (Rpt)
Destroy (Usg)
EndSub
Sub UsageReportObject (Level As String, Usg, Rpt As TStringList, F As TFolder)
Dim I, J, K, C1, C2, C3, C4, C5, C6, C7 as Long, F1 As TFolder, S As String
Hint ('Analizing: ' + Level + F.Name )
Rpt.Add ('
<img border=0 src="' + ProgramPath + 'htm\' + Copy (IntToHex (K), 7, 2) + '.gif"> ' + Level + F.Name + '/' + '
') Rpt.Add ('
') For I = 0 To F.Count - 1 F1 = F.Items (I) If F1.IsObject Then S = '' J = Usg.Find (IntToHex (F1.ID)) If J >= 0 Then C1 = 0 C2 = 0 C3 = 0 C4 = 0 C5 = 0 C6 = 0 C7 = 0 While Usg.Strings(J) = IntToHex (F1.ID) If Usg.Data(J) <= 7 Then C1 = C1 + 1 EndIf If Usg.Data(J) <= 14 Then C2 = C2 + 1 EndIf If Usg.Data(J) <= 30 Then C3 = C3 + 1 EndIf If Usg.Data(J) <= 90 Then C4 = C4 + 1 EndIf If Usg.Data(J) <= 180 Then C5 = C5 + 1 EndIf If Usg.Data(J) <= 360 Then C6 = C6 + 1 EndIf C7 = C7 + 1 J = J + 1 If J = Usg.Count Then Break EndIf Wend Rpt.Add (S + '') Else Rpt.Add (S + '') EndIf
EndIf
Next
Rpt.Add ('| <img border=0 src="' + ProgramPath + 'htm\' + Copy (IntToHex (F1.ObjectType), 7, 2) + '.gif"> ' + F1.Name + ' | ' + FormatFloat ('#', C1) + ' | ' + FormatFloat ('#', C2) + ' | ' + FormatFloat ('#', C3) + ' | ' + FormatFloat ('#', C4) + ' | ' + FormatFloat ('#', C5) + ' | ' + FormatFloat ('#', C6) + ' | ' + FormatFloat ('#', C7) + ' |
| Ni uporabljen | |||||||
')
For I = 0 To F.Count - 1
F1 = F.Items (I)
If F1.IsFolder Then
UsageReportObject (Level + F.Name + '/', Usg, Rpt, F1)
EndIf
Next
EndSub