Q
qinmingzsj
Unregistered / Unconfirmed
GUEST, unregistred user!
[blue]使用SimpleObjectBroker实现容错却出现如下问题:
我有两个APPSERVER,当客户端程序在使用的过程中,我停止了客户端连接的APPSERVER,为了保证客户端程序可以不中断的使用,因此使用下面的程序去连接另外一个APPSERVER
第一段代码的Tclientdataset.Open 没有作用,但是使用第2段代码却又可以,哪位高手可以告诉我原因及更好的解决办法吗:
第一段代码:
procedure TForm1.Button1Click(Sender: TObject);
begin
with ClientDataSet1do
begin
try
close;
Params.ParamByName('CKEY_NO').Value := '0000156000';
open;
except
if Set_SocketCN(SocketConnection1) then
Button1Click(self);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with ClientDataSet1do
begin
try
close;
Params.ParamByName('CKEY_NO').Value := '0000236000';
open;
except
if Set_SocketCN(SocketConnection1) then
begin
EmptyDataSet;
FetchParams;
Params.ParamByName('CKEY_NO').Value := '';
open;
Button1Click(self);
end;
end;
end;
end;
Function Set_SocketCN( Socket: Array Of TSocketConnection): boolean;
Var
Icount: integer;
VHost: String;
begin
If length(Socket) <= 0 then
exit;
Try
For Icount := low(Socket) To high(Socket)do
begin
Socket[Icount].Connected := false;
Socket[Icount].Connected := true;
end;
Except
Try
For Icount := low(Socket) To high(Socket)do
begin
Socket[Icount].Connected := false;
Socket[Icount].ObjectBroker.SetConnectStatus(Socket[Icount].Host, False);
end;
Finally
Try
For Icount := low(Socket) To high(Socket)do
begin
VHost := Socket[Icount].ObjectBroker.GetComputerForProgID
('Project1.Test_Server');
Socket[Icount].Host := VHost;
Socket[Icount].Connected := True;
end;
Except
On EBrokerExceptiondo
begin
Showmessage('沒有服務器可以使用,請稍后再使用系統');
end;
end;
end;
end;
end;
[/blue]
我有两个APPSERVER,当客户端程序在使用的过程中,我停止了客户端连接的APPSERVER,为了保证客户端程序可以不中断的使用,因此使用下面的程序去连接另外一个APPSERVER
第一段代码的Tclientdataset.Open 没有作用,但是使用第2段代码却又可以,哪位高手可以告诉我原因及更好的解决办法吗:
第一段代码:
procedure TForm1.Button1Click(Sender: TObject);
begin
with ClientDataSet1do
begin
try
close;
Params.ParamByName('CKEY_NO').Value := '0000156000';
open;
except
if Set_SocketCN(SocketConnection1) then
Button1Click(self);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with ClientDataSet1do
begin
try
close;
Params.ParamByName('CKEY_NO').Value := '0000236000';
open;
except
if Set_SocketCN(SocketConnection1) then
begin
EmptyDataSet;
FetchParams;
Params.ParamByName('CKEY_NO').Value := '';
open;
Button1Click(self);
end;
end;
end;
end;
Function Set_SocketCN( Socket: Array Of TSocketConnection): boolean;
Var
Icount: integer;
VHost: String;
begin
If length(Socket) <= 0 then
exit;
Try
For Icount := low(Socket) To high(Socket)do
begin
Socket[Icount].Connected := false;
Socket[Icount].Connected := true;
end;
Except
Try
For Icount := low(Socket) To high(Socket)do
begin
Socket[Icount].Connected := false;
Socket[Icount].ObjectBroker.SetConnectStatus(Socket[Icount].Host, False);
end;
Finally
Try
For Icount := low(Socket) To high(Socket)do
begin
VHost := Socket[Icount].ObjectBroker.GetComputerForProgID
('Project1.Test_Server');
Socket[Icount].Host := VHost;
Socket[Icount].Connected := True;
end;
Except
On EBrokerExceptiondo
begin
Showmessage('沒有服務器可以使用,請稍后再使用系統');
end;
end;
end;
end;
end;
[/blue]