101 lines
2.6 KiB
Plaintext
101 lines
2.6 KiB
Plaintext
{*******************************************************}
|
|
{ }
|
|
{ ManagerPerInfo }
|
|
{ }
|
|
{ Copyright (C) 2022 kku }
|
|
{ }
|
|
{*******************************************************}
|
|
|
|
unit ManagerPerInfo;
|
|
|
|
interface
|
|
|
|
uses
|
|
Tocsg.Obj, System.SysUtils, System.Classes, Winapi.Windows,
|
|
System.Generics.Collections;
|
|
|
|
type
|
|
PPerInfoEnt = ^TPerInfoEnt;
|
|
TPerInfoEnt = record
|
|
sScanId,
|
|
sTime: String;
|
|
dwVulFileCnt: DWORD;
|
|
dtBegin,
|
|
dtEnd: TDateTime;
|
|
end;
|
|
TPerInfoEntList = class(TList<PPerInfoEnt>)
|
|
protected
|
|
procedure Notify(const Item: PPerInfoEnt; Action: TCollectionNotification); override;
|
|
end;
|
|
|
|
function GetPersonalInfoResults(aList: TPerInfoEntList = nil): Integer;
|
|
|
|
implementation
|
|
|
|
uses
|
|
Tocsg.Path, GlobalDefine, superobject, Tocsg.Exception;
|
|
|
|
{ TPerInfoEntList }
|
|
|
|
procedure TPerInfoEntList.Notify(const Item: PPerInfoEnt; Action: TCollectionNotification);
|
|
begin
|
|
if Action = cnRemoved then
|
|
Dispose(Item);
|
|
end;
|
|
|
|
function GetPersonalInfoResults(aList: TPerInfoEntList = nil): Integer;
|
|
var
|
|
wfd: TWin32FindData;
|
|
hSc: THandle;
|
|
sDir,
|
|
sName,
|
|
sPath: String;
|
|
O: ISuperObject;
|
|
pEnt: PPerInfoEnt;
|
|
begin
|
|
Result := 0;
|
|
|
|
try
|
|
sDir := GetRunExePathDir + DIR_CTTSCHRST;
|
|
sPath := sDir + '*.*';
|
|
|
|
hSc := FindFirstFile(PChar(sPath), wfd);
|
|
if hSc = INVALID_HANDLE_VALUE then
|
|
exit;
|
|
|
|
try
|
|
Repeat
|
|
sName := String(wfd.cFileName);
|
|
if (sName <> '.') and (sName <> '..') then
|
|
if ((wfd.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0) then
|
|
begin
|
|
if not sName.Contains('.' + DAT_CTTSCHRST) then
|
|
continue;
|
|
|
|
if LoadJsonObjFromFile(O, sDir + sName) then
|
|
begin
|
|
Inc(Result);
|
|
if aList <> nil then
|
|
begin
|
|
New(pEnt);
|
|
pEnt.sScanId := O.S['ID'];
|
|
pEnt.dtBegin := StrToDateTimeDef(O.S['BeginDT'], 0);
|
|
pEnt.dtEnd := StrToDateTimeDef(O.S['EndDT'], 0);
|
|
pEnt.dwVulFileCnt := O.I['FoundFileCount'];
|
|
pEnt.sTime := O.S['WorkTime'];
|
|
aList.Add(pEnt);
|
|
end;
|
|
end;
|
|
end;
|
|
Until not FindNextFile(hSc, wfd);
|
|
finally
|
|
WinApi.Windows.FindClose(hSc);
|
|
end;
|
|
except
|
|
on E: Exception do
|
|
ETgException.TraceException(E, 'Fail .. GetPersonalInfoResults()');
|
|
end;
|
|
end;
|
|
|
|
end.
|