Hi,
After another discussion with a customer about something that happened on his system, I would like to have a logfile of each selected menu-item. I want to see if a user started a menuoption in my logfiles. For exemple: If they choose to delete all stock, and they confirm three times, I want to proove this to their boss.
I suppose this doesn't exist in eXpress++ at this moment? Or is there something in the eventhandler to get this done?
Suggestions are always welcome.
Logfile in menusystem?
Re: Logfile in menusystem?
Hi, Chris.
We do log lots of transactions in our app, not only those selected from menus, but also button clicks, drag&drops a.s.o. There is a central function "LogTransaction(<cTransaction>,[<lImportant>])", which is called at the end of every to-be-logged transaction (since the user may decide not to use the function after he called it). It writes the date, the time, the name of the user, the transaction text and, if handed, the parameter "lImportant", which creates a warn sign in the transaction log (i.e. customer data deleted).
If you only want to log the name of the menu item, you may change DCDIALOG.CH (or create a clone added to your app before DCDIALOG.CH), which changes this line for "DCMENUITEM":
Instead of just adding the "bAction" codeblock to the menu, you may create something like this: "{||WriteTransaction(<cPrompt>),Eval(<bAction>)}"
This would call a function "WriteTransaction" with the caption of the menu item and the action-codeblock afterwards. I'm not sure if this will work in any situation, but it may point into the right direction.
We do log lots of transactions in our app, not only those selected from menus, but also button clicks, drag&drops a.s.o. There is a central function "LogTransaction(<cTransaction>,[<lImportant>])", which is called at the end of every to-be-logged transaction (since the user may decide not to use the function after he called it). It writes the date, the time, the name of the user, the transaction text and, if handed, the parameter "lImportant", which creates a warn sign in the transaction log (i.e. customer data deleted).
If you only want to log the name of the menu item, you may change DCDIALOG.CH (or create a clone added to your app before DCDIALOG.CH), which changes this line for "DCMENUITEM":
Code: Select all
[;DC_GetListSet(DCGUI_GETLIST,bGETLIST_ACTION,<bAction>)]
This would call a function "WriteTransaction" with the caption of the menu item and the action-codeblock afterwards. I'm not sure if this will work in any situation, but it may point into the right direction.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Logfile in menusystem?
Chris -
I have added this new sample to eXpress++.
Roger
I have added this new sample to eXpress++.
Roger
Code: Select all
#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"
#INCLUDE "fileio.CH"
FUNCTION Main()
LOCAL GetList[0], oMenuBar, oMenu1, oMenu2
DCMENUBAR oMenuBar
DCSUBMENU oMenu1 PROMPT 'File' PARENT oMenuBar
DCMENUITEM 'Open a file' PARENT oMenu1 ACTION {||MsgBox('Open File')}
DCMENUITEM 'Close a file' PARENT oMenu1 ACTION {||MsgBox('Close File')}
DCSUBMENU oMenu2 PROMPT 'Edit' PARENT oMenuBar
DCMENUITEM 'Edit a file' PARENT oMenu2 ACTION {||MsgBox('Edit File')}
DCMENUITEM 'Save a file' PARENT oMenu2 ACTION {||MsgBox('Save File')}
DCREAD GUI HANDLER MenuHandler
RETURN nil
PROC appsys ; return
STATIC FUNCTION MenuHandler( nEvent, mp1, mp2, oXbp )
IF nEvent == xbeP_ActivateItem .AND. oXbp:isDerivedFrom('DC_XbpMenu')
LogItem( oXbp:items[mp1] )
ENDIF
RETURN DCGUI_NONE
* -----------
STATIC FUNCTION LogItem( aItem )
LOCAL nHandle
nHandle := FOpen( 'MENU.LOG', FO_READ+FO_WRITE )
IF nHandle <= 0
nHandle := FCreate( 'MENU.LOG' )
ENDIF
FSeek( nHandle, 0, FS_END )
FWrite( nHandle, DC_Array2String( aItem ) + Chr(13) + Chr(10) )
FClose( nHandle )
RETURN nil
The eXpress train is coming - and it has more cars.
Re: Logfile in menusystem?
Hi Tom, Roger,
Thanks for the ideas.
To Tom.
A generic function which can be called to log also other important actions is a good idea. This way it should be easy to add this also to some pushbuttons.
Thanks for the ideas.
To Tom.
The discussion I had yesterday is that I'm quite sure a user did stop the application with the taskmanager after he started it. The first 30.000 records of a table were modified. I like to log the menuitems, and also log the result of the confirmations they did to proceed.which is called at the end of every to-be-logged transaction (since the user may decide not to use the function after he called it).
A generic function which can be called to log also other important actions is a good idea. This way it should be easy to add this also to some pushbuttons.