| 18 |
|
procedure UpdateListCache; |
| 19 |
|
|
| 20 |
|
function GetLinksToFile(FileID: Integer): TLinks; |
| 21 |
– |
function GetLinksFromFile(FileID: Integer): TLinks; |
| 21 |
|
|
| 22 |
|
function GetFileInfo(FileID: Integer): TFileInfo; override; |
| 23 |
|
function GetFilesList(Ext: String; Pattern: String; |
| 46 |
|
implementation |
| 47 |
|
|
| 48 |
|
uses |
| 49 |
< |
SysUtils, Data, Functions, ABSDecUtil, DB, DatLinks; |
| 49 |
> |
SysUtils, Data, Functions, ABSDecUtil, DB, DatLinks, StrUtils; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
(* |
| 66 |
|
FFileName := DBFilename; |
| 67 |
|
|
| 68 |
|
FDatabase := TABSDatabase.Create(nil); |
| 69 |
+ |
FDatabase.Exclusive := True; |
| 70 |
+ |
FDatabase.MultiUser := False; |
| 71 |
|
FDatabase.DatabaseName := 'OLDBcon' + IntToStr(ConnectionID); |
| 72 |
|
FDatabase.DatabaseFileName := DBFilename; |
| 73 |
|
FDatabase.Open; |
| 74 |
|
FQuery := TABSQuery.Create(FDatabase); |
| 75 |
+ |
FQuery.DisableControls; |
| 76 |
+ |
FQuery.RequestLive := False; |
| 77 |
|
FQuery.DatabaseName := 'OLDBcon' + IntToStr(ConnectionID); |
| 78 |
|
FQuery.SQL.Text := 'SELECT [name],[value] FROM globals ORDER BY [name] ASC'; |
| 79 |
|
FQuery.Open; |
| 196 |
|
FQuery.Close; |
| 197 |
|
end; |
| 198 |
|
|
| 196 |
– |
function TAccess_OUP_ADB.GetLinksFromFile(FileID: Integer): TLinks; |
| 197 |
– |
var |
| 198 |
– |
i: Integer; |
| 199 |
– |
begin |
| 200 |
– |
SetLength(Result.ByName, 0); |
| 201 |
– |
FQuery.SQL.Text := 'SELECT src_link_offset, target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' ORDER BY target_id ASC;'; |
| 202 |
– |
FQuery.Open; |
| 203 |
– |
SetLength(Result.ByID, FQuery.RecordCount); |
| 204 |
– |
if FQuery.RecordCount > 0 then |
| 205 |
– |
begin |
| 206 |
– |
i := 0; |
| 207 |
– |
repeat |
| 208 |
– |
Result.ByID[i].SrcOffset := FQuery.FieldByName('src_link_offset').AsInteger; |
| 209 |
– |
Result.ByID[i].Destination := FQuery.FieldByName('target_id').AsInteger; |
| 210 |
– |
Inc(i); |
| 211 |
– |
FQuery.Next; |
| 212 |
– |
until FQuery.EOF; |
| 213 |
– |
end; |
| 214 |
– |
FQuery.Close; |
| 215 |
– |
end; |
| 216 |
– |
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
function TAccess_OUP_ADB.GetFileInfo(fileid: Integer): TFileInfo; |
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 234 |
– |
|
| 216 |
|
function TAccess_OUP_ADB.GetFilesList(ext: String; pattern: String; |
| 217 |
|
NoEmptyFiles: Boolean; SortType: TSortType): TStrings; |
| 218 |
|
var |
| 251 |
|
end; |
| 252 |
|
|
| 253 |
|
begin |
| 254 |
< |
list := TStringList.Create; |
| 274 |
< |
list.Sorted := True; |
| 275 |
< |
for i := 0 to GetFileCount - 1 do |
| 254 |
> |
if not (SortType in [ST_ExtNameAsc, ST_ExtNameDesc]) then |
| 255 |
|
begin |
| 256 |
< |
if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and |
| 257 |
< |
((Length(pattern) = 0) or |
| 258 |
< |
(Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then |
| 256 |
> |
list := TStringList.Create; |
| 257 |
> |
list.Sorted := True; |
| 258 |
> |
for i := 0 to GetFileCount - 1 do |
| 259 |
|
begin |
| 260 |
< |
if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then |
| 260 |
> |
if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and |
| 261 |
> |
((Length(pattern) = 0) or |
| 262 |
> |
(Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then |
| 263 |
|
begin |
| 264 |
< |
id := FormatNumber(Fdat_files[i].ID, 5, '0'); |
| 265 |
< |
name := Fdat_files[i].Name; |
| 266 |
< |
extension := Fdat_files[i].Extension; |
| 267 |
< |
|
| 268 |
< |
case SortType of |
| 269 |
< |
ST_IDAsc, ST_IDDesc: list.Add(id + ';' + name + ';' + extension); |
| 270 |
< |
ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension); |
| 271 |
< |
ST_ExtAsc, ST_ExtDesc: list.Add(extension + ';' + id + ';' + name); |
| 272 |
< |
ST_ExtNameAsc, ST_ExtNameDesc: list.Add(name + ';' + extension + ';' + id); |
| 264 |
> |
if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then |
| 265 |
> |
begin |
| 266 |
> |
id := FormatNumber(Fdat_files[i].ID, 5, '0'); |
| 267 |
> |
name := Fdat_files[i].Name; |
| 268 |
> |
extension := Fdat_files[i].Extension; |
| 269 |
> |
|
| 270 |
> |
case SortType of |
| 271 |
> |
ST_IDAsc, ST_IDDesc: list.Add(id + ';' + name + ';' + extension); |
| 272 |
> |
ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension); |
| 273 |
> |
ST_ExtAsc, ST_ExtDesc: list.Add(extension + ';' + id + ';' + name); |
| 274 |
> |
ST_ExtNameAsc, ST_ExtNameDesc: list.Add(extension + ';' + name + ';' + id); |
| 275 |
> |
end; |
| 276 |
|
end; |
| 277 |
|
end; |
| 278 |
|
end; |
| 279 |
< |
end; |
| 280 |
< |
if not Assigned(Result) then |
| 281 |
< |
Result := TStringList.Create; |
| 282 |
< |
if list.Count > 0 then |
| 279 |
> |
if not Assigned(Result) then |
| 280 |
> |
Result := TStringList.Create; |
| 281 |
> |
if list.Count > 0 then |
| 282 |
> |
begin |
| 283 |
> |
fields := TStringList.Create; |
| 284 |
> |
if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then |
| 285 |
> |
for i := 0 to list.Count - 1 do |
| 286 |
> |
begin |
| 287 |
> |
getfields; |
| 288 |
> |
Result.Add(id + '-' + name + '.' + extension); |
| 289 |
> |
end |
| 290 |
> |
else |
| 291 |
> |
for i := list.Count - 1 downto 0 do |
| 292 |
> |
begin |
| 293 |
> |
getfields; |
| 294 |
> |
Result.Add(id + '-' + name + '.' + extension); |
| 295 |
> |
end; |
| 296 |
> |
fields.Free; |
| 297 |
> |
end; |
| 298 |
> |
list.Free; |
| 299 |
> |
end |
| 300 |
> |
else |
| 301 |
|
begin |
| 302 |
< |
fields := TStringList.Create; |
| 303 |
< |
if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then |
| 304 |
< |
for i := 0 to list.Count - 1 do |
| 305 |
< |
begin |
| 306 |
< |
getfields; |
| 307 |
< |
Result.Add(id + '-' + name + '.' + extension); |
| 308 |
< |
end |
| 309 |
< |
else |
| 310 |
< |
for i := list.Count - 1 downto 0 do |
| 311 |
< |
begin |
| 312 |
< |
getfields; |
| 313 |
< |
Result.Add(id + '-' + name + '.' + extension); |
| 314 |
< |
end; |
| 315 |
< |
fields.Free; |
| 302 |
> |
FQuery.SQL.Text := 'SELECT id, name, extension FROM datfiles ' + |
| 303 |
> |
'WHERE Length(name) > 0 ORDER BY extension ASC, name ASC;'; |
| 304 |
> |
FQuery.Open; |
| 305 |
> |
if not Assigned(Result) then |
| 306 |
> |
Result := TStringList.Create; |
| 307 |
> |
if FQuery.RecordCount > 0 then |
| 308 |
> |
begin |
| 309 |
> |
FQuery.First; |
| 310 |
> |
repeat |
| 311 |
> |
name := FormatNumber(FQuery.FieldByName('id').AsInteger, 5, '0') + |
| 312 |
> |
'-' + FQuery.FieldByName('name').AsString + '.' + |
| 313 |
> |
FQuery.FieldByName('extension').AsString; |
| 314 |
> |
if SortType = ST_ExtNameAsc then |
| 315 |
> |
Result.Add(name) |
| 316 |
> |
else |
| 317 |
> |
Result.Insert(0, name); |
| 318 |
> |
FQuery.Next; |
| 319 |
> |
until FQuery.EOF; |
| 320 |
> |
end; |
| 321 |
> |
FQuery.Close; |
| 322 |
|
end; |
| 315 |
– |
list.Free; |
| 323 |
|
end; |
| 324 |
|
|
| 325 |
|
|