Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 3 Jahren, 3 Monaten
Letzter Beitrag:
vor 3 Jahren, 3 Monaten
Beteiligte Autoren:
Yogi Yang, Paulo Oliveira, Al

Need Advise WD17 - Maintain User activity Log

Startbeitrag von Yogi Yang am 08.11.2014 15: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

Antworten:

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

von Al - am 08.11.2014 15:47
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)

von Paulo Oliveira - am 08.11.2014 16:33
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.

von Yogi Yang - am 13.11.2014 06:42
Yogi
check this sample of triggers it may give you some hints.

http://27130.foren.mysnip.de/read.php?27131,472901,476005#msg-476005

von Paulo Oliveira - am 13.11.2014 09:35
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.