ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/DataAccess/ConnectionManager.pas
(Generate patch)

Comparing oup/rewrite/DataAccess/ConnectionManager.pas (file contents):
Revision 93 by alloc, Thu Jan 18 17:15:59 2007 UTC vs.
Revision 101 by alloc, Tue Feb 20 20:43:29 2007 UTC

# Line 17 | Line 17 | type
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;
# Line 36 | Line 38 | type
38    end;
39  
40  
41 + var
42 +  ConManager: TConnectionManager;
43 +
44 +
45   implementation
46   uses
47    SysUtils, Dialogs;
# Line 50 | Line 56 | begin
56    Result := Length(FConnections);
57   end;
58  
59 + function TConnectionManager.GetConnectionIndex(ConnectionID: Integer): Integer;
60 + var
61 +  i: Integer;
62 + begin
63 +  Result := -1;
64 +  if Count > 0 then
65 +    for i := 0 to Count - 1 do
66 +      if ConnectionByIndex[i].ConnectionID = ConnectionID then
67 +      begin
68 +        Result := i;
69 +        Break;
70 +      end;
71 + end;
72 +
73   function TConnectionManager.GetConnection(ConnectionID: Integer): TDataAccess;
74   var
75    i: Integer;
# Line 129 | Line 149 | begin
149  
150    ext := UpperCase(ExtractFileExt(FileName));
151  
152 <  if ext = 'ODB' then
152 >  if ext = '.OLDB' then
153      backend := DB_ADB
154 <  else if ext = 'DAT' then
154 >  else if ext = '.DAT' then
155      backend := DB_ONI
156    else
157    begin
# Line 152 | Line 172 | begin
172    begin
173      FLastID := FConnections[i].ConnectionID;
174      Result := FLastID;
175 +    Msg := SM_OK;
176    end
177    else
178    begin
# Line 159 | Line 180 | begin
180      FConnections[i].Free;
181      FConnections[i] := nil;
182      SetLength(FConnections, Length(FConnections) - 1);
183 <    Msg := SM_UnknownError;
183 >    Msg := CreateMsg;
184    end;
185   end;
186  
# Line 239 | Line 260 | begin
260   end;
261  
262  
263 + initialization
264 +  ConManager := TConnectionManager.Create;
265 + finalization
266 +  ConManager.Free;
267   end.

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)