Logfile in menusystem?

This forum is for eXpress++ general support.
Post Reply
Message
Author
skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Logfile in menusystem?

#1 Post by skiman »

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. :twisted:

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.
Best regards,

Chris.
www.aboservice.be

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Logfile in menusystem?

#2 Post by Tom »

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":

Code: Select all

[;DC_GetListSet(DCGUI_GETLIST,bGETLIST_ACTION,<bAction>)]
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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Logfile in menusystem?

#3 Post by rdonnay »

Chris -

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.

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Logfile in menusystem?

#4 Post by skiman »

Hi Tom, Roger,

Thanks for the ideas.

To Tom.
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).
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.

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.
Best regards,

Chris.
www.aboservice.be

Post Reply