BSOne.SFC/eCrmHE/Utils/EXE_BS1DecLog/DDecLogMain.pas

153 lines
3.6 KiB
Plaintext

unit DDecLogMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons,
Tocsg.Controls;
type
TDlgDecLogMain = class(TForm)
Label1: TLabel;
Label2: TLabel;
edSrc: TEdit;
edDest: TEdit;
btnOpen: TSpeedButton;
chAfterOpen: TCheckBox;
btnDec: TButton;
OpenDialog: TOpenDialog;
procedure btnOpenClick(Sender: TObject);
procedure btnDecClick(Sender: TObject);
private
{ Private declarations }
MgCtrls_: TManagerInputControlsData;
public
{ Public declarations }
Constructor Create(aOwner: TComponent); override;
Destructor Destroy; override;
end;
var
DlgDecLogMain: TDlgDecLogMain;
implementation
uses
Tocsg.Path, Tocsg.Safe, Tocsg.Trace, Tocsg.Shell;
{$R *.dfm}
Constructor TDlgDecLogMain.Create(aOwner: TComponent);
begin
Inherited Create(aOwner);
MgCtrls_ := TManagerInputControlsData.Create(CutFileExt(GetRunExePath) + '.ini');
MgCtrls_.RegInputCtrl(edSrc);
MgCtrls_.RegInputCtrl(edDest);
MgCtrls_.RegInputCtrl(chAfterOpen);
MgCtrls_.Load;
end;
Destructor TDlgDecLogMain.Destroy;
begin
FreeAndNil(MgCtrls_);
Inherited;
end;
procedure TDlgDecLogMain.btnOpenClick(Sender: TObject);
begin
if OpenDialog.Execute(Handle) then
edSrc.Text := OpenDialog.FileName;
end;
procedure TDlgDecLogMain.btnDecClick(Sender: TObject);
var
SrcList,
DestList: TStringList;
i: Integer;
sLine, sTemp: String;
begin
edSrc.Text := Trim(edSrc.Text);
edDest.Text := Trim(edDest.Text);
if edSrc.Text = '' then
begin
MessageBox(Handle, PChar('"대상 파일 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
edSrc.SetFocus;
exit;
end;
if edDest.Text = '' then
begin
MessageBox(Handle, PChar('"복호화 후 저장 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
edDest.SetFocus;
exit;
end;
if not FileExists(edSrc.Text) then
begin
MessageBox(Handle, PChar('"대상 파일 경로"가 존재하지 않습니다.'), PChar(Caption), MB_ICONWARNING or MB_OK);
edSrc.SetFocus;
exit;
end;
if not DirectoryExists(ExtractFilePath(edDest.Text)) then
begin
MessageBox(Handle, PChar('"복호화 후 저장 경로"의 폴더가 존재하지 않습니다.'), PChar(''), MB_ICONWARNING or MB_OK);
edDest.SetFocus;
exit;
end;
MgCtrls_.Save;
if GetFileExt(edDest.Text).ToUpper <> 'LOG' then
edDest.Text := edDest.Text + '.ini';
Guard(SrcList, TStringList.Create);
Guard(DestList, TStringList.Create);
try
SrcList.LoadFromFile(edSrc.Text, TEncoding.UTF8);
sLine := '';
for i := 0 to SrcList.Count - 1 do
begin
if SrcList[i] = '' then
continue;
sTemp := SrcList[i];
if sTemp.StartsWith('[2025-') or (sTemp[1] = ':') then
sLine := sTemp
else
sLine := sLine + sTemp;
if i <> (SrcList.Count - 1) then
begin
sTemp := SrcList[i + 1];
if not sTemp.StartsWith('[2025-') and (sTemp[1] <> ':') then
continue;
end;
if sLine <> '' then
begin
if sLine[1] = ':' then
DestList.Add(DecLog(sLine))
else
DestList.Add(sLine);
end;
end;
DestList.SaveToFile(edDest.Text, TEncoding.UTF8);
MessageBox(Handle, PChar('로그 복호화 완료'), PChar(Caption), MB_ICONINFORMATION or MB_OK);
if chAfterOpen.Checked then
ExecutePath(edDest.Text);
except
on E: Exception do
MessageBox(Handle, PChar(Format('복호화 중 오류가 발생했습니다. (%s)', [E.Message])),
PChar(Caption), MB_ICONWARNING or MB_OK);
end;
end;
end.