PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Need Advise WD17 - Maintain User activity Log
Need Advise WD17 - Maintain User activity Log
Iniciado por guest, 08,nov. 2014 16:10 - 6 respuestas
Publicado el 08,noviembre 2014 - 16:10
In an application that I am developing I want to manage activity log as to when a particular data record was created, edited, etc. So for this what I did was added 6 fields to every Table/File like this:
CreatedDate
CreatedTime
CreatedBy
ModifyDate
ModifyTime
ModifiedBy

Things are working fine till today.

Now my boss says that I have to maintain a complete log in which all the activity on any table/file should be recorded. Meaning that after an entry is created I have to maintain a complete log for many times as it is edited by users so if users edit a record 15 times all the 15times entries should be recorded and for this I have to also maintain old data and new data for comparision.

For this what is better way from following:
Build a set of procedures that will create necessary entries in a specialized table/file and call these routines as necessary
Built a set of Triggers and a few stored procedures that will do the handy work

TIA

Yogi Yang
Publicado el 08,noviembre 2014 - 16:47
Hello Yogi

There is logging built into Windev and it will capture the changes you require, so you could have a look at it. I could never figure out how to actually use the log files so like you I use my own process.

From day one when I started with Windev I used my own processes to add,delete and modify so I have procedures called "recordadd", "recordmodify" and "recorddelete" that my programs use so typically, my projects have only one instance of HAdd and HModify and I funnel all my deletes through a central "RecordDelete" function that handles deletion of all records (and any linked records because I do not use Windev's Integrity options for that)

You can do a similar process by just overloading the Windev HAdd, HModify and HDelete functions with your own functions of the same names and this will give you control over every time these functions are called and you can write your own logs from these functions. This would be simpler than triggers but the advantage of triggers is that they will also run for external changes to the database if you use HFCS.

As storage space is no longer an issue with most installations, an easy option would be to just maintain a duplicate set of files and maintain them as a copy using HCopyRecord()

Regards
Al
Publicado el 08,noviembre 2014 - 17:33
If your DB is HF use the LOG for that it's the easy way. Check the log features in the help and the HHistoryModification function.

If your DB isn't HF or if you want to do it yourself my sugestion is using triggers at DB level.
If you only overload the h* function or if you use triggers at app level you can´t store external changes and you can't store changes made by SQL (INSERT/UPDATE/DELETE)
Publicado el 09,noviembre 2014 - 05:38
Keep in mind that LOG is primarily designed for recovery and not long term tracking of changes. If LOG is ever cleared (after a full backup for example) then your history of changes goes as well.

LOG is not backed up with your data and can easily fall out of sync when you rebuild a server or move the database.
Miembro registrado
28 mensajes
Publicado el 09,noviembre 2014 - 10:47
Hi Yogi

Keep in mind that the LOG is designed for recovery and not for the lifetime tracking of changes to data. It can easily be deleted and does not form part of the standard backup. When the database is copied or moved the LOG does not go with.

Regards
Dave
Publicado el 13,noviembre 2014 - 07:42
Al and Paulo,

Thanks for your inputs. I think I will have to use some extra coding that will extract required data and concatenate it into a single string and then dump the string in a file in log file/table.

Currently I am working on MySQL which is remote and am using webservices (php4wm) to access it. In this case HF is not being used.
Publicado el 13,noviembre 2014 - 10:35
Yogi
check this sample of triggers it may give you some hints.

<a class="ExternalLink" rel="nofollow" target="_blank" href="http://27130.foren.mysnip.de/read.php?27131,472901,476005#msg-476005">http://27130.foren.mysnip.de/read.php&hellip;</a>