186 lines
4.7 KiB
Plaintext
186 lines
4.7 KiB
Plaintext
unit DConnSetting;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
|
|
Vcl.StdCtrls, Vcl.Buttons, IdHTTP, IdSSLOpenSSL;
|
|
|
|
type
|
|
TDlgConnSetting = class(TForm)
|
|
Label1: TLabel;
|
|
edSvrAddr: TEdit;
|
|
Label2: TLabel;
|
|
Label3: TLabel;
|
|
edConnCnt: TEdit;
|
|
btnOk: TButton;
|
|
btnCancel: TButton;
|
|
btnTest: TSpeedButton;
|
|
Label4: TLabel;
|
|
Label5: TLabel;
|
|
edConnTO: TEdit;
|
|
edReadTO: TEdit;
|
|
Label6: TLabel;
|
|
Label7: TLabel;
|
|
Label8: TLabel;
|
|
edEmpNoHead: TEdit;
|
|
Label9: TLabel;
|
|
Label10: TLabel;
|
|
procedure btnOkClick(Sender: TObject);
|
|
procedure btnTestClick(Sender: TObject);
|
|
procedure Label2DblClick(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
HTTP_: TIdHTTP;
|
|
SSL_: TIdSSLIOHandlerSocketOpenSSL;
|
|
function TestConnect(sSvrAddr: String): Boolean;
|
|
public
|
|
{ Public declarations }
|
|
Constructor Create(aOwner: TComponent); override;
|
|
Destructor Destroy; override;
|
|
end;
|
|
|
|
var
|
|
DlgConnSetting: TDlgConnSetting;
|
|
|
|
implementation
|
|
|
|
uses
|
|
ManagerSetting, HttpUtil;
|
|
|
|
{$R *.dfm}
|
|
|
|
// for 2.6 : (¿¹ : https://192.168.14.133:8443/agentLogRequests.do)
|
|
// for 2.7-8 : (¿¹ : https://192.168.15.171:8443)
|
|
|
|
Constructor TDlgConnSetting.Create(aOwner: TComponent);
|
|
begin
|
|
Inherited Create(aOwner);
|
|
edSvrAddr.Text := gSet.SvrAddr;
|
|
edEmpNoHead.Text := gSet.EmpNoHead;
|
|
edConnCnt.Text := IntToStr(gSet.ConnAgents);
|
|
edConnTO.Text := IntToStr(gSet.ConnectTimeout);
|
|
edReadTO.Text := IntToStr(gSet.ReadTimeout);
|
|
HTTP_ := nil;
|
|
SSL_ := nil;
|
|
ASSERT(CreateHttpSSL(HTTP_, SSL_));
|
|
end;
|
|
|
|
Destructor TDlgConnSetting.Destroy;
|
|
begin
|
|
FreeAndNil(HTTP_);
|
|
FreeAndNil(SSL_);
|
|
Inherited;
|
|
end;
|
|
|
|
procedure TDlgConnSetting.Label2DblClick(Sender: TObject);
|
|
begin
|
|
edSvrAddr.Text := 'https://192.168.15.171:8443';
|
|
end;
|
|
|
|
procedure TDlgConnSetting.btnTestClick(Sender: TObject);
|
|
begin
|
|
edSvrAddr.Text := Trim(edSvrAddr.Text);
|
|
if edSvrAddr.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('¼¹ö Á¢¼Ó Á¤º¸¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.'),
|
|
PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edSvrAddr.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if TestConnect(edSvrAddr.Text) then
|
|
MessageBox(Handle, PChar('Á¢¼ÓÀÌ °¡´ÉÇÕ´Ï´Ù.'), PChar(Caption), MB_ICONINFORMATION or MB_OK)
|
|
else
|
|
MessageBox(Handle, PChar('Á¢¼ÓÇÒ ¼ö ¾ø½À´Ï´Ù.'+#13+#10+'Á¢¼Ó Á¤º¸¸¦ È®ÀÎ ÈÄ ´Ù½Ã ½ÃµµÇØ ÁֽʽÿÀ.'),
|
|
PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
end;
|
|
|
|
function TDlgConnSetting.TestConnect(sSvrAddr: String): Boolean;
|
|
const
|
|
JSON_CONNCHECK = '{"Request : ConnectionCheck"}';
|
|
var
|
|
nReadTO,
|
|
nConnTO: Integer;
|
|
begin
|
|
Result := false;
|
|
try
|
|
if (Length(sSvrAddr) > 0) and (sSvrAddr[Length(sSvrAddr)] <> '/') then
|
|
sSvrAddr := sSvrAddr + '/agentEmpInfo.do';
|
|
|
|
nConnTO := HTTP_.ConnectTimeout;
|
|
nReadTO := HTTP_.ReadTimeout;
|
|
HTTP_.ConnectTimeout := 3000;
|
|
HTTP_.ReadTimeout := 3000;
|
|
try
|
|
// Result := HttpPost(HTTP_, sSvrAddr, '123000', JSON_CONNCHECK) <> '';
|
|
|
|
Result := HttpPost(HTTP_, sSvrAddr, '97', '') <> '';
|
|
finally
|
|
HTTP_.ReadTimeout := nReadTO;
|
|
HTTP_.ConnectTimeout := nConnTO;
|
|
end;
|
|
except
|
|
// ..
|
|
end;
|
|
end;
|
|
|
|
procedure TDlgConnSetting.btnOkClick(Sender: TObject);
|
|
var
|
|
nCnt: Integer;
|
|
begin
|
|
edSvrAddr.Text := Trim(edSvrAddr.Text);
|
|
edEmpNoHead.Text := Trim(edEmpNoHead.Text);
|
|
edConnCnt.Text := Trim(edConnCnt.Text);
|
|
edConnTO.Text := Trim(edConnTO.Text);
|
|
edReadTO.Text := Trim(edReadTO.Text);
|
|
|
|
if edSvrAddr.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('¼¹ö Á¢¼Ó Á¤º¸¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.'),
|
|
PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edSvrAddr.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
nCnt := StrToIntDef(edConnCnt.Text, 0);
|
|
if (nCnt < 0) or (nCnt > 1000) then
|
|
begin
|
|
MessageBox(Handle, PChar('0ÀÌ»ó 1000ÀÌÇÏÀÇ ¼ýÀÚ¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edConnCnt.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if edEmpNoHead.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('»ç¹ø Á¢µÎ¾î¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edEmpNoHead.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if StrToIntDef(edConnTO.Text, 0) <= 0 then
|
|
begin
|
|
MessageBox(Handle, PChar('ConnectTimeoutÀ» ÀÔ·ÂÇØ ÁֽʽÿÀ.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edConnCnt.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if StrToIntDef(edReadTO.Text, 0) <= 0 then
|
|
begin
|
|
MessageBox(Handle, PChar('ReadTimeoutÀ» ÀÔ·ÂÇØ ÁֽʽÿÀ.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edReadTO.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if not TestConnect(edSvrAddr.Text) then
|
|
begin
|
|
if MessageBox(Handle, PChar('ÀÔ·ÂµÈ "¼¹ö Á¢¼Ó Á¤º¸"·Î ¿¬°áÀÌ µÇÁö ¾Ê°í ÀÖ½À´Ï´Ù.'+
|
|
#13+#10+'°è¼ÓÇϽðڽÀ´Ï±î?'), PChar(Caption), MB_ICONWARNING or MB_YESNO) = IDNO then exit;
|
|
end;
|
|
|
|
ModalResult := mrOk;
|
|
end;
|
|
|
|
end.
|