File: eaf_n_cst_baseservice.sru
Size: 11855
Date: Tue, 22 Jan 2008 23:39:19 +0100
$PBExportHeader$eaf_n_cst_baseservice.sru
forward
global type eaf_n_cst_baseservice from nonvisualobject
end type
end forward

global type eaf_n_cst_baseservice from nonvisualobject
end type
global eaf_n_cst_baseservice eaf_n_cst_baseservice

type variables
Public:
n_cst_messageservice       inv_messaging
string                     is_logservice =                           "n_cst_loggingservice_base"

Protected:
long                       il_languageid = 1

//Debugging/Error references
boolean                    ib_trace = false
boolean                    ib_debug = false
boolean                    ib_detailed = false
boolean                    ib_warning = false
boolean                    ib_usedatabaselogging = false

string                     is_crlf = char(10) + char(13)

n_cst_loggingservice_base  inv_log

n_cst_constants            inv_constants


end variables

forward prototypes
public function long setdebug (boolean ab_state)
public function long setdetailed (boolean ab_state)
public function long settrace (boolean ab_state)
public function long setwarning (boolean ab_state)
public function long setlanguageid (long al_languageid)
public function long getlanguageid ()
public function long setusedatabaselogging (boolean ab_value)
public function long propagatelogsettings ()
public function long adderror (string as_methodname, string as_message)
end prototypes

public function long setdebug (boolean ab_state);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Sets the debug property.  If TRUE it will allow debugging 
//    messages to be sent to the logging service
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ab_state - The switch to enable/disable the property
// Returns:
//     1 - Success
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setDebug "

// Validate arguments
If isNull(ab_state) Then
   addError (METHOD_NAME, "Invalid ab_state argument")
   Return -1
End If

ib_debug = ab_state

inv_log.setDebug( ib_debug )

Return 1
end function

public function long setdetailed (boolean ab_state);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Sets the detailed property.  If TRUE it will allow detailed
//    tracing and debugging messages to be sent to the logging service
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ab_state - The switch to enable/disable the property
// Returns:
//     1 - Success
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setDetailed "

// Validate arguments
If isNull(ab_state) Then
   addError (METHOD_NAME, "Invalid ab_state argument")
   Return -1
End If

ib_detailed = ab_state

inv_log.setDetailed( ib_detailed )


Return 1
end function

public function long settrace (boolean ab_state);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Sets the trace property.  If TRUE it will allow tracing 
//    messages to be sent to the logging service
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ab_state - The switch to enable/disable the property
// Returns:
//     1 - Success
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setTrace "

// Validate arguments
If isNull(ab_state) Then
   addError (METHOD_NAME, "Invalid ab_state argument")
   Return -1
End If

ib_trace = ab_state

inv_log.setTrace( ib_trace )


Return 1
end function

public function long setwarning (boolean ab_state);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Sets the warning property.  If TRUE it will allow warning
//    messages to be sent to the logging service
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ab_state - The switch to enable/disable the property
// Returns:
//     1 - Success
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setWarning "

// Validate arguments
If isNull(ab_state) Then
   addError (METHOD_NAME, "Invalid ab_state argument")
   Return -1
End If

ib_warning = ab_state

inv_log.setWarning( ib_warning )

Return 1
end function

public function long setlanguageid (long al_languageid);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Sets the Language ID property.  
//    1.0   - Initial version
// Arguments:  
//    al_languageid - The new default Language
// Returns:
//     1 - Success
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of thems, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setLanguageID "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(al_languageid)   al_languageid="+string(al_languageid))
End If   

// Validate arguments
If isNull(al_languageid) Or al_languageid <= 0 Then
   addError (METHOD_NAME, "Invalid al_languageid argument")
   Return -1
End If

il_languageid = al_languageid
Return 1
end function

public function long getlanguageid ();///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Gets the Language ID property.  
//    1.0   - Initial version
// Arguments:  
//    None
// Returns:
//     The Language ID property
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Applirk
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getLanguageID "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "")
End If   

Return il_languageid
end function

public function long setusedatabaselogging (boolean ab_value);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Sets the warning variable
//    Required for the LogPropagation interface
//    
//    1.0   - Initial version
// Arguments:  
//    as_error - The actual error messsage
// Returns:
//     1 - Success
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Encation Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setUseDatabaseLogging( boolean value ) "

ib_usedatabaselogging = ab_value

inv_log.setUseDatabaseLogging( ib_usedatabaselogging )

Return 1

end function

public function long propagatelogsettings ();///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Stub method to signal the completion of log settings to allow 
//    propagation to continue to other loggable objects
// Revisions
//    3.0   - Initial version
// Arguments:  
//    None
// Returns:
//     1 - Success
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "propagateLogSettings() "

inv_log.traceLog (METHOD_NAME, "")

inv_log.setTrace( ib_trace )
inv_log.setDebug( ib_debug )
inv_log.setDetailed( ib_detailed )
inv_log.setWarning( ib_warning )
inv_log.setUseDatabaseLogging( ib_usedatabaselogging )

return 1

end function

public function long adderror (string as_methodname, string as_message);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Adds the error to the message stack and logs the error
//    Sets the last error variable for legacy code support
//
//    Revisions
//    3.0   - Initial version
// Arguments:  
//    as_error - The actual error messsage
// Returns:
//     1 - Success
//    -1 - Failure
////////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, In reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

inv_log.addError(as_methodname, as_message, inv_messaging)


return 1

end function

on eaf_n_cst_baseservice.create
call super::create
TriggerEvent( this, "constructor" )
end on

on eaf_n_cst_baseservice.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

event constructor;///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Occurs when the object is created
// Revisions
//    1.0   - Initial version
// Arguments:  
//    None
// Returns: 
///////////////////////////////////////////////////////////////////////////////////

constant string METHOD_NAME = "constructor "

// Tell the logging service who requested it
inv_log = create using is_logservice

inv_log.setRequestor(this)

inv_constants = create n_cst_constants

inv_messaging = create n_cst_messageservice

end event

event destructor;///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Occurs when the object is destroyed
// Revisions
//    1.0   - Initial version
// Arguments:  
//    None
// Returns: 
///////////////////////////////////////////////////////////////////////////////////

if isValid( inv_log ) then
   destroy inv_log
end if

if ( isValid( inv_constants ) ) then
   destroy inv_constants
end if

if ( isValid( inv_messaging ) ) then
   destroy inv_messaging
end if

end event