1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls ,Registry ,InvokeRegistry ,ShellApi ;
type
TForm2 = class(TForm)
ListBox2: TListBox;
ListBox1: TListBox;
Timer1: TTimer;
procedure ALLFILE(Chemin : string);
procedure Timer1Timer(Sender: TObject);
private
protected
FPATH : STRING;
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form2: TForm2;
cpt : integer ;
implementation
{$R *.dfm}
procedure TForm2.ALLFILE(Chemin : string);
Var Info : TSearchRec;
begin
If FindFirst(Chemin +'*.*',faAnyFile,Info)=0 Then
Begin
repeat
{ Les répertoires sont affichés dans ListBox1 }
{ Les fichiers sont affichés dans ListBox2 }
If ((Info.Attr And faDirectory)=0) Then
begin
ListBox2.Items.Add( 'insert into file_t (file_name, file_path, file_size, file_EXTE) values ('''+Info.Name+''','''+ chemin +''',''' +inttostr(Info.Size)+ ''',''0'' );');
if ListBox2.Items.Count mod 30 = 0 then ListBox2.Items.Add( 'commit;');
end
Else
begin
if ((Info.FindData.cFileName[0] <> '.') ) then ALLFILE(Chemin + Info.Name+'\') ;
end ;
{ Il faut ensuite rechercher l'entrée suivante }
Until FindNext(Info)<>0;
{ Dans le cas ou une entrée au moins est trouvée il faut }
{ appeler FindClose pour libérer les ressources de la recherche }
FindClose(Info);
End;
End ;
procedure TForm2.Timer1Timer(Sender: TObject);
var
i: integer ;
str : string ;
ch : pchar ;
begin
ListBox1.Items.Clear;
ListBox2.Items.Clear;
ListBox2.Items.Add('set feedback off');
ListBox2.Items.Add('set define off');
ListBox2.Items.Add('alter table FILE_T disable all triggers;');
ListBox2.Items.Add('prompt Loading the new file ...');
ListBox1.Items.LoadFromFile('C:\FLISTENER.INI');
IF (StrToInt(Trim(listbox1.Items[1])) > 1) and (StrToInt(Trim(listbox1.Items[1])) < 60) then
Timer1.Interval := StrToInt(Trim(listbox1.Items[1]))*60*1000
ELSE
Timer1.Interval := 3*60*1000 ;
For i:=5 to listbox1.Items.Count-1 do
begin
if Trim(listbox1.Items[i] )<> '' then
ALLFILE(listbox1.Items[i]);
end ;
ListBox2.Items.Add('commit ;');
ListBox2.Items.Add('EXEC NEWFILE;');
ListBox2.Items.Add('Alter table FILE_T enable all triggers;');
ListBox2.Items.Add('Exit');
ListBox2.Items.SaveToFile('C:\RESULT.SQL') ;
ch := PCHAR( Trim(listbox1.Items[3])+ ' @C:\RESULT.sql' ) ;
ShellExecute(0,nil ,'sqlplus', ch , nil,sw_hide);
end;
end. |
Partager