1 (edited by sdpc62 2023-02-11 08:54:50)

Topic: Safeguard symbol

Hi all, how to have a symbol of backup of the program which is displayed on the screen to warn the user that the backup of his data is carried out.
Sabine

Re: Safeguard symbol

Hello sdpc

What do you mean by symbol? An image, an icon, a message?
You can use a MessageBox with its appropriate icon, create your own message box.
Give us more clarification

JB

3 (edited by sdpc62 2023-02-12 10:59:31)

Re: Safeguard symbol

Yes, an image that appears when the backup is in progress.

Re: Safeguard symbol

sdpc62 wrote:

Hi all, how to have a symbol of backup of the program which is displayed on the screen to warn the user that the backup of his data is carried out.
Sabine

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
  Stream1, Stream2: TFileStream;
begin
  Form1.SQLConnection.Connected := False;
  Stream1 := TFileStream.Create ('sqlite.db', fmOpenRead);
  try
    Stream2 := TFileStream.Create ('Backup\backup '+ FormatDateTime('dd-mm-yyyy', now)+'.db', fmOpenWrite or fmCreate);
    try
      Form1.Panel1.Color := clGreen;
      Stream2.CopyFrom (Stream1, Stream1.Size);
    finally
      Stream2.Free;
    end;
  finally
    Stream1.Free;
    Form1.SQLConnection.Connected := True;
    Form1.Panel1.Color := clBtnFace;
  end;
end;

Re: Safeguard symbol

Thank you very much Vladimir, your code works to save the data but does not display an image during the save. I would like an image or an icon to be displayed during the backup to warn the user of the program.

6 (edited by pavlenko.vladimir.v 2023-02-12 18:36:16)

Re: Safeguard symbol

sdpc62 wrote:

Thank you very much Vladimir, your code works to save the data but does not display an image during the save. I would like an image or an icon to be displayed during the backup to warn the user of the program.

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
  Form1.Image1.Picture.LoadFromFile('icons8_Copy_52px.png');
  if (CopyFile('sqlite.db','Backup\Backup_sqlite.db',False)) then
    Form1.Image1.Picture.LoadFromFile('icons8_Copy_52px_1.png') else
    Form1.Image1.Picture.LoadFromFile('icons8_Copy_52px_2.png');
end;

7 (edited by sdpc62 2023-02-13 11:24:51)

Re: Safeguard symbol

Thanks for the reply, I would like to know what "icons8_Copy_" is because I can't display the image when the backup starts. Can you explain to me please?

Re: Safeguard symbol

Hi Sabine, Hi Vladimir,
'Icons8_Copy_' are simply the names of two image files that Vladimir has used to display the status of the back-up job.
Just replace the image filenames that Vladimir uses with your own files.
Derek.

Re: Safeguard symbol

Great, it works. Is it possible to make it disappear after a few seconds, while the backup is done.

Re: Safeguard symbol

Hi Sabine,
I'd probably try to incorporate a simple splash screen as a timed event (see the attached as an example) into the code that Vladimir has already written for you.
Derek.

Post's attachments

Attachment icon sabine splash screen.zip 349.32 kb, 118 downloads since 2023-02-13 

Re: Safeguard symbol

Thanks Derek, thanks Vladimir, I included the timer in my program and when I click on the save button the timer runs until the green button appears which means the save has been done.
Thank you so much.
Sabine

12 (edited by sdpc62 2023-02-15 12:14:23)

Re: Safeguard symbol

How can I do to display an image on the main form and close it after some time. I manage to make it appear but I can't close it, I must be wrong somewhere.
Sabine

Re: Safeguard symbol

sdpc62 wrote:

How can I do to display an image on the main form and close it after some time. I manage to make it appear but I can't close it, I must be wrong somewhere.
Sabine

in the timer, check if the file sizes are the same
if YES then close the form

14 (edited by sdpc62 2023-02-16 15:57:07)

Re: Safeguard symbol

Here is an example of my program, I would like the "Backup" image to close after the time has elapsed but I can't. Can you help me please.

Post's attachments

Attachment icon Versements.zip 572.69 kb, 91 downloads since 2023-02-16 

Re: Safeguard symbol

Hi Sabine, Hi Vladimir,
For some reason, you have deleted the following instruction from your script:
application.processmessages;
This is what is preventing the image from closing.
Try it something like the attached (I have included a file size check as suggested by Vladimir).
I would be careful with the way you are doing all your processing on Form1 - it is very easy to hit 'enter' / 'save' accidently and create duplicate entries;  to try and prevent this from happening, perhaps you could make versements.somme mandatory and clear form1.edit1 when 'enter' or 'save' is pressed
Derek.

Post's attachments

Attachment icon Versements2.zip 585.95 kb, 117 downloads since 2023-02-16 

Re: Safeguard symbol

Great, thanks Derek, I was stuck on that one. Thank you so much.

Re: Safeguard symbol

Hi all,


Because of the nature of SQLite, it's not a good idea to compare sizes.
You can add multiple entries and the size will not change.
This will not give a full guarantee that the process has passed.
It's better to compare the time if it's really important.

Re: Safeguard symbol

sparrow wrote:

Hi all,


Because of the nature of SQLite, it's not a good idea to compare sizes.
You can add multiple entries and the size will not change.
This will not give a full guarantee that the process has passed.
It's better to compare the time if it's really important.

I agree about the size, but the modification time is not a reliable indicator of data modification, since when using standard authorization, the login time is recorded at each login, and other data may not change. Therefore, I make daily backups at the first start and keep copies for 5 days, the old ones are automatically deleted.

Визуальное программирование: блог и телеграм-канал.

Re: Safeguard symbol

Hello Sabine, Vladimir, Sparrow, Konstantin (and anyone else!),
In the past, I have used

sqlexecute('select total_changes()')

to detect if any changes have been made to determine if I need to perform a back-up or not.
If so, you could then automate it on a 'form_close' procedure rather than relying on users to do it manually (they say they will but they never do!).
Maybe this is of interest.
Derek.

Re: Safeguard symbol

Your code works wonderfully. I would also like to put a progress bar on the form to view the backup, any idea?

Post's attachments

Attachment icon Bare de progression.jpg 5.93 kb, 36 downloads since 2023-02-17 

Re: Safeguard symbol

sdpc62 wrote:

Your code works wonderfully. I would also like to put a progress bar on the form to view the backup, any idea?

Maybe someone knows a script for reading and writing in blocks or by bits...?
Может кто знает скрипт для чтения и записи по блокам или по битам...?

22 (edited by agusecc 2023-02-18 07:19:56)

Re: Safeguard symbol

mybe this link can help for make progressbar

http://myvisualdatabase.com/forum/viewt … 020#p25020
or
http://myvisualdatabase.com/forum/viewtopic.php?id=553

Re: Safeguard symbol

It's exactly what I needed. Thank you all for your efforts, you are on top.
Sabine