procedure TfmMain.SbtnSet1Click(Sender: TObject);
var
dwPort : Integer;
dwValue : Integer;
dwLocalPort : Integer;
Buffer : PChar;
BufLen : DWORD;
HostName : string;
strFileName : string;
FileName, strFilePath : string;
IniFile: TIniFile;
begin
lvGroups.Items.Clear;
mmoUnAssigned.Clear;
mmoWirelessStatus.Clear;
mmoBlacklistInfo.Clear;
mmoAgentStateChanged.Clear;
dwPort := 0;
dwLocalPort := 0;
BufLen := 255;
GetMem(Buffer, BufLen);
GetComputerName(Buffer, BufLen);
HostName := string(Buffer);
if edtAddr.Text = '' then
begin
MessageDlg('请输入CDMS服务器地址!',mtWarning,[mbOk],0);
edtAddr.SetFocus;
Exit;
end;
if edtPort.Text <> '' then
begin
if IsDigit(edtPort.Text) then
begin
dwPort := Str2DWord(edtPort.Text);
if (dwPort = 0) then
begin
MessageDlg('CDMS服务器端口不能为0,请重新输入!',mtWarning,[mbOk],0);
edtPort.SetFocus;
Exit;
end;
end
else
begin
ShowMessage('CDMS服务器端口值只能是数字,请重新输入!');
edtPort.SetFocus;
Exit;
end;
end
else
begin
Application.MessageBox('请输入CDMS服务器端口信息!', '错误', MB_OK);
edtPort.SetFocus;
Exit;
end;
if edtLocal.Text <> '' then
begin
if IsDigit(edtLocal.Text) then
begin
dwLocalPort := Str2DWord(edtLocal.Text);
if (dwLocalPort = 0) then
begin
MessageDlg('本地端口不能为0,请重新输入!',mtWarning,[mbOk],0);
edtLocal.SetFocus;
Exit;
end;
end
else
begin
ShowMessage('本地端口值只能是数字,请重新输入!');
edtLocal.SetFocus;
Exit;
end;
end
else
begin
Application.MessageBox('请输入本地端口信息!', '错误', MB_OK);
edtLocal.SetFocus;
Exit;
end;
if LowerCase(edtCdmsAddr.Text) = LowerCase(HostName) then
begin
if edtPort.Text = edtLocal.Text then
begin
MessageDlg('CDMS的端口号和本地端口号不能相同,请重新输入!',mtWarning,[mbOk],0);
edtLocal.SetFocus;
Exit;
end;
end;
if edtAgentId.Text <> '' then
begin
if IsDigit(edtAgentId.Text) then
begin
dwValue := Str2DWord(edtAgentId.Text);
if (dwvalue = 0) then
begin
MessageDlg('座席标识不能为0,请重新输入!',mtWarning,[mbOk],0);
edtAgentId.SetFocus;
Exit;
end;
end
else
begin
ShowMessage('座席标识只能是数字,请重新输入!');
edtAgentId.SetFocus;
Exit;
end;
end
else
begin
Application.MessageBox('请输入座席标识信息!', '错误', MB_OK);
edtAgentId.SetFocus;
Exit;
end;
if edtExtension.Text <> '' then
begin
if IsDigit(edtExtension.Text) then
begin
dwValue := Str2DWord(edtExtension.Text);
if (dwvalue = 0) then
begin
MessageDlg('座席话机号码不能为0,请重新输入!',mtWarning,[mbOk],0);
edtExtension.SetFocus;
Exit;
end;
end
else
begin
ShowMessage('座席话机号码只能是数字,请重新输入!');
edtExtension.SetFocus;
Exit;
end;
end
else
begin
Application.MessageBox('请输入座席话机号码信息!', '错误', MB_OK);
edtExtension.SetFocus;
Exit;
end;
if edtPassword.Text = '' then
begin
MessageDlg('请输入座席登录口令!',mtWarning,[mbOk],0);
edtPassword.SetFocus;
Exit;
end;
Inc(dwTestCount);
if bAgentLogon then
begin
if (dwTestCount mod 2) = 0 then
// SendAgentLogoffRequest();
Self.agntsftphn1.ServerName := '';
Self.agntsftphn1.ServerPort := 0;
Self.agntsftphn1.LocalPort := 0;
Sleep(1000);
bAgentLogon := FALSE;
end;
strAgentId := edtAgentId.Text;
strPassword := edtPassword.Text;
strExtension := edtExtension.Text;
Self.agntsftphn1.AgentID := edtAgentId.Text;
Self.agntsftphn1.AgentPassword := edtPassword.Text;
Self.agntsftphn1.Extension := edtExtension.Text;;
Self.agntsftphn1.ServerName := edtAddr.Text;
Self.agntsftphn1.ServerPort := dwPort;
Self.agntsftphn1.LocalPort := dwLocalPort;
sbtnRequest.Enabled := TRUE;
FileName := ExtractFilePath(Application.ExeName) + 'IniFile\CdmsInfoCfg.ini';
try
IniFile := TIniFile.Create(FileName);
IniFile.WriteString('AgentParam', 'ServerAddr', edtAddr.Text);
IniFile.WriteString('AgentParam', 'ServerPort', edtPort.Text);
IniFile.WriteString('AgentParam', 'LocalPort', edtLocalPort.Text);
IniFile.WriteString('AgentParam', 'AgentID', edtAgentId.Text);
IniFile.WriteString('AgentParam', 'AgentStaNum', edtExtension.Text);
IniFile.WriteString('AgentParam', 'AgentPW', edtPassword.Text);
finally
IniFile.Free;
end;
sbStatus.Panels.Items[1].Text := '座席标识:' + strAgentId;
sbStatus.Panels.Items[3].Text := '分机号码:' + strExtension;
sbStatus.Panels.Items[4].Text := '分机状态:' + '未知';
end;