595 lines
16 KiB
Plaintext
595 lines
16 KiB
Plaintext
unit DBs1AgentsMain;
|
||
|
||
interface
|
||
|
||
uses
|
||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, ManagerSetting, Tocsg.Trace,
|
||
Vcl.ExtCtrls, VirtualTrees, ThdBS1Agent, Vcl.StdCtrls;
|
||
|
||
type
|
||
PAgentEnt = ^TAgentEnt;
|
||
TAgentEnt = record
|
||
Tasker: TThdBS1Agent;
|
||
end;
|
||
|
||
TDlgBs1AgentsMain = class(TForm)
|
||
MainMenu: TMainMenu;
|
||
miConnection: TMenuItem;
|
||
miConfig: TMenuItem;
|
||
miConnSetting: TMenuItem;
|
||
miAgentsConn: TMenuItem;
|
||
miAgentsDisconn: TMenuItem;
|
||
N2: TMenuItem;
|
||
miExit: TMenuItem;
|
||
tInit: TTimer;
|
||
pnBottom: TPanel;
|
||
vtList: TVirtualStringTree;
|
||
popFun: TPopupMenu;
|
||
miChangeMode: TMenuItem;
|
||
miSleepMode: TMenuItem;
|
||
miSecuMode: TMenuItem;
|
||
miVulMode: TMenuItem;
|
||
N6: TMenuItem;
|
||
miSendBlockLog: TMenuItem;
|
||
lbTime: TLabel;
|
||
tProg: TTimer;
|
||
lbSvrInfo: TLabel;
|
||
miGetPol: TMenuItem;
|
||
procedure miExitClick(Sender: TObject);
|
||
procedure miConnSettingClick(Sender: TObject);
|
||
procedure tInitTimer(Sender: TObject);
|
||
procedure miAgentsConnClick(Sender: TObject);
|
||
procedure vtListGetHint(Sender: TBaseVirtualTree;
|
||
Node: PVirtualNode; Column: TColumnIndex;
|
||
var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string);
|
||
procedure vtListGetNodeDataSize(Sender: TBaseVirtualTree;
|
||
var NodeDataSize: Integer);
|
||
procedure miAgentsDisconnClick(Sender: TObject);
|
||
procedure miConnectionClick(Sender: TObject);
|
||
procedure vtListGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
|
||
procedure vtListFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
||
procedure vtListPaintText(Sender: TBaseVirtualTree;
|
||
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
||
TextType: TVSTTextType);
|
||
procedure miSleepModeClick(Sender: TObject);
|
||
procedure miSecuModeClick(Sender: TObject);
|
||
procedure miVulModeClick(Sender: TObject);
|
||
procedure tProgTimer(Sender: TObject);
|
||
procedure vtListCompareNodes(Sender: TBaseVirtualTree; Node1,
|
||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||
procedure vtListHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
|
||
procedure miGetPolClick(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
Trace_: TTgTrace;
|
||
Setting_: TManagerSetting;
|
||
bActive_: Boolean;
|
||
dtStart_: TDateTime;
|
||
nAddEmpNo_: Integer;
|
||
procedure TurnOnUpdateInfo;
|
||
procedure StopThreads;
|
||
public
|
||
{ Public declarations }
|
||
Constructor Create(aOwner: TComponent); override;
|
||
Destructor Destroy; override;
|
||
|
||
procedure process_WM_SYSCOMMAND(var msg: TWMSysCommand); Message WM_SYSCOMMAND;
|
||
procedure process_WM_UPDATE_AGENT(var msg: TMessage); Message WM_UPDATE_AGENT;
|
||
end;
|
||
|
||
var
|
||
DlgBs1AgentsMain: TDlgBs1AgentsMain;
|
||
|
||
implementation
|
||
|
||
uses
|
||
Define, DConnSetting, Tocsg.Safe, Tocsg.Path, Condition, Tocsg.VTUtil,
|
||
Tocsg.WinInfo, Tocsg.WTS, GlobalDefine, Tocsg.DateTime, System.DateUtils,
|
||
VirtualTrees.Types;
|
||
|
||
{$R *.dfm}
|
||
|
||
Constructor TDlgBs1AgentsMain.Create(aOwner: TComponent);
|
||
|
||
procedure FindOtherProcess;
|
||
var
|
||
sCap: String;
|
||
h: HWND;
|
||
begin
|
||
sCap := APP_TITLE + ' ' + APP_VER;
|
||
h := FindWindow('TDlgBs1AgentsMain', PChar(sCap));
|
||
while h <> 0 do
|
||
begin
|
||
Inc(nAddEmpNo_, 1000);
|
||
sCap := Format('%s %s : %d', [APP_TITLE, APP_VER, nAddEmpNo_]);
|
||
h := FindWindow('TDlgBs1AgentsMain', PChar(sCap));
|
||
if h = 0 then
|
||
break;
|
||
|
||
if nAddEmpNo_ >= 19000 then
|
||
begin
|
||
MessageBox(Handle, PChar('<27><><EFBFBD>̻<EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.'), PChar(Caption), MB_ICONSTOP or MB_OK);
|
||
TerminateProcess(GetCurrentProcess, 9);
|
||
exit;
|
||
end;
|
||
end;
|
||
Caption := sCap;
|
||
end;
|
||
|
||
begin
|
||
Inherited Create(aOwner);
|
||
nAddEmpNo_ := 0;
|
||
bActive_ := false;
|
||
CUSTOMER_TYPE := CUSTOMER_DEV;
|
||
Trace_ := TTgTrace.Create(GetRunExePathDir + 'Log\',
|
||
CutFileExt(ExtractFileName(GetRunExePath)) + '.log',
|
||
true);
|
||
Setting_ := TManagerSetting.Create;
|
||
dtStart_ := 0;
|
||
FindOtherProcess;
|
||
tInit.Enabled := true;
|
||
end;
|
||
|
||
Destructor TDlgBs1AgentsMain.Destroy;
|
||
begin
|
||
// StopThreads;
|
||
FreeAndNil(Setting_);
|
||
FreeAndNil(Trace_);
|
||
Inherited;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.TurnOnUpdateInfo;
|
||
var
|
||
pNode: PVirtualNode;
|
||
pData: PAgentEnt;
|
||
begin
|
||
vtList.BeginUpdate;
|
||
try
|
||
pNode := vtList.GetFirst;
|
||
while pNode <> nil do
|
||
begin
|
||
pData := vtList.GetNodeData(pNode);
|
||
pData.Tasker.SetUpdateAgentInfo(true);
|
||
pNode := vtList.GetNext(pNode);
|
||
end;
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.StopThreads;
|
||
var
|
||
pNode: PVirtualNode;
|
||
pData: PAgentEnt;
|
||
begin
|
||
vtList.BeginUpdate;
|
||
try
|
||
pNode := vtList.GetFirst;
|
||
while pNode <> nil do
|
||
begin
|
||
pData := vtList.GetNodeData(pNode);
|
||
pData.Tasker.StopThread;
|
||
pNode := vtList.GetNext(pNode);
|
||
end;
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miAgentsConnClick(Sender: TObject);
|
||
var
|
||
pNode: PVirtualNode;
|
||
pData: PAgentEnt;
|
||
sHead,
|
||
sEmpNo,
|
||
sComaName: String;
|
||
nCnt: Integer;
|
||
i: Integer;
|
||
begin
|
||
if bActive_ then
|
||
exit;
|
||
|
||
if gSet.SvrAddr = '' then
|
||
begin
|
||
MessageBox(Handle, PChar('<27><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
||
miConnSetting.Click;
|
||
exit;
|
||
end;
|
||
|
||
sHead := gSet.EmpNoHead;
|
||
sComaName := GetComName + '\';
|
||
|
||
vtList.BeginUpdate;
|
||
try
|
||
nCnt := gSet.ConnAgents + nAddEmpNo_;
|
||
for i := nAddEmpNo_ + 1 to nCnt do
|
||
begin
|
||
pData := VT_AddChildDataN(vtList, pNode);
|
||
sEmpNo := Format('%s%.5d', [sHead, i]);
|
||
pData.Tasker := TThdBS1Agent.Create(Handle, pNode, sEmpNo, sComaName + sEmpNo);
|
||
pData.Tasker.StartThread;
|
||
end;
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
TurnOnUpdateInfo;
|
||
miConnSetting.Enabled := false;
|
||
dtStart_ := Now;
|
||
bActive_ := true;
|
||
sHead := gSet.SvrAddr;
|
||
sHead := StringReplace(sHead, 'http://', '', [rfReplaceAll]);
|
||
sHead := StringReplace(sHead, 'https://', '', [rfReplaceAll]);
|
||
sHead := StringReplace(sHead, '/agentLogRequest.do', '', [rfReplaceAll]);
|
||
sHead := StringReplace(sHead, '/agentLogRequests.do', '', [rfReplaceAll]);
|
||
lbSvrInfo.Caption := sHead;
|
||
tProg.Enabled := true;
|
||
Application.ProcessMessages;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miAgentsDisconnClick(Sender: TObject);
|
||
begin
|
||
if not bActive_ then
|
||
exit;
|
||
|
||
if vtList.RootNodeCount >= 100 then
|
||
begin
|
||
if MessageBox(Handle, PChar('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><C3B0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.'+#13+#10+
|
||
'<27><><EFBFBD><EFBFBD><EFBFBD>Ͻðڽ<C3B0><DABD>ϱ<EFBFBD>?'+#13+#10+'(<28><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.)'),
|
||
PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit;
|
||
end else
|
||
if MessageBox(Handle, PChar('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͻðڽ<C3B0><DABD>ϱ<EFBFBD>?'),
|
||
PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit;
|
||
|
||
tProg.Enabled := false;
|
||
// StopThreads;
|
||
vtList.BeginUpdate;
|
||
try
|
||
VT_Clear(vtList);
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
miConnSetting.Enabled := true;
|
||
lbTime.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...';
|
||
lbSvrInfo.Caption := '';
|
||
bActive_ := false;
|
||
dtStart_ := 0;
|
||
Application.ProcessMessages;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miConnectionClick(Sender: TObject);
|
||
begin
|
||
miAgentsConn.Checked := bActive_;
|
||
miAgentsConn.Enabled := not miAgentsConn.Checked;
|
||
miAgentsDisconn.Enabled := not miAgentsConn.Enabled;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miConnSettingClick(Sender: TObject);
|
||
var
|
||
dlg: TDlgConnSetting;
|
||
begin
|
||
Guard(dlg, TDlgConnSetting.Create(Self));
|
||
if dlg.ShowModal = mrOk then
|
||
begin
|
||
Setting_.SvrAddr := dlg.edSvrAddr.Text;
|
||
Setting_.EmpNoHead := dlg.edEmpNoHead.Text;
|
||
Setting_.ConnAgents := StrToIntDef(dlg.edConnCnt.Text, 0);
|
||
ASSERT(Setting_.ConnAgents <> 0);
|
||
Setting_.ReadTimeout := StrToIntDef(dlg.edReadTO.Text, 0);
|
||
Setting_.ConnectTimeout := StrToIntDef(dlg.edConnTO.Text, 0);
|
||
Setting_.Save;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miExitClick(Sender: TObject);
|
||
begin
|
||
if bActive_ then
|
||
begin
|
||
if MessageBox(Handle, PChar('<27><><EFBFBD><EFBFBD><EFBFBD>Ͻðڽ<C3B0><DABD>ϱ<EFBFBD>?'),
|
||
PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit;
|
||
end;
|
||
|
||
TerminateProcess(GetCurrentProcess, 9);
|
||
|
||
Close;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miGetPolClick(Sender: TObject);
|
||
var
|
||
pNode: PVirtualNode;
|
||
pData: PAgentEnt;
|
||
begin
|
||
if vtList.SelectedCount = 0 then
|
||
exit;
|
||
|
||
vtList.BeginUpdate;
|
||
try
|
||
pNode := vtList.GetFirstSelected;
|
||
while pNode <> nil do
|
||
begin
|
||
pData := vtList.GetNodeData(pNode);
|
||
if pData.Tasker.AgentState = asConnected then
|
||
pData.Tasker.ProcessRcvPolicy(rpkAll);
|
||
|
||
pNode := vtList.GetNextSelected(pNode);
|
||
end;
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miSecuModeClick(Sender: TObject);
|
||
var
|
||
pNode: PVirtualNode;
|
||
pData: PAgentEnt;
|
||
begin
|
||
if vtList.SelectedCount = 0 then
|
||
exit;
|
||
|
||
vtList.BeginUpdate;
|
||
try
|
||
pNode := vtList.GetFirstSelected;
|
||
while pNode <> nil do
|
||
begin
|
||
pData := vtList.GetNodeData(pNode);
|
||
if pData.Tasker.AgentMode <> hmkSecurity then
|
||
begin
|
||
pData.Tasker.SendEventLog(URI_USER_ACTION, MODE_SECURITY_START, 'Security Mode');
|
||
pData.Tasker.AgentMode := hmkSecurity;
|
||
end;
|
||
pNode := vtList.GetNextSelected(pNode);
|
||
end;
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miSleepModeClick(Sender: TObject);
|
||
var
|
||
pNode: PVirtualNode;
|
||
pData: PAgentEnt;
|
||
begin
|
||
if vtList.SelectedCount = 0 then
|
||
exit;
|
||
|
||
vtList.BeginUpdate;
|
||
try
|
||
pNode := vtList.GetFirstSelected;
|
||
while pNode <> nil do
|
||
begin
|
||
pData := vtList.GetNodeData(pNode);
|
||
case pData.Tasker.AgentMode of
|
||
hmkSecurity :
|
||
begin
|
||
pData.Tasker.SendEventLog(URI_USER_ACTION, MODE_VULNER_END, 'Sleep mode');
|
||
pData.Tasker.AgentMode := hmkSleep;
|
||
end;
|
||
hmkVulnerability :
|
||
begin
|
||
pData.Tasker.SendEventLog(URI_USER_ACTION, MODE_VULNER_END, 'Sleep mode');
|
||
pData.Tasker.AgentMode := hmkSleep;
|
||
end;
|
||
end;
|
||
|
||
pNode := vtList.GetNextSelected(pNode);
|
||
end;
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.miVulModeClick(Sender: TObject);
|
||
var
|
||
pNode: PVirtualNode;
|
||
pData: PAgentEnt;
|
||
begin
|
||
if vtList.SelectedCount = 0 then
|
||
exit;
|
||
|
||
vtList.BeginUpdate;
|
||
try
|
||
pNode := vtList.GetFirstSelected;
|
||
while pNode <> nil do
|
||
begin
|
||
pData := vtList.GetNodeData(pNode);
|
||
if pData.Tasker.AgentMode <> hmkVulnerability then
|
||
begin
|
||
pData.Tasker.SendEventLog(URI_USER_ACTION, MODE_VULNER_START, 'Vulnerable mode');
|
||
pData.Tasker.AgentMode := hmkVulnerability;
|
||
end;
|
||
pNode := vtList.GetNextSelected(pNode);
|
||
end;
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.process_WM_SYSCOMMAND(var msg: TWMSysCommand);
|
||
begin
|
||
if msg.CmdType = SC_CLOSE then
|
||
begin
|
||
miExit.Click;
|
||
exit;
|
||
end;
|
||
Inherited;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.tInitTimer(Sender: TObject);
|
||
begin
|
||
tInit.Enabled := false;
|
||
if gSet.SvrAddr = '' then
|
||
miConnSetting.Click;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.tProgTimer(Sender: TObject);
|
||
begin
|
||
lbTime.Caption := ConvSecBetweenToProgTime(dtStart_, Now);
|
||
Application.ProcessMessages;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.vtListCompareNodes(Sender: TBaseVirtualTree; Node1,
|
||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||
var
|
||
pData1, pData2: PAgentEnt;
|
||
begin
|
||
pData1 := Sender.GetNodeData(Node1);
|
||
pData2 := Sender.GetNodeData(Node2);
|
||
|
||
case Column of
|
||
1 : Result := Integer(pData1.Tasker.AgentState) - Integer(pData2.Tasker.AgentState);
|
||
2 : Result := Integer(pData1.Tasker.AgentMode) - Integer(pData2.Tasker.AgentMode);
|
||
3,
|
||
4 : Result := CompareText(vtList.Text[Node1, Column], vtList.Text[Node2, Column]);
|
||
5 : Result := CompareDateTime(pData1.Tasker.LastRcvPolDT, pData2.Tasker.LastRcvPolDT);
|
||
6 : Result := CompareDateTime(pData1.Tasker.LastPolModDT, pData2.Tasker.LastPolModDT);
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.vtListFreeNode(Sender: TBaseVirtualTree;
|
||
Node: PVirtualNode);
|
||
var
|
||
pData: PAgentEnt;
|
||
begin
|
||
pData := Sender.GetNodeData(Node);
|
||
if pData.Tasker <> nil then
|
||
// pData.Tasker.Terminate;
|
||
FreeAndNil(pData.Tasker);
|
||
Finalize(pData^);
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.vtListGetHint(Sender: TBaseVirtualTree;
|
||
Node: PVirtualNode; Column: TColumnIndex;
|
||
var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string);
|
||
begin
|
||
HintText := vtList.Text[Node, Column];
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.vtListGetNodeDataSize(Sender: TBaseVirtualTree;
|
||
var NodeDataSize: Integer);
|
||
begin
|
||
NodeDataSize := SizeOf(TAgentEnt);
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.vtListGetText(Sender: TBaseVirtualTree;
|
||
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||
var CellText: string);
|
||
var
|
||
pData: PAgentEnt;
|
||
begin
|
||
pData := Sender.GetNodeData(Node);
|
||
|
||
case Column of
|
||
0 : CellText := IntToStr(Node.Index + 1);
|
||
1 :
|
||
begin
|
||
case pData.Tasker.AgentState of
|
||
asInit : CellText := '<27>غ<EFBFBD><D8BA><EFBFBD>..';
|
||
asConnected : CellText := 'Manage Mode';
|
||
asDisconnected : CellText := 'Standalone Mode';
|
||
end;
|
||
end;
|
||
2 :
|
||
begin
|
||
case pData.Tasker.AgentMode of
|
||
hmkSleep : CellText := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
hmkSecurity : CellText := '<27><><EFBFBD>ȸ<EFBFBD><C8B8><EFBFBD>';
|
||
hmkVulnerability : CellText := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
end;
|
||
end;
|
||
3 : CellText := pData.Tasker.EmpNo;
|
||
4 : CellText := pData.Tasker.PolicyGroup;
|
||
5 :
|
||
begin
|
||
if pData.Tasker.LastRcvPolDT <> 0 then
|
||
CellText := DateTimeToStr(pData.Tasker.LastRcvPolDT);
|
||
end;
|
||
6 :
|
||
begin
|
||
if pData.Tasker.LastPolModDT <> 0 then
|
||
CellText := DateTimeToStr(pData.Tasker.LastPolModDT);
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.vtListHeaderClick(Sender: TVTHeader;
|
||
HitInfo: TVTHeaderHitInfo);
|
||
begin
|
||
if HitInfo.Button = mbLeft then
|
||
begin
|
||
if HitInfo.Column < 0 then
|
||
exit;
|
||
|
||
with Sender, Treeview do
|
||
begin
|
||
if SortColumn > NoColumn then
|
||
Columns[SortColumn].Options := Columns[SortColumn].Options + [coParentColor];
|
||
|
||
if HitInfo.Column = 0 then
|
||
SortColumn := NoColumn
|
||
else
|
||
begin
|
||
if (SortColumn = NoColumn) or (SortColumn <> HitInfo.Column) then
|
||
begin
|
||
SortColumn := HitInfo.Column;
|
||
SortDirection := sdAscending;
|
||
end else
|
||
if SortDirection = sdAscending then
|
||
SortDirection := sdDescending
|
||
else
|
||
SortDirection := sdAscending;
|
||
|
||
Columns[SortColumn].Color := $00EFEFEF;
|
||
|
||
vtList.BeginUpdate;
|
||
try
|
||
vtList.SortTree(SortColumn, SortDirection, False);
|
||
finally
|
||
vtList.EndUpdate;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.vtListPaintText(Sender: TBaseVirtualTree;
|
||
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
||
TextType: TVSTTextType);
|
||
var
|
||
pData: PAgentEnt;
|
||
begin
|
||
if not (vsSelected in Node.States) then
|
||
begin
|
||
pData := Sender.GetNodeData(Node);
|
||
case Column of
|
||
1 :
|
||
begin
|
||
case pData.Tasker.AgentState of
|
||
asInit : ;
|
||
asConnected : TargetCanvas.Font.Color := clBlue;
|
||
asDisconnected : TargetCanvas.Font.Color := clGreen;
|
||
end;
|
||
end;
|
||
|
||
2 :
|
||
begin
|
||
case pData.Tasker.AgentMode of
|
||
hmkSecurity : TargetCanvas.Font.Color := clBlue;
|
||
hmkVulnerability : TargetCanvas.Font.Color := clRed;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TDlgBs1AgentsMain.process_WM_UPDATE_AGENT(var msg: TMessage);
|
||
begin
|
||
try
|
||
vtList.RepaintNode(PVirtualNode(msg.LParam));
|
||
except
|
||
// ..
|
||
end;
|
||
end;
|
||
|
||
end.
|