Capturar eventos

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

Post Reply
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Capturar eventos

Post by luisvasquezcl »

Estimados,
tengo que generar un archivo en donde se registren todos los movimientos que hacen los usuarios dentro de un sistema.
Esto es, cuando crean, modifican o borran un comprobante, un registro de detalle ...etc.
hay alguna forma de poder hacer una funcion que por cada movimiento que efectue el usuario se capture el Procfile, Procname, Procline.
Les agradecería que pudieran aportarme alguna idea.
Saludos cordiales,
Luis VAsquez.


Dear,
I have to create a file where all movements are recorded
how users within a system.
That is, when they create, modify or delete a receipt, a record of
... etc detail.
there is any way we could make a function that for each movement
VERIFIABLE user Procfile be captured, procname, procline.
I appreciate that could provide some idea.
Best regards,
Luis Vasquez.
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Capturar eventos

Post by gfilatov »

luisvasquezcl wrote: Dear,
I have to create a file where all movements are recorded
how users within a system.
That is, when they create, modify or delete a receipt, a record of
... etc detail.
there is any way we could make a function that for each movement
VERIFIABLE user Procfile be captured, procname, procline.
I appreciate that could provide some idea.
Hello Luis Vasquez,

The Harbour have a LOGRDD rdd driver for this purpose (placed in hbuddall library).

Please be so kind to revise the following sample:

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 *
 * Copyright 2002-2008 Roberto Lopez <harbourminigui@gmail.com>
 * http://harbourminigui.googlepages.com/
*/

#include "dbinfo.ch"

// Request for LOGRDD rdd driver
REQUEST LOGRDD

// Here put Request for RDD you want to inherit then add
// function hb_LogRddInherit() (see at bottom)
REQUEST DBFCDX

#include "minigui.ch"

Memvar memvartestcode
Memvar memvartestfirst
Memvar memvartestlast
Memvar memvartestbirth

Function Main

	SET CENTURY ON
	SET DELETED ON

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'MiniGUI Browse Demo' ;
		MAIN NOMAXIMIZE ;
		ON INIT OpenTables() ;
		ON RELEASE CloseTables()

		DEFINE MAIN MENU 
			POPUP 'File'
				ITEM 'Set Browse Value'	ACTION Form_1.Browse_1.Value := 50
				ITEM 'Get Browse Value'	ACTION MsgInfo ( Str ( Form_1.Browse_1.Value ) )
				ITEM 'Refresh Browse'	ACTION Form_1.Browse_1.Refresh
				SEPARATOR
				ITEM 'Exit'		ACTION Form_1.Release
			END POPUP
			POPUP 'Help'
				ITEM 'About'		ACTION MsgInfo ("MiniGUI Browse Demo") 
			END POPUP
		END MENU

		DEFINE STATUSBAR
			STATUSITEM 'HMG Power Ready'
			STATUSITEM '<Enter> / Double Click To Edit' WIDTH 200
			STATUSITEM 'Alt+A: Append' WIDTH 120
		END STATUSBAR

		@ 10,10 BROWSE Browse_1									;
		WIDTH 610  										;
		HEIGHT 390 										;	
		HEADERS { 'Code' , 'First Name' , 'Last Name', 'Birth Date', 'Married' , 'Biography' } ;
		WIDTHS { 150 , 150 , 150 , 150 , 150 , 150 } ;
		WORKAREA Test ;
		FIELDS { 'Test->Code' , 'Test->First' , 'Test->Last' , 'Test->Birth' , 'Test->Married' , 'Test->Bio' } ;
		VALUE 1 ;
		EDIT INPLACE APPEND DELETE ;
		VALID { { || MemVar.Test.Code <= 1000 } , { || !Empty(MemVar.Test.First) } , { || !Empty(MemVar.Test.Last) } , { || Year(MemVar.Test.Birth) >= 1900 } , , 
} ;
		VALIDMESSAGES { 'Code Range: 0-1000', 'First Name Cannot Be Empty', , , ,  } ;
		LOCK 

	END WINDOW

	CENTER WINDOW Form_1

	Form_1.Browse_1.SetFocus

	ACTIVATE WINDOW Form_1

