Componentes.Terceros.SDAC/internal/4.10.0.10/1/Demos/Win32/ThirdParty/IntraWeb/IW5/uData.pas
2007-10-05 14:48:18 +00:00

154 lines
4.0 KiB
ObjectPascal

unit uData;
interface
uses
SysUtils, Classes, DB, DBAccess, MSAccess, ActiveX, MemData;
type
TDM = class(TDataModule)
Connection: TMSConnection;
procedure ConnectionBeforeConnect(Sender: TObject);
procedure ConnectionAfterConnect(Sender: TObject);
procedure ConnectionAfterDisconnect(Sender: TObject);
procedure ConnectionConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
end;
implementation
{$R *.dfm}
uses IWInit, ServerController;
{ TDM }
procedure TDM.ConnectionBeforeConnect(Sender: TObject);
begin
Connection.Username := UserSession.Username;
Connection.Password := UserSession.Password;
Connection.Server := UserSession.Server;
Connection.Database := UserSession.Database;
Connection.Options.DisconnectedMode := UserSession.DisconnectedMode;
Connection.Pooling := UserSession.Pooling;
Connection.PoolingOptions := UserSession.PoolingOptions;
if UserSession.FailOver then
Connection.OnConnectionLost := ConnectionConnectionLost
else
Connection.OnConnectionLost := nil;
end;
procedure TDM.ConnectionAfterConnect(Sender: TObject);
begin
UserSession.IsGoodConnection := True;
UserSession.ConnectionResult := 'Connected';
end;
procedure TDM.ConnectionAfterDisconnect(Sender: TObject);
begin
if not (csDestroying in Connection.ComponentState) then
UserSession.ConnectionResult := '';
end;
procedure TDM.ConnectionConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
var
Msg: string;
begin
UserSession.IsGoodConnection := False;
case ConnLostCause of
clUnknown:
Msg := 'Unknown';
clConnect:
Msg := 'Connect';
clExecute:
Msg := 'Execute';
clOpen:
Msg := 'Open';
clApply:
Msg := 'Apply';
end;
UserSession.ConnectionResult := 'Connection lost: ' +
Component.Name + ' - ' + Msg;
end;
end.
interface
uses
SysUtils, Classes, DB, DBAccess, MSAccess, ActiveX;
type
TDM = class(TDataModule)
Connection: TMSConnection;
procedure ConnectionBeforeConnect(Sender: TObject);
procedure ConnectionAfterConnect(Sender: TObject);
procedure ConnectionAfterDisconnect(Sender: TObject);
procedure ConnectionConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
end;
implementation
{$R *.dfm}
uses IWInit, ServerController;
{ TDM }
procedure TDM.ConnectionBeforeConnect(Sender: TObject);
begin
Connection.Username := UserSession.Username;
Connection.Password := UserSession.Password;
Connection.Server := UserSession.Server;
Connection.Database := UserSession.Database;
Connection.Options.DisconnectedMode := UserSession.DisconnectedMode;
Connection.Pooling := UserSession.Pooling;
Connection.PoolingOptions := UserSession.PoolingOptions;
if UserSession.FailOver then
Connection.OnConnectionLost := ConnectionConnectionLost
else
Connection.OnConnectionLost := nil;
end;
procedure TDM.ConnectionAfterConnect(Sender: TObject);
begin
UserSession.IsGoodConnection := True;
UserSession.ConnectionResult := 'Connected';
end;
procedure TDM.ConnectionAfterDisconnect(Sender: TObject);
begin
if not (csDestroying in Connection.ComponentState) then
UserSession.ConnectionResult := '';
end;
procedure TDM.ConnectionConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
var
Msg: string;
begin
UserSession.IsGoodConnection := False;
case ConnLostCause of
clUnknown:
Msg := 'Unknown';
clConnect:
Msg := 'Connect';
clExecute:
Msg := 'Execute';
clOpen:
Msg := 'Open';
clApply:
Msg := 'Apply';
end;
UserSession.ConnectionResult := 'Connection lost: ' +
Component.Name + ' - ' + Msg;
end;
end.