| 17 |
|
function GetConnectionCount: Integer; |
| 18 |
|
function GetConnection(ConnectionID: Integer): TDataAccess; |
| 19 |
|
function GetConnectionByIndex(Index: Integer): TDataAccess; |
| 20 |
+ |
function GetConnectionIndex(ConnectionID: Integer): Integer; |
| 21 |
|
procedure RemoveConnection(ArrayIndex: Integer); |
| 22 |
|
protected |
| 23 |
|
public |
| 24 |
|
property Count: Integer read GetConnectionCount; |
| 25 |
|
property Connection[ConnectionID: Integer]: TDataAccess read GetConnection; |
| 26 |
|
property ConnectionByIndex[Index: Integer]: TDataAccess read GetConnectionByIndex; |
| 27 |
+ |
property ConnectionIndexByID[ConnectionID: Integer]: Integer read GetConnectionIndex; |
| 28 |
|
property OnCoonnectionListChanged: TConnectionListChangedEvent read FConnectionListChanged write FConnectionListChanged; |
| 29 |
|
|
| 30 |
|
constructor Create; |
| 34 |
|
function CloseConnectionByIndex(Index: Integer; var Msg: TStatusMessages): Boolean; overload; |
| 35 |
|
function CloseConnection(ID: Integer; var Msg: TStatusMessages): Boolean; overload; |
| 36 |
|
function CloseConnection(FileName: String; var Msg: TStatusMessages): Boolean; overload; |
| 37 |
+ |
function FileOpened(FileName: String): Integer; |
| 38 |
|
published |
| 39 |
|
end; |
| 40 |
|
|
| 41 |
|
|
| 42 |
+ |
var |
| 43 |
+ |
ConManager: TConnectionManager; |
| 44 |
+ |
|
| 45 |
+ |
|
| 46 |
|
implementation |
| 47 |
|
uses |
| 48 |
|
SysUtils, Dialogs; |
| 57 |
|
Result := Length(FConnections); |
| 58 |
|
end; |
| 59 |
|
|
| 60 |
+ |
function TConnectionManager.GetConnectionIndex(ConnectionID: Integer): Integer; |
| 61 |
+ |
var |
| 62 |
+ |
i: Integer; |
| 63 |
+ |
begin |
| 64 |
+ |
Result := -1; |
| 65 |
+ |
if Count > 0 then |
| 66 |
+ |
for i := 0 to Count - 1 do |
| 67 |
+ |
if ConnectionByIndex[i].ConnectionID = ConnectionID then |
| 68 |
+ |
begin |
| 69 |
+ |
Result := i; |
| 70 |
+ |
Break; |
| 71 |
+ |
end; |
| 72 |
+ |
end; |
| 73 |
+ |
|
| 74 |
|
function TConnectionManager.GetConnection(ConnectionID: Integer): TDataAccess; |
| 75 |
|
var |
| 76 |
|
i: Integer; |
| 150 |
|
|
| 151 |
|
ext := UpperCase(ExtractFileExt(FileName)); |
| 152 |
|
|
| 153 |
< |
if ext = 'ODB' then |
| 153 |
> |
if ext = '.OLDB' then |
| 154 |
|
backend := DB_ADB |
| 155 |
< |
else if ext = 'DAT' then |
| 155 |
> |
else if ext = '.DAT' then |
| 156 |
|
backend := DB_ONI |
| 157 |
|
else |
| 158 |
|
begin |
| 173 |
|
begin |
| 174 |
|
FLastID := FConnections[i].ConnectionID; |
| 175 |
|
Result := FLastID; |
| 176 |
+ |
Msg := SM_OK; |
| 177 |
|
end |
| 178 |
|
else |
| 179 |
|
begin |
| 181 |
|
FConnections[i].Free; |
| 182 |
|
FConnections[i] := nil; |
| 183 |
|
SetLength(FConnections, Length(FConnections) - 1); |
| 184 |
< |
Msg := SM_UnknownError; |
| 184 |
> |
Msg := CreateMsg; |
| 185 |
|
end; |
| 186 |
|
end; |
| 187 |
|
|
| 261 |
|
end; |
| 262 |
|
|
| 263 |
|
|
| 264 |
+ |
function TConnectionManager.FileOpened(FileName: String): Integer; |
| 265 |
+ |
var |
| 266 |
+ |
i: Integer; |
| 267 |
+ |
begin |
| 268 |
+ |
Result := -1; |
| 269 |
+ |
if Length(FConnections) > 0 then |
| 270 |
+ |
for i := 0 to High(FConnections) do |
| 271 |
+ |
if FConnections[i].FileName = FileName then |
| 272 |
+ |
begin |
| 273 |
+ |
Result := FConnections[i].ConnectionID; |
| 274 |
+ |
Exit; |
| 275 |
+ |
end; |
| 276 |
+ |
end; |
| 277 |
+ |
|
| 278 |
+ |
|
| 279 |
+ |
initialization |
| 280 |
+ |
ConManager := TConnectionManager.Create; |
| 281 |
+ |
finalization |
| 282 |
+ |
ConManager.Free; |
| 283 |
|
end. |