Return Nil

Procedure OpenTables()
   // Set LOGRDD as default RDD otherwise I have to set explicitly use
   // with DRIVER option
   RDDSetDefault( "LOGRDD" )
   // Adding Memofile Info
   rddInfo( RDDI_MEMOVERSION, DB_MEMOVER_CLIP, "LOGRDD" )

   // Define Log File Name and position
   hb_LogRddLogFileName( "logs\changes.log" )
   // Define Tag to add for each line logged
   hb_LogRddTag( NETNAME() + "\" + hb_USERNAME() )
   // Activate Logging, it can be stopped/started at any moment
   hb_LogRddActive( .T. )

   // Comment next line to change the logged string to standard LOGRDD message
   hb_LogRddMsgLogBlock( {|cTag, cRDDName, cCmd, nWA, xPar1, xPar2, xPar3| MyToString( cCmd, nWA, xPar1, xPar2, xPar3 ) } )

   // Open a table with logging (default RDD is LOGRDD)
   USE test SHARED
Return

Procedure CloseTables()
   USE
Return

STATIC FUNCTION MyToString( cCmd, nWA, xPar1, xPar2, xPar3 )
   LOCAL cString

   DO CASE
      CASE cCmd == "CREATE"
           // Parameters received: xPar1 = aOpenInfo
           cString := xPar1[ UR_OI_NAME ] + " created"
      CASE cCmd == "CREATEFIELDS"
           // Parameters received: xPar1 = aStruct
           cString := hb_ValToExp( xPar1 )
      CASE cCmd == "OPEN"
           // Parameters received: xPar1 = aOpenInfo
           cString := 'Open table : "' + xPar1[ UR_OI_NAME ] + '", Alias : "' + Alias() + '", WorkArea : ' + LTrim( Str( nWA ) )
      CASE cCmd == "CLOSE"
           // Parameters received: xPar1 = cTableName, xPar2 = cAlias
           cString := 'Close table : "' + xPar1 + '", Alias : "' + xPar2 + '", WorkArea : ' + LTrim( Str( nWA ) )
      CASE cCmd == "APPEND"
           // Parameters received: xPar1 = lUnlockAll
           cString := Alias() + "->RecNo() = " + LTrim( Str( RecNo() ) ) + " appended"
      CASE cCmd == "DELETE"
           // Parameters received: none
           cString := Alias() + "->RecNo() = " + LTrim( Str( RecNo() ) ) + " deleted"
      CASE cCmd == "RECALL"
           // Parameters received: none
           cString := Alias() + "->RecNo() = " + LTrim( Str( RecNo() ) ) + " recalled"
      CASE cCmd == "PUTVALUE"
           // Parameters received: xPar1 = nField, xPar2 = xValue, xPar3 = xOldValue
#ifndef __XHARBOUR__
           HB_SYMBOL_UNUSED( xPar3 ) // Here don't log the previous value
#endif
           cString := Alias() + "(" + LTrim( Str( RecNo() ) ) + ")->" + PadR( FieldName( xPar1 ), 10 ) + " := " + hb_LogRddValueToText( xPar2 ) + " replaced"
      CASE cCmd == "ZAP"
           // Parameters received: none
           cString := 'Alias : "' + Alias() + ' Table : "' + dbInfo( DBI_FULLPATH ) + '" zapped'
   ENDCASE
RETURN cString

FUNCTION hb_LogRddInherit()
RETURN "DBFCDX"
I hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: Capturar eventos

Post by luisvasquezcl »

Excellent Grigory.
Thank you very much for your help.
Best regards,
Luis Vasquez.
Post Reply