BSOne.SFC/eCrmHE/EXE_eCrmHomeEdition/Messages/DSchPiNoti.pas

451 lines
13 KiB
Plaintext

unit DSchPiNoti;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.pngimage, Vcl.ExtCtrls,
PngImageList, superobject, Vcl.StdCtrls, System.ImageList, Vcl.ImgList,
Vcl.Imaging.GIFImg, System.Win.TaskbarCore, Vcl.Taskbar;
//{$DEFINE _FILEENC_STOPABLE_}
type
TDlgSchPiNoti = class(TForm)
imgMain: TImage;
imgList: TPngImageCollection;
imgBtnOk: TImage;
imgBtnExit: TImage;
lbCnt: TLabel;
lbTop: TLabel;
lbBtn: TLabel;
lbBottom: TLabel;
imgEnc: TImage;
tProg: TTimer;
Taskbar: TTaskbar;
lbDetail: TLabel;
lbTitle: TLabel;
lbDetailMsg: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure imgMainMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure imgBtnOkMouseEnter(Sender: TObject);
procedure imgBtnOkMouseLeave(Sender: TObject);
procedure imgBtnOkMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure imgBtnExitMouseEnter(Sender: TObject);
procedure imgBtnExitMouseLeave(Sender: TObject);
procedure imgBtnExitClick(Sender: TObject);
procedure tProgTimer(Sender: TObject);
procedure lbBtnClick(Sender: TObject);
procedure lbDetailClick(Sender: TObject);
procedure lbDetailMouseEnter(Sender: TObject);
procedure lbDetailMouseLeave(Sender: TObject);
private
{ Private declarations }
llProcTgFileCnt_,
llTotalTgFileCnt_: LONGLONG;
clLabel_: TColor;
procedure SetImgBtn(aImg: TImage; nImgIdx: Integer);
public
{ Public declarations }
Constructor Create(aOwner: TComponent; sJsonData: String);
procedure CreateParams(var Params: TCreateParams); override;
procedure process_WM_SYSCOMMAND(var msg: TWMSysCommand); Message WM_SYSCOMMAND;
end;
var
DlgSchPiNoti: TDlgSchPiNoti;
implementation
uses
Tocsg.Safe, Tocsg.Strings, DeCrmHeMain, ManagerService, Condition,
GlobalDefine, Tocsg.Thread, Tocsg.Exception, Define;
resourcestring
RS_Caution = '위험';
RS_Warning = '경고';
RS_Attention = '주의';
RS_FileEnc = '파일 암호화';
RS_EncTasking = '암호화 수행 중';
RS_Stop = '중지';
RS_Close = '닫기';
RS_InfoProtec = '정보보호';
RS_FileEncComp = '파일 암호화 완료';
RS_Ok = '확인';
RS_FileEncStop = '파일 암호화 중지';
RS_Enc = '암호화';
RS_TargetCheck = '대상 파일 확인중...';
RS_SecuCenter = '보안지원센터';
RS_Q_EncStop = '파일 암호화를 중지 하시겠습니까?';
{$R *.dfm}
Constructor TDlgSchPiNoti.Create(aOwner: TComponent; sJsonData: String);
var
hTarkBar: HWND;
r: TRect;
O: ISuperObject;
begin
Inherited Create(aOwner);
SetImgBtn(imgBtnOk, 2);
SetImgBtn(imgBtnExit, 5);
clLabel_ := clGray;
try
O := SO(sJsonData);
if O <> nil then
begin
case O.I['T'] of
TYPE_MSG_CTTSCH_COMPLETE :
begin
lbDetail.Visible := true;
clLabel_ := $0014C2FB;
var nCnt: Integer := 0;
var StrList: TStringList;
Guard(StrList, TStringList.Create);
SplitString(O.S['D'], '|', StrList);
if StrList.Count > 1 then
nCnt := StrToIntDef(StrList[1], 0);
if gMgSvc.ProcCampn <> nil then
begin
if gMgSvc.ProcCampn.Info.nNotiCriIfCnt <= nCnt then
begin
SetImgBtn(imgMain, 1);
lbCnt.Caption := RS_Caution + ' (' + InsertPointComma(nCnt, 3) + ')';
clLabel_ := $00384EF8;
end else
if gMgSvc.ProcCampn.Info.nNotiWarIfCnt <= nCnt then
begin
SetImgBtn(imgMain, 0);
lbCnt.Caption := RS_Warning + ' (' + InsertPointComma(nCnt, 3) + ')';
clLabel_ := $002E8EFF;
end else
lbCnt.Caption := RS_Attention + ' (' + InsertPointComma(nCnt, 3) + ')';
end;
lbCnt.Font.Color := clLabel_;
lbDetail.Font.Color := clLabel_;
end;
TYPE_MSG_CAMPN_FILEENC :
begin
gMgSvc.DlgEncCampn := Self;
Caption := RS_FileEnc;
SetImgBtn(imgMain, 7);
lbTitle.Caption := RS_EncTasking;
lbTitle.Visible := true;
Taskbar.ProgressState := TTaskBarProgressState.Normal;
Taskbar.ProgressMaxValue := 100;
Taskbar.ProgressValue := 0;
{$IFDEF _FILEENC_STOPABLE_}
lbBtn.Caption := RS_Stop;
{$ELSE}
lbBtn.Caption := RS_Close; // 중지 기능 없앰 24_0104 15:48:57 kku
{$ENDIF}
lbCnt.Top := 301;
lbCnt.Caption := '...';
lbCnt.Font.Style := lbCnt.Font.Style - [fsBold];
lbCnt.Font.Color := clGray;
lbCnt.Font.Size := 13;
if imgEnc.Picture.Graphic is TGIFImage then
begin
TGIFImage(imgEnc.Picture.Graphic).Animate := true;
imgEnc.Top := 122;
imgEnc.Left := 95;
imgEnc.Visible := true;
imgEnc.BringToFront;
end;
// lbCnt.OnClick := nil;
// lbCnt.OnMouseDown := nil;
// lbCnt.OnMouseEnter := nil;
// lbCnt.OnMouseLeave := nil;
imgBtnOk.OnMouseDown := nil;
imgBtnOk.OnMouseEnter := nil;
imgBtnOk.OnMouseLeave := nil;
tProg.Enabled := true;
end;
end;
end;
except
end;
lbBottom.Caption := '';
case CUSTOMER_TYPE of
CUSTOMER_GEC : lbTop.Caption := RS_InfoProtec;
CUSTOMER_HDENG :
begin
lbTop.Caption := RS_InfoProtec;
lbBottom.Caption := RS_SecuCenter + ' 02-2134-1145';
end;
CUSTOMER_KISTEP : lbTop.Caption := APP_TITLE;
else lbTop.Caption := 'BSOne';
end;
var h: HWND := FindWindow('TDlgNoticeImg', nil);
if h <> 0 then
PostMessage(h, WM_CLOSE, 0, 0);
hTarkBar := FindWindow('Shell_TrayWnd', '');
if hTarkBar <> 0 then
begin
GetWindowRect(hTarkBar, r);
// Top가 0이면 위, 왼쪽 아님 오른쪽
if (r.Left <= 0) and (r.Right < Screen.PrimaryMonitor.Width) then
begin
// 왼쪽
Top := Screen.PrimaryMonitor.Height;
Left := Screen.PrimaryMonitor.Width;
end else
if (r.Left <= 0) and (r.Top = 0) and
(r.Bottom < Screen.PrimaryMonitor.Height) then
begin
// 위쪽
Top := Screen.PrimaryMonitor.Height;
Left := Screen.PrimaryMonitor.Width;
end else
if (r.Left <= 0) and (r.Top > 0) then
begin
// 아래쪽
Top := Screen.PrimaryMonitor.Height - (r.Bottom - r.Top);
Left := Screen.PrimaryMonitor.Width;// - Width;
end else begin
// 오른쪽
Top := Screen.PrimaryMonitor.Height;
Left := Screen.PrimaryMonitor.Width - (r.Right - r.Left);// - Width - (r.Right - r.Left);
end;
// nVCnt := Screen.PrimaryMonitor.Height div Height;
// nHPos := _nNotiCnt mod nVCnt;
// if nHPos = 0 then
// begin
// Left := Left - (_nNotiCnt div nVCnt) * Width;
// nHPos := nVCnt;
// end else
// Left := Left - ((_nNotiCnt div nVCnt) + 1) * Width;
// Top := Top - (nHPos * Height);
Top := Top - Height;
Left := Left - Width;
end;
end;
procedure TDlgSchPiNoti.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := WS_EX_APPWINDOW; // 작업표시줄에 표시
Params.WindowClass.Style := Params.WindowClass.Style or CS_DROPSHADOW;
Params.WndParent := GetDesktopWindow;
end;
procedure TDlgSchPiNoti.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if lbCnt.Top = 301 then
gMgSvc.DlgEncCampn := nil;
Action := caFree;
end;
procedure TDlgSchPiNoti.imgBtnExitClick(Sender: TObject);
begin
{$IFDEF _FILEENC_STOPABLE_}
if (lbCnt.Top = 301) and tProg.Enabled then
begin
WindowState := wsMinimized;
end else
{$ELSE}
if (lbCnt.Top = 301) and tProg.Enabled then
begin
WindowState := wsMinimized;
Hide;
end else
{$ENDIF}
Close;
end;
procedure TDlgSchPiNoti.imgBtnExitMouseEnter(Sender: TObject);
begin
SetImgBtn(imgBtnExit, 6);
end;
procedure TDlgSchPiNoti.imgBtnExitMouseLeave(Sender: TObject);
begin
SetImgBtn(imgBtnExit, 5);
end;
procedure TDlgSchPiNoti.imgBtnOkMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
SetImgBtn(imgBtnOk, 4);
end;
procedure TDlgSchPiNoti.imgBtnOkMouseEnter(Sender: TObject);
begin
SetImgBtn(imgBtnOk, 3);
end;
procedure TDlgSchPiNoti.imgBtnOkMouseLeave(Sender: TObject);
begin
SetImgBtn(imgBtnOk, 2);
end;
procedure TDlgSchPiNoti.imgMainMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
end;
procedure TDlgSchPiNoti.lbBtnClick(Sender: TObject);
begin
if tProg.Enabled then
begin
{$IFDEF _FILEENC_STOPABLE_}
if MessageBox(Handle, PChar(RS_Q_EncStop),
PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit;
tProg.Enabled := false;
var LogInfo: TLogInfo;
ZeroMemory(@LogInfo, SizeOf(LogInfo));
if gMgsvc.ProcCampn <> nil then
begin
LogInfo.sFileCompId := gMgsvc.ProcCampn.Info.sId;
LogInfo.sComment := gMgSvc.ThdScanSch.CttSchProg.sTaskId;
end;
LogInfo.sCode := SYSEVT_STOP_CAMPN_FILEENC;
LogInfo.sSummary := 'Stop Campaign - FileEnc ';
gMgSvc.SendEventLogEx(@LogInfo, false);
gMgSvc.StopCampaignTask;
{$ELSE}
// 최소화, 숨기지 않고 그냥 닫히도록 수정 24_0112 09:16:36 kku
// 다시 숨겨달라고 변경 24_0125 13:54:19 kku
WindowState := wsMinimized;
Hide;
exit;
// WindowState := wsMinimized;
// exit;
{$ENDIF}
end;
Close;
end;
procedure TDlgSchPiNoti.lbDetailClick(Sender: TObject);
begin
gMain.lbCttSchRstClick(nil);
end;
procedure TDlgSchPiNoti.lbDetailMouseEnter(Sender: TObject);
begin
lbDetail.Font.Style := lbDetail.Font.Style + [fsUnderline];
lbDetail.Font.Color := $00FE8645;
end;
procedure TDlgSchPiNoti.lbDetailMouseLeave(Sender: TObject);
begin
lbDetail.Font.Style := lbDetail.Font.Style - [fsUnderline];
lbDetail.Font.Color := clLabel_;
end;
procedure TDlgSchPiNoti.SetImgBtn(aImg: TImage; nImgIdx: Integer);
begin
aImg.Picture.Assign(imgList.Items[nImgIdx].PngImage);
aImg.Repaint;
end;
procedure TDlgSchPiNoti.tProgTimer(Sender: TObject);
var
sProcFile: String;
wPercent: WORD;
begin
try
if gMgSvc.IsSearchingPersonalInfo then
begin
case gMgSvc.ThdScanSch.WorkState of
tsWorking :
begin
sProcFile := gMgSvc.ThdScanSch.ProcSchFile;
if sProcFile <> '' then
begin
llProcTgFileCnt_ := gMgSvc.ThdScanSch.ProcTgFileCount;
llTotalTgFileCnt_ := gMgSvc.ThdScanSch.TotalTgFileCount;
if llTotalTgFileCnt_ > 0 then
wPercent := (llProcTgFileCnt_ * 100) div llTotalTgFileCnt_
else
wPercent := 0;
lbCnt.Caption := Format('%d%% %s : %s',
[wPercent, RS_Enc, InsertPointComma(gMgSvc.ThdScanSch.TotalEncCount, 3)]);
Caption := Format('%d%% - ', [wPercent]) + RS_FileEnc;
Taskbar.ProgressValue := wPercent;
end else begin
lbCnt.Caption := RS_TargetCheck;
// if lbCttSchSP.Visible then
// begin
// if lbCttSchSP.Caption = '?...' then
// lbCttSchSP.Caption := '.?..'
// else if lbCttSchSP.Caption = '.?..' then
// lbCttSchSP.Caption := '..?.'
// else if lbCttSchSP.Caption = '..?.' then
// lbCttSchSP.Caption := '...?'
// else
// lbCttSchSP.Caption := '?...';
// end;
end;
end;
tsStop,
tsCompleted,
tsFail :
begin
// ...
end;
end;
end else begin
tProg.Enabled := false;
imgEnc.Visible := false;
SetImgBtn(imgMain, 8);
if gMgSvc.IsStopCampn then
begin
lbTitle.Caption := RS_FileEncStop;
lbCnt.Caption := RS_Enc + Format(' : %s / %s',
[InsertPointComma(gMgSvc.CampnEnc, 3),
InsertPointComma(gMgSvc.CampnEnc + gMgSvc.CampnEncFail, 3)]);
end else begin
Caption := '100% - ' + RS_FileEnc;
lbCnt.Caption := Format('100%% %s : %s / %s',
[RS_Enc, InsertPointComma(gMgSvc.CampnEnc, 3),
InsertPointComma(gMgSvc.CampnEnc + gMgSvc.CampnEncFail, 3)]);
lbTitle.Caption := RS_FileEncComp;
end;
lbBtn.Caption := RS_Ok;
end;
except
on E: Exception do
ETgException.TraceException(Self, E, 'Fail .. tProgTimer()');
end;
Application.ProcessMessages;
end;
procedure TDlgSchPiNoti.process_WM_SYSCOMMAND(var msg: TWMSysCommand);
begin
if msg.CmdType = SC_CLOSE then
begin
imgBtnExitClick(nil);
// Hide;
// WindowState := wsMinimized;
exit;
end;
Inherited;
end;
end.