unit Unit1;
procedure TForm1.ConnectToDB;
var
LDBPfad:
String ;
begin
LDBPfad := TMyDaten.GetMyPath;
FDBPfad := LDBPfad + '
MyDatenbank.accdb';
// D:\FastBackup\MyDatenbank.accdb
try
// adoConBackupper.Connected := true;
adoConBackupper.ConnectionString := TMyaccessDB.ConnectionToACCDB(FDBPfad);
//adoConBackupper.ConnectionString := 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=' + FDBPfad +';Persist Security Info=False';
lProcessStatus.Caption := '
Verbindung zur Datenbank wird aufgebaut...';
except
lProcessStatus.Caption := '
Fehler beim Verbinden...';
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
GlassFrame.Enabled:= true;
Height := 0;
left := Screen.Width - Width;
top := Screen.Height;
Timer2.enabled := true;
end;
procedure TForm1.StartingProcess;
var
LThread: MyThread;
lFileCountFrom, LRecordCount: Integer;
LSql,LDateNow,LBackupString:
String;
LStatus, LPfadFrom, LPfadTo :
String;
LAddDate, LReplaceDate,LReplaceFolder,LDateiCode, LAddBackupString: Boolean;
LReccord: Integer;
I,x: Integer;
begin
ConnectToDB;
QuerryBackupper.Close;
QuerryBackupper.SQL.Text := '
SELECT COUNT (*) FROM MyBackup WHERE deltag = ''
t''
and Status = ''
aktiv''
';
QuerryBackupper.open;
LRecordCount := QuerryBackupper.Fields[0].asInteger;
QuerryBackupper.Close;
TMyaccessDB.SelectQuerry(QuerryBackupper,
'
id, backupname,Pfad, Pfad_export,add_date,replace_folder,datei_code,add_backup_string',
'
MyBackup','
deltag = ''
t''
and Status = ''
aktiv''
');
while not QuerryBackupper.Eof
do
begin
LReccord := QuerryBackupper.FieldByName('
id').AsInteger;
LStatus := QuerryBackupper.FieldByName('
backupname').AsString;
//LStatus
LPfadFrom:= QuerryBackupper.FieldByName('
pfad').AsString;
LPfadTo:= QuerryBackupper.FieldByName('
Pfad_export').AsString;
LAddDate := QuerryBackupper.FieldByName('
add_date').AsBoolean;
LReplaceFolder := QuerryBackupper.FieldByName('
replace_folder').AsBoolean;
LAddBackupString := QuerryBackupper.FieldByName('
add_backup_string').AsBoolean;
Application.ProcessMessages;
lProcessStatus.Caption := '
Starte mit der Archivierung...';
//Strings in Arrays
Setlength(FaStatus,length(FaStatus)+1);
FaStatus[Length(FaStatus)-1] := Lstatus;
//Backupname
Setlength(FaPfad,length(FaPfad)+1);
FaPfad[Length(FaPfad)-1] := LPfadFrom;
//Pfad
Setlength(Fapfadto,length(Fapfadto)+1);
Fapfadto[Length(Fapfadto)-1] := LPfadTo;
//Pfad Export
//Boolean als Arrays
Setlength(FaAddDate,length(FaAddDate)+1);
FaAddDate[Length(FaAddDate)-1] := LAddDate;
//add_date
Setlength(FaReplaceFolder,length(FaReplaceFolder)+1);
FaReplaceFolder[Length(FaReplaceFolder)-1] := LReplaceFolder;
//replace Folder
Setlength(FAddBackupString,length(FAddBackupString)+1);
FAddBackupString[Length(FAddBackupString)-1] := LAddBackupString;
//Pfad Export
QuerryBackupper.Next;
end;
adoConBackupper.Connected := false;
for i := 0
to LRecordCount -1
do
begin
Lstatus := FaStatus[i];
LPfadFrom := FaPfad[i];
LPfadTo := Fapfadto[i];
LAddDate := FaAddDate[i];
LReplaceFolder := FaReplaceFolder[i];
LAddBackupString := FAddBackupString[i];
FFileCountFrom := TMyDaten.CountFiles(LPfadFrom);
//ist Einstellung AddDate true dann Datum erstellen
if LAddDate = true
then
LDateNow := DateToStr(now);
// is Einstellung auf true, dann wird in exportpfad'backup hinzugefügt'
if LAddBackupString = true
then
LBackupString := '
- Backup';
//LPfadTo :=LPfadTo + LBackupString + '-' + LStatus + LDateNow;
LPfadTo :=LPfadTo + '
\' + LStatus + LBackupString + LDateNow;
//pfad zu lang
LThread := MyThread.Create(true);
LThread.GPfadFrom := LPfadFrom;
LThread.GFadTo := LPfadTo;
LThread.Start;
repeat
FileCountTo := TMyDaten.CountFiles(LPfadTo);
//ermittelt OrdnerZahl
Progressbar1.Position := FileCountTo;
Application.ProcessMessages;
until FileCountTo = FFileCountFrom;
ProgressBar1.Position:= 0;
Application.ProcessMessages;
end;
//for i
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
if Height > 150
then
begin
Timer2.Enabled := false;
StartingProcess;
//
end
else
begin
LockWindowUpdate(
Handle);
try
Height := Height + 5;
top := Screen.WorkAreaHeight - Height;
//top := Screen.Height - Height;
finally
Lockwindowupdate(0);
Application.BringToFront;
end;
end;
end;
end.