$PBExportHeader$eaf_n_cst_objectservice.sru forward global type eaf_n_cst_objectservice from n_cst_baseservice end type end forward global type eaf_n_cst_objectservice from n_cst_baseservice string is_logservice = "n_cst_loggingservice" end type global eaf_n_cst_objectservice eaf_n_cst_objectservice type prototypes protected: function long GetEnvironmentVariable(ref string variablename, ref string variablevalue, long length ) Library "KERNEL32.DLL" Alias for "GetEnvironmentVariableA;Ansi" end prototypes type variables Public: // Component n_cst_MessageManager inv_messagemanager n_cst_VariableManager inv_variablemanager Protected: // Package/Component Name Defaults and Availability boolean ib_messagemanageravailable = false string is_messagemanager = "n_cst_MessageManager" string is_variablemanager = "n_cst_VariableManager" // Service internal message cache functionality string is_messageid[] long il_messagelanguageid[] string is_message[] end variables forward prototypes public function long setmessagemanager (string as_name) public function boolean ismessagemanageravailable () public function long setmessagemanager () public function long addmessage (string as_messageid, long al_languageid, string as_message) public function long getvariable (string as_variablename, ref string as_variablevalue) public function long setvariablemanager (string as_name) public function long setvariable (string as_variablename, string as_variablevalue) public function long getpbversion (ref integer ai_pbversion) public function long getenvironmentvariable (string as_name, ref string as_value) public subroutine setcomponentname (string as_componentname) public function long getmessage (string as_messageid, ref string as_message) public function long messageprepare (string as_messageid, ref string as_message, string as_parameters[]) public function long messageprepare (string as_messageid, ref string as_message) end prototypes public function long setmessagemanager (string as_name);//////////////////////////////////////////////////////////////// // Description: // Sets the Message Manager to be used by this object. // // The object must already have a valid connection to the // server. // Revisions // 1.0 - Initial version // Arguments: // as_name - The name of the message manager // Returns: // 1 - Success // 0 - Component Not Available by design (not an error) // -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 = "setMessageManager " String ls_runtimeerror If ib_trace Then inv_log.traceLog (METHOD_NAME, "(as_name) " +& "as_name='"+as_name+"'") End If // Check on availability If Not isMessageManagerAvailable() Then // Component Not Available by design (not an error) inv_log.warningLog(METHOD_NAME, "Proper MessageManager availability should be set prior to this call") Return 0 End If // Perform cleanup as_name = trim(as_name) // Validate arguments If isNull(as_name) Or len(as_name) = 0 Then addError(METHOD_NAME, "Invalid as_name argument") Return -1 End If // Confirm this is a valid object try inv_messagemanager = create using as_name catch ( RuntimeError re ) addError(METHOD_NAME, "Create for Message Manager " + & "'" + as_name + "' failed") Return -1 end try // Set the attribute is_messagemanager = as_name Return 1 end function public function boolean ismessagemanageravailable ();//////////////////////////////////////////////////////////////// // Description: // Determins if the Message Manager is Available // Revisions // 1.0 - Initial version // Arguments: // None // Returns: // true - Yes, it is available // false - No, it is not available //////////////////////////////////////////////////////////////// // 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 = "isMessageManagerAvailable " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "") End If If isNull(ib_messagemanageravailable) Then ib_messagemanageravailable = false Return ib_messagemanageravailable end function public function long setmessagemanager ();//////////////////////////////////////////////////////////////// // Description: // Sets the Message Manager to be used by this object. // // The object must already have a valid connection to the // server. // Revisions // 1.0 - Initial version // Arguments: // None // Returns: // 1 - Success // 0 - Component Not Available by design (not an error) // -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 = "setMessageManager " If ib_trace Then inv_log.traceLog (METHOD_NAME, "() ") End If // Function overload Return setMessageManager(is_messagemanager) end function public function long addmessage (string as_messageid, long al_languageid, string as_message);//////////////////////////////////////////////////////////////// // Description: // Adds a message to the Internal Cache. // // This is nomally used when there is no support for the MessageManager. // Revisions // 1.0 - Initial version // Arguments: // as_messageid - The message Identification // al_languageid - The Langage Identification // as_message - The message itself // 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 = "addMessage " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "") End If // Declare local variables long ll_newupper // Perform cleanup as_messageid = lower(trim(as_messageid)) // Validate arguments If isNull(as_messageid) Or len(as_messageid) <= 0 Then addError (METHOD_NAME,"Invalid as_messageid argument") Return -1 End If If isNull(al_languageid) Or al_languageid <= 0 Then addError (METHOD_NAME,"Invalid al_languageid argument") Return -1 End If If isNull(as_message) Or len(trim(as_message)) <= 0 Then addError (METHOD_NAME, "Invalid as_message argument") Return -1 End If // Add the new entry ll_newupper = upperBound(is_messageid) + 1 is_messageid[ll_newupper] = as_messageid il_messagelanguageid[ll_newupper] = al_languageid is_message[ll_newupper] = as_message Return 1 end function public function long getvariable (string as_variablename, ref string as_variablevalue);//////////////////////////////////////////////////////////////// // Description: // Gets the variable value for the passed in variable name // // Revisions // 3.0 - Initial version // Arguments: // as_variablename - The message Identification // as_variablevalue - The place holder for the message // 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 = "getVariable ( String, REF String ) " inv_log.traceLog (METHOD_NAME, "") // Declare local variables long ll_rc long ll_method_rc string ls_rc // Validate arguments If isNull(as_variablename) Or len(as_variablename) <= 0 Then addError (METHOD_NAME, "Invalid as_variablename argument") Return -1 End If return inv_variablemanager.getValue( as_variablename, as_variablevalue ) end function public function long setvariablemanager (string as_name);//////////////////////////////////////////////////////////////// // Description: // Sets the Variable Manager to be used by this object. // // The object must already have a valid connection to the // server. // Revisions // 3.0 - Initial version // Arguments: // as_name - The name of the variable manager // 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 = "setVariableManager " String ls_runtimeerror If ib_trace Then inv_log.traceLog (METHOD_NAME, "(as_name) " +& "as_name='"+as_name+"'") End If // Perform cleanup as_name = trim(as_name) // Validate arguments If isNull(as_name) Or len(as_name) = 0 Then addError(METHOD_NAME, "Invalid as_name argument") Return -1 End If // Confirm this is a valid object try inv_variablemanager = create using as_name catch ( RuntimeError re ) addError(METHOD_NAME, "Create for Message Manager " + & "'" + as_name + "' failed") Return -1 end try // Set the attribute is_variablemanager = as_name Return 1 end function public function long setvariable (string as_variablename, string as_variablevalue);//////////////////////////////////////////////////////////////// // Description: // Sets the variable value for the passed in variable name // // Revisions // 3.0 - Initial version // Arguments: // as_variablename - Variable name // as_variablevalue - Variable value // 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 = "setVariable ( String, String ) " inv_log.traceLog (METHOD_NAME, "") // Declare local variables long ll_rc long ll_method_rc string ls_rc // Validate arguments If isNull(as_variablename) Or len(as_variablename) <= 0 Then addError (METHOD_NAME, "Invalid as_variablename argument") Return -1 End If return inv_variablemanager.setValue( as_variablename, as_variablevalue ) end function public function long getpbversion (ref integer ai_pbversion);//////////////////////////////////////////////////////////////// // Description: // Gets the current major version of the PB runtime environment // // Revisions // 4.0 - Initial version // Arguments: // al_pbversion - Reference variable for the PB version number // 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 = "getPBVersion ( REF long ) " // Declare local variables long ll_rc ContextInformation lctx_info inv_log.traceLog (METHOD_NAME, "") getContextService( "ContextInformation", lctx_info ) lctx_info.getMajorVersion( ai_pbversion ) return 1 end function public function long getenvironmentvariable (string as_name, ref string as_value);//////////////////////////////////////////////////////////////// // Description: // Retrieves the value for the requested environment variable. // Revisions // 4.0 - Initial version // Arguments: // as_name - Environment variable name // as_value - REF Environment variable value // 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 = "getEnvironmentVariable( string, REF string ) " // Declare local variables long ll_length = 255 long ll_rc as_value = space ( ll_length ) ll_rc = GetEnvironmentVariable( as_name, as_value, ll_length ) if ll_rc > 0 then return 1 else as_value = "" return -1 end if end function public subroutine setcomponentname (string as_componentname);if IsValid(inv_log) then inv_log.Dynamic SetComponentName(as_ComponentName) end if end subroutine public function long getmessage (string as_messageid, ref string as_message);//////////////////////////////////////////////////////////////// // Description: // Gets the appropriate Message for the passed in // MessageID // This is nomally used when there is no support for the MessageManager. // Revisions // 1.0 - Initial version // Arguments: // as_messageid - The message Identification // as_message - The place holder for the message // 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 = "getMessage " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(as_messageid, ref as_message)~r~n"+ & " as_messageid="+as_messageid+"~r~n" + & " as_message="+as_message) End If // Declare local variables long ll_rc long ll_method_rc long ll_upper long ll_idx long ll_lowindexlanguageid = 9999 string ls_rc string ls_lowindexmessage string ls_holdmessage // Perform cleanup as_messageid = lower(trim(as_messageid)) // Validate arguments If isNull(as_messageid) Or len(as_messageid) <= 0 Then addError (METHOD_NAME,"Invalid as_messageid argument") Return -1 End If // Go after the appropriate source for the message If isMessageManagerAvailable() Then // Session Manager - Internal Cache is not being used // Check for existence of the Message Manager If isNull(inv_messagemanager) Or & Not isValid(inv_messagemanager) Then If setMessageManager(is_messagemanager) < 0 Then addError(METHOD_NAME, "Invalid setMessageManager('"+ & is_messagemanager+"') operation") Return -1 End If End If // Get the appropriate message from the Message Manager ls_holdmessage = as_message ll_rc = inv_messagemanager.getMessage (as_messageid, il_languageid, as_message) If isNull(ll_rc) Or ll_rc <= 0 Then ls_rc = string(ll_rc) If isNull(ls_rc) Then ls_rc = "Null" as_message = ls_holdmessage End If addError (METHOD_NAME,"Invalid call to inv_messagemanager.getMessage('"+ as_messageid+"') operation RC="+ls_rc) ll_method_rc = -1 End If Return ll_method_rc Else // Internal Cache - Session Manager is not being used // Get the number of entries on the cache ll_upper = upperBound(is_messageid) If ll_upper <= 0 Then addError (METHOD_NAME,"Invalid or No entries cache") Return -1 End If // Loop until the MessageID and LanguageID match is found Do ll_idx ++ If is_messageid[ll_idx] = as_messageid Then If il_messagelanguageid[ll_idx] = il_languageid Then as_message = is_message[ll_idx] Return 1 End If // Keep the MessageID match with the lowest LanguageID just in case // the match Language is not found If il_messagelanguageid[ll_idx] < ll_lowindexlanguageid Then ll_lowindexlanguageid = il_messagelanguageid[ll_idx] ls_lowindexmessage = is_message[ll_idx] End If End If Loop Until (ll_idx >= ll_upper) If len(ls_lowindexmessage) = 0 Then addError (METHOD_NAME, "Failed to find the passed in as_messageid ("+as_messageid+")") Else as_message = ls_lowindexmessage addError (METHOD_NAME, "Failed to find the passed in messageID ("+as_messageid+") " + & "il_languageid (+"+string(il_languageid)+"); passing back " + & "languageid ("+string(ll_lowindexlanguageid)+").") End If Return -1 End If // Imposible to hit this line of code Return -1 end function public function long messageprepare (string as_messageid, ref string as_message, string as_parameters[]);//////////////////////////////////////////////////////////////// // Description: // Prepares the message based on the information passed in. // Revisions // 1.0 - Initial version // Arguments: // as_messageid - The message Identification // as_sessionid - current user's session id // as_message - The place holder for the message // as_parameters[]- The parameters values // 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 = "messagePrepare ( String, String, REF STring, String[] ) " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(as_messageid, ref as_message, " + & "as_parameters[])~r~n"+ & " as_messageid="+as_messageid+"~r~n" + & " as_message="+as_message) End If // Declare local variables long ll_method_rc = 1 n_cst_helperservice lnv_helper try // Perform cleanup as_messageid = lower(trim(as_messageid)) // Validate arguments If isNull(as_messageid) Then addError (METHOD_NAME,"Invalid as_messageid argument") Return -1 End If If len(as_message) = 0 And len(trim(as_messageid)) = 0 Then addError (METHOD_NAME,"Invalid as_message argument when there is no as_messageid") Return -1 End If // Can only get a message if there is a Message ID If len(as_messageid) > 0 Then ll_method_rc = this.getMessage(as_messageid, as_message) End If // Perform the parameter substitutions If upperBound(as_parameters) > 0 Then lnv_helper = create n_cst_helperservice If lnv_helper.replaceParameter (as_message, as_parameters, "%s") <= 0 Then addError (METHOD_NAME,"Invalid call to lnv_helper.replaceParameter('"+ as_message + ", parms') operation") Return -1 End If End If Return ll_method_rc finally if isValid( lnv_helper ) then destroy lnv_helper end if end try end function public function long messageprepare (string as_messageid, ref string as_message);//////////////////////////////////////////////////////////////// // Description: // Prepares the message based on the information passed in. // Revisions // 1.0 - Initial version // Arguments: // as_messageid - The message Identification // as_sessionid - current user's session id // as_message - The place holder for the message // 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 = "messagePrepare( String, String, REF String ) " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(as_messageid, ref as_message)~r~n"+ & " as_messageid="+as_messageid+"~r~n" + & " as_message="+as_message) End If // Declare local variables long ll_rc string ls_parms[] // Function overload default is not parameters ll_rc = messagePrepare(as_messageid, as_message, ls_parms) Return ll_rc end function on eaf_n_cst_objectservice.create call super::create end on on eaf_n_cst_objectservice.destroy call super::destroy end on event constructor;call super::constructor;//////////////////////////////////////////////////////////////// // Description: // Occurs when the object is created. // There are a Client and a Server side Objects. These are // two different object serving the same kind of capabilities // for their perspective environment. // Revisions // 1.0 - Initial version // 3.0 - Added instantiation of VariableManager // Arguments: // None // Returns: //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "constructor() " // Declare local variables long ll_rc //Enable the VariableManager setVariableManager( is_variablemanager ) end event event destructor;call super::destructor;if IsValid(inv_messagemanager) then destroy inv_messagemanager end if if IsValid(inv_variablemanager) then destroy inv_variablemanager end if end event
- Sources
- EAF.NET
- eaf_servershared
- eaf_n_cst_objectservice.sru
File: eaf_n_cst_objectservice.sru
Size: 22343
Date: Tue, 22 Jan 2008 23:39:43 +0100
Size: 22343
Date: Tue, 22 Jan 2008 23:39:43 +0100
- n_cst_baseservice eaf_n_cst_objectservice(sru)
- addmessage (string as_messageid, long al_languageid, string as_message) returns long
- getenvironmentvariable (string as_name, ref string as_value) returns long
- getmessage (string as_messageid, ref string as_message) returns long
- getpbversion (ref integer ai_pbversion) returns long
- getvariable (string as_variablename, ref string as_variablevalue) returns long
- ismessagemanageravailable () returns boolean
- messageprepare (string as_messageid, ref string as_message) returns long
- messageprepare (string as_messageid, ref string as_message, string as_parameters[]) returns long
- setcomponentname (string as_componentname)
- setmessagemanager () returns long
- setmessagemanager (string as_name) returns long
- setvariable (string as_variablename, string as_variablevalue) returns long
- setvariablemanager (string as_name) returns long