Rewrite
This commit is contained in:
parent
d03d6419dc
commit
df00c62ae8
|
@ -20,7 +20,7 @@ Const
|
||||||
fmRWDN = 66;
|
fmRWDN = 66;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
RecHistory = Record // from records.pas 1.10
|
RecHistory = Record // From records.pas 1.10
|
||||||
Date : LongInt;
|
Date : LongInt;
|
||||||
Emails : Word;
|
Emails : Word;
|
||||||
Posts : Word;
|
Posts : Word;
|
||||||
|
@ -36,35 +36,84 @@ Type
|
||||||
SMTP : Word;
|
SMTP : Word;
|
||||||
NNTP : Word;
|
NNTP : Word;
|
||||||
HTTP : Word;
|
HTTP : Word;
|
||||||
Reserved : Array[1..26] of Byte;
|
Hourly : Array[0..23] of Byte;
|
||||||
|
Reserved : Array[1..2] of Byte;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function DisplayMonthly : Boolean;
|
Var
|
||||||
|
Days : LongInt;
|
||||||
|
Calls : LongInt;
|
||||||
|
Month : Array[1..12] of Cardinal;
|
||||||
|
Week : Array[0..6] of Cardinal;
|
||||||
|
Hour : Array[0..23] of Cardinal;
|
||||||
|
|
||||||
|
Procedure DrawBar (XPos, Value: Byte);
|
||||||
|
Var
|
||||||
|
Temp : Byte;
|
||||||
|
Begin
|
||||||
|
For Temp := 1 to Value Do
|
||||||
|
WriteXY (XPos, 18 - Temp, 1, #219 + #219 + #219);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure DisplayMonthly;
|
||||||
|
Var
|
||||||
|
Count : Byte;
|
||||||
|
Count2 : Byte;
|
||||||
|
Begin
|
||||||
|
WriteLn ('|CL|09|17 ' + #176 + ' |15Monthly Usage Graph ' + PadLT(strComma(Days) + '|07 days, |15' + strComma(Calls) + ' |07calls ', 63, ' ') + '|09' + #176 + ' |16');
|
||||||
|
|
||||||
|
GotoXY (6, 18);
|
||||||
|
|
||||||
|
For Count := 1 to 12 Do
|
||||||
|
Write ('|08' + #196 + #196 + #196 + ' ');
|
||||||
|
|
||||||
|
WriteXY (6, 19, 14, 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec');
|
||||||
|
WriteXY (2, 21, 08, strRep(#196, 78));
|
||||||
|
|
||||||
|
For Count := 1 to 12 Do
|
||||||
|
For Count2 := 15 DownTo 1 Do Begin
|
||||||
|
GotoXY (Count * 6, 2 + Count2);
|
||||||
|
Write (#250 + #250 + #250);
|
||||||
|
End;
|
||||||
|
|
||||||
|
For Count := 1 to 12 Do
|
||||||
|
DrawBar (6 * Count, Month[Count]);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure DisplayWeekly;
|
||||||
|
Var
|
||||||
|
Count : Byte;
|
||||||
|
Count2 : Byte;
|
||||||
|
Begin
|
||||||
|
WriteLn ('|CL|09|17 ' + #176 + ' |15Weekly Usage Graph ' + PadLT(strComma(Days) + '|07 days, |15' + strComma(Calls) + ' |07calls ', 64, ' ') + '|09' + #176 + ' |16');
|
||||||
|
|
||||||
|
For Count := 0 to 6 Do Begin
|
||||||
|
GotoXY (10 * (Count + 1), 18);
|
||||||
|
Write ('|08' + #196 + #196 + #196);
|
||||||
|
End;
|
||||||
|
|
||||||
|
WriteXY (10, 19, 14, 'Sun Mon Tue Wed Thu Fri Sat');
|
||||||
|
WriteXY ( 2, 21, 08, strRep(#196, 78));
|
||||||
|
|
||||||
|
For Count := 0 to 6 Do
|
||||||
|
For Count2 := 15 DownTo 1 Do Begin
|
||||||
|
GotoXY (10 * (Count + 1), 2 + Count2);
|
||||||
|
Write (#250 + #250 + #250);
|
||||||
|
End;
|
||||||
|
|
||||||
|
For Count := 0 to 6 Do
|
||||||
|
DrawBar (10 * (Count + 1), Week[Count]);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure CalculateHistory;
|
||||||
Var
|
Var
|
||||||
HistFile : File;
|
HistFile : File;
|
||||||
Days : Cardinal;
|
|
||||||
OneDay : RecHistory;
|
OneDay : RecHistory;
|
||||||
Months : Array[1..12] of Cardinal;
|
TempLong : Cardinal;
|
||||||
CurMonth : Byte;
|
TempReal : Real;
|
||||||
TotalCalls : Cardinal;
|
Count : LongInt;
|
||||||
Loop1 : Byte;
|
Highest : Cardinal;
|
||||||
Loop2 : Byte;
|
|
||||||
|
|
||||||
Procedure DrawBar (XPos, Value: Byte);
|
|
||||||
Var
|
|
||||||
Temp : Byte;
|
|
||||||
Begin
|
|
||||||
Write ('|01');
|
|
||||||
|
|
||||||
For Temp := 1 to Value Do Begin
|
|
||||||
GotoXY (XPos, 18 - Temp);
|
|
||||||
Write (#219 + #219 + #219);
|
|
||||||
End;
|
|
||||||
End;
|
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
DisplayMonthly := False;
|
|
||||||
|
|
||||||
fAssign (HistFile, CfgDataPath + 'history.dat', fmRWDN);
|
fAssign (HistFile, CfgDataPath + 'history.dat', fmRWDN);
|
||||||
fReset (HistFile);
|
fReset (HistFile);
|
||||||
|
|
||||||
|
@ -77,58 +126,94 @@ Begin
|
||||||
|
|
||||||
Days := fSize(HistFile) / SizeOf(OneDay);
|
Days := fSize(HistFile) / SizeOf(OneDay);
|
||||||
|
|
||||||
WriteLn ('|16|CL|15Calculating Monthly usage (' + strComma(Days) + ' days)...');
|
WriteLn ('|16|CL|15Calculating usage for last ' + strComma(Days) + ' days...');
|
||||||
|
|
||||||
While Not fEof(HistFile) Do Begin
|
While Not fEof(HistFile) Do Begin
|
||||||
fReadRec(HistFile, OneDay);
|
fReadRec(HistFile, OneDay);
|
||||||
|
|
||||||
CurMonth := Str2Int(Copy(DateStr(OneDay.Date, 1), 1, 2));
|
Calls := Calls + OneDay.Calls;
|
||||||
Months[CurMonth] := Months[CurMonth] + OneDay.Calls;
|
TempLong := Str2Int(Copy(DateStr(OneDay.Date, 1), 1, 2));
|
||||||
TotalCalls := TotalCalls + OneDay.Calls;
|
Month[TempLong] := Month[TempLong] + OneDay.Calls;
|
||||||
|
TempLong := DayOfWeek(OneDay.Date);
|
||||||
|
Week[TempLong] := Week[TempLong] + OneDay.Calls;
|
||||||
|
|
||||||
|
For Count := 0 to 23 Do
|
||||||
|
Hour[Count] := Hour[Count] + OneDay.Hourly[Count];
|
||||||
|
End;
|
||||||
|
|
||||||
|
Highest := 0;
|
||||||
|
|
||||||
|
For Count := 1 to 12 Do
|
||||||
|
If Month[Count] > Highest Then
|
||||||
|
Highest := Month[Count];
|
||||||
|
|
||||||
|
For Count := 1 to 12 Do
|
||||||
|
If Month[Count] > 0 Then Begin
|
||||||
|
TempReal := (Month[Count] / Highest * 100);
|
||||||
|
Month[Count] := TempReal / 7 + 1;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Highest := 0;
|
||||||
|
|
||||||
|
For Count := 0 to 6 Do
|
||||||
|
If Week[Count] > Highest Then
|
||||||
|
Highest := Week[Count];
|
||||||
|
|
||||||
|
For Count := 0 to 6 Do
|
||||||
|
If Week[Count] > 0 Then Begin
|
||||||
|
TempReal := (Week[Count] / Highest * 100);
|
||||||
|
Week[Count] := TempReal / 7 + 1;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Highest := 0;
|
||||||
|
|
||||||
|
For Count := 0 to 23 Do
|
||||||
|
If Hour[Count] > Highest Then
|
||||||
|
Highest := Hour[Count];
|
||||||
|
|
||||||
|
For Count := 0 to 23 Do
|
||||||
|
If Hour[Count] > 0 Then Begin
|
||||||
|
TempReal := (Hour[Count] / Highest * 100);
|
||||||
|
Hour[Count] := TempReal / 7 + 1;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
fClose (HistFile);
|
fClose (HistFile);
|
||||||
|
|
||||||
For Loop1 := 1 to 12 Do Begin
|
|
||||||
If Months[Loop1] > 0 Then
|
|
||||||
Months[Loop1] := Months[Loop1] / TotalCalls * 15
|
|
||||||
Else
|
|
||||||
Months[Loop1] := 1;
|
|
||||||
End;
|
|
||||||
|
|
||||||
WriteLn ('|CL|09|17 ' + #176 + ' |15Monthly Usage Graph ' + PadLT(strComma(Days) + '|07 days, |15' + strComma(TotalCalls) + ' |07calls ', 63, ' ') + '|09' + #176 + ' |16');
|
|
||||||
|
|
||||||
GotoXY (6, 18);
|
|
||||||
|
|
||||||
For Loop1 := 1 to 12 Do
|
|
||||||
Write ('|08' + #196 + #196 + #196 + ' ');
|
|
||||||
|
|
||||||
GotoXY (6, 19);
|
|
||||||
Write ('|14Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec');
|
|
||||||
|
|
||||||
GotoXY (2, 21);
|
|
||||||
Write ('|08|$D78' + #196);
|
|
||||||
|
|
||||||
For Loop1 := 1 to 12 Do
|
|
||||||
For Loop2 := 15 DownTo 1 Do Begin
|
|
||||||
GotoXY (Loop1 * 6, 2 + Loop2);
|
|
||||||
Write (#250 + #250 + #250);
|
|
||||||
End;
|
|
||||||
|
|
||||||
For Loop1 := 1 to 12 Do
|
|
||||||
DrawBar (6 * Loop1, Months[Loop1]);
|
|
||||||
|
|
||||||
DisplayMonthly := True;
|
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Var
|
||||||
|
ShowMode : Byte;
|
||||||
Begin
|
Begin
|
||||||
If Graphics = 0 Then Begin
|
If Graphics = 0 Then Begin
|
||||||
WriteLn ('|CRSorry, usage graphs require ANSI graphics|CR|CR|PA');
|
WriteLn ('|CRSorry, usage graphs require ANSI graphics|CR|CR|PA');
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
If DisplayMonthly Then Begin
|
CalculateHistory;
|
||||||
GotoXY (28, 22);
|
|
||||||
Write ('|07Press |08[|15ENTER|08] |07to continue|PN');
|
If ParamCount > 0 Then Begin
|
||||||
|
Case Upper(ParamStr(1)) of
|
||||||
|
'MONTHLY' : DisplayMonthly;
|
||||||
|
'WEEKLY' : DisplayWeekly;
|
||||||
|
// 'HOURLY' : DisplayHourly;
|
||||||
|
Else
|
||||||
|
WriteLn ('USAGE.MPS: Invalid command line option.|PN');
|
||||||
|
End;
|
||||||
|
End Else Begin
|
||||||
|
ShowMode := 1;
|
||||||
|
|
||||||
|
Repeat
|
||||||
|
Case ShowMode of
|
||||||
|
1 : DisplayMonthly;
|
||||||
|
2 : DisplayWeekly;
|
||||||
|
// 3 : DisplayHourly;
|
||||||
|
End;
|
||||||
|
|
||||||
|
WriteXYPipe (22, 23, 7, 0, 'Press |08[|15TAB|08] |07for more or |08[|15ENTER|08] |07to Quit');
|
||||||
|
|
||||||
|
Case OneKey(#09 + #13, False) of
|
||||||
|
#09 : If ShowMode < 2 Then ShowMode := ShowMode + 1 Else ShowMode := 1;
|
||||||
|
#13 : Break;
|
||||||
|
End;
|
||||||
|
Until False;
|
||||||
End;
|
End;
|
||||||
End
|
End
|
||||||
|
|
Loading…
Reference in New Issue