Vous êtes sur la page 1sur 42

Function EP_LOGIN_POST_PRCS( BRANCH, OPTIONS )

*
* Author : WUR
* Purpose : Post Processes for EP_login windows. Currently, these are:
* : i. EP_ETHICAL_START
* : ii. EP_EMINENT_START
* :
* Date : 17-03-2007
* Modify : 05-09-2007, WUR, After implementing relational index between EMI_APP
and EMI_PROJ,
* :
now changing the logic of reading one Project/Company (from EMI_PROJ)
* :
and its related application (from EMI_APP).
* : 21-01-2008, WRU, Add functionality of i) Intruder
Locking, and ii) updating Login info
* :
in user_profile.
* : 20-04-2008, WUR, Add functionality of launching on
Default Entry Point
* :
Also show Window Title from EMI_PROJ's parameters
* : 27-04-2008, wur, Convert the logic to
Customer/User-based entry-point.
* : 25-10-2012, wur, Convert to SQL
*
*---------------------------- declaration -----------------------------
*
Declare Function Msg, Set_Property, Get_Property, Start_Window,
End_Window, Utility, CS_PRCS
Declare Function ATTACH_DB, EMI_SHOW_DETAIL_MSG,
GET_APP_PARAM, EMI_PROJ, USER_ACCESS_LOG, EMI_EXEC, CO_SETTINGS
Declare Function GetNetworkUserName, REV_UTILITY, USER_PROFILE,
ALERT, EMI_UTILITY
Declare Function APP_VER_HISTORY
Declare Subroutine Set_Property, FORWARD_EVENT, Send_Event, Msg, Rlist, YIELD,
Set_Status, WRITE_ROW
*
$Insert SETUP_COMMON_VARIABLES
$Insert LOGICAL
$Insert MSG_EQUATES
$Insert EMI_PROJ_EQUATES
$Insert USER_PROFILE_EQUATES
$Insert USER_INTRUDER_HISTORY_EQUATES
*
Equ UT_SUPER_USER$ To 'S' ;* System defined
USER_TYPES in USER_PROFILE
Equ UT_GOBAL_USER$ To 'G' ;* Global User
Equ UT_ENTERPRISE_USER$ To 'E'
Equ UT_ADMIN_USER$ To 'A'
Equ NO_CO_ID$ To '#'
Equ NO_BR_ID$ To '#'
*
Equ PROG_NAME$ To 'Login Process'
*
* ------------------------------ main --------------------------------
*
XMSG = '' ;* Prepare MSG variable
XMSG<MTEXT$> = ''
XMSG<MTYPE$> = 'BCancel'
XMSG<MCAPTION$>= PROG_NAME$
XMSG<MICON$> = '!' ;* Warning bitmap
*
RET_VALUE = True$
DO_ENCRYPT= FALSE$
*
Begin Case
Case ( BRANCH EQ 'CONTROLLER_CREATE' ) ; Goto
CONTROLLER_CREATE
*
Case ( BRANCH EQ 'CREATE' )
; Goto CREATE
Case ( BRANCH EQ 'COMBO_COMPANY_LOSTFOCUS' ) ; Goto COMBO_COMPANY_LOSTFOCUS
Case ( BRANCH EQ 'BTN_LOGIN_CLICK' ) ; Goto
BTN_LOGIN_CLICK
*
Case ( BRANCH EQ 'SWITCH_USER' ) ; Goto
OPEN_DEFAULT_LOGIN_SCREEN
Case Otherwise$
*
* display an error message
*
XMSG<MTEXT$>= '|"':BRANCH: '" is an unknown parameter received...|'
Msg( @Window, XMSG )
Set_Status( True$, XMSG<MTEXT$> )
End Case
*
STOP_RUN:
*
Return ''
*
* ------------------------- Internal Subroutines -----------------------------
*
CONTROLLER_CREATE:
*
ATTACH_STATUS= ATTACH_DB()
;* Attach Default + All related (application) volumes as defined in EMI_APP
*
If ( ATTACH_STATUS EQ ERR$ ) Then
ERR_TEXT = 'Error in connecting DB...'
*
Set_Property( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
Set_Property( @WINDOW: '.STATUSLINE', 'TEXT', ERR_TEXT )
Set_Property( @WINDOW: '.STATUSLINE', 'VISIBLE', TRUE$ )
Set_Property( @WINDOW: '.USERNAME', 'FOCUS' )
Return
End
*
* Since there is no error from ATTACH_DB(), therefore transfer the contents
* of ATTACH_STATUS to INI_INFO variable
*
INI_INFO = ATTACH_STATUS
ATTACH_STATUS= ''
*
If ATTACH_STATUS Then
XANS= END_WINDOW( @WINDOW )
Return
End
Gosub OPEN_DEFAULT_LOGIN_SCREEN
*
Return
*
!
OPEN_DEFAULT_LOGIN_SCREEN:
*
* Now switch to Login page for this EMI_PROJ@<PROJ_ID_POS$> Project (as defined in
EMI_PROJ table)
* This routine is also called for "Switch User"
*
If ( BRANCH EQ 'SWITCH_USER' ) then
*
* Perform this check only if "Switching to another user" is requested.
*
XMSG<MCAPTION$>= PROG_NAME$: '/Switch User'
XMSG<MTEXT$>= '|Caution! This will close all opened windows.||Please confirm
switching to another user...?|'
XMSG<MTYPE$>= 'BSwitch User,Cancel'
XMSG<MICON$>= '?' ;* Warning
bitmap
*
CONFIRM= Msg( @WINDOW, XMSG )
If ( CONFIRM NE '1' ) Then
Return ''
End
end
*
LOGIN_WIN_ID= GET_APP_PARAM( '', 'DEFAULT_LOGIN', '' ) ;* get name of window for User
Login
*
If ( LOGIN_WIN_ID EQ '' ) Then
XTEXT = 'Project ID: ': EMI_PROJ@<PROJ_ID_POS$>
XTEXT:= '|There is no "Login Page" defined for this project...|'
XTEXT:= '|(Please contact System Administrator for assistance...)'
*
XMSG<MTEXT$>= XTEXT
*
Set_Property( @WINDOW: '.STATUSLINE', XTEXT )
Msg( @WINDOW, XMSG )
Return ''
End
*
* Check whether User-based login window exists...
*
WINDOW_EXISTS= @APPID<1>: '**': LOGIN_WIN_ID
;* Set name of checking the window
WINDOW_EXISTS= XLATE( 'SYSREPOSWINEXES', WINDOW_EXISTS, '', 'X' )
*
IF ( WINDOW_EXISTS EQ '' ) THEN
XTEXT = '|An unknown Login Page "': LOGIN_WIN_ID: '"'
XTEXT:= '|is associated with "': EMI_PROJ@<PROJ_ID_POS$>: '" Project...|'
XTEXT:= '|System is switching to default login page.'
*
XMSG<MTEXT$>= XTEXT
*
Set_Property( @WINDOW: '.STATUSLINE', XTEXT )
MSG( @WINDOW, XMSG )
*
* now verify that project's default login page exist or not
*
LOGIN_WIN_ID = 'EP_DEFAULT_LOGIN'
;* System's default login page
WINDOW_EXISTS= @APPID<1>: '**': LOGIN_WIN_ID
WINDOW_EXISTS= XLATE( 'SYSREPOSWINEXES', WINDOW_EXISTS, '', 'X' )
END
*
IF ( WINDOW_EXISTS EQ '' ) THEN
XTEXT = '|System is unable to launch this application.'
XTEXT:= '|Default login Page "': LOGIN_WIN_ID: '" does not exist.'
*
XMSG<MTEXT$>= XTEXT
*
SET_PROPERTY( @WINDOW: '.STATUSLINE', XTEXT )
MSG( @WINDOW, XMSG )
Return ''
END
*
XANS = USER_ACCESS_LOG( 'CLOSE_SESSION', OPS_USER@ )
PARENT= Get_Property( @WINDOW, 'PARENT' ) ;* get the PARENT name before closing
the WINDOW
XANS = END_WINDOW( @WINDOW )
*
CREATE_PARAM= EMI_PROJ@<CAPTION_POS$>
XANS = START_WINDOW( LOGIN_WIN_ID, PARENT, CREATE_PARAM )
*
Return ''
*
!
CREATE:
*
Forward_Event( OPTIONS )
*
Gosub POPULATE_COMPANY_BRANCH
If LOGIN_ERR Then
Set_Property( @Window: '.BTN_LOGIN', 'ENABLED', DISABLE$ )
End
*
* Especially, when switching between EBA Companies, set the already logged-in user for next
login
*
DFLT_USERNAME= EBA_INFO@<1, 1>
DFLT_PASSWORD= OConv( EBA_INFO@<1, 2>, '[ENCRYPT_FORMAT]' )
DFLT_REM_ME = EMI_UTILITY( 'GET_LOCAL_SETTINGS', 'LAST_LOGIN_REMEMBER_ME' )
*
If ( DFLT_USERNAME EQ '' ) Then
DFLT_USERNAME= EMI_UTILITY( 'GET_LOCAL_SETTINGS', 'LAST_LOGIN_USER_ID' )
End
*
Set_Property( @WINDOW: '.USERNAME', 'DEFPROP', DFLT_USERNAME )
Set_Property( @WINDOW: '.PASSWORD', 'DEFPROP', DFLT_PASSWORD )
Set_Property( @Window: '.REMEMBER_ME', 'DEFPROP', DFLT_REM_ME )
*
* Tab sequence on the form is logical from top-bottom-left-right
* but purposefully, focus is being set to USERNAME so that user can just enter
username/password...
*
If ( DFLT_USERNAME EQ '' ) Then
Set_Property( @WINDOW: '.USERNAME', 'FOCUS', True$ )
End Else
Set_Property( @WINDOW: '.PASSWORD', 'FOCUS', True$ )
End
*
* arrange to show additional CAPTION as defined in Eminent.ini file
*
If ( EMI_PROJ@<CAPTION_POS$> NE '' ) Then
XTITLE = Get_Property( @WINDOW, 'TEXT' )
XTITLE:= ' ': EMI_PROJ@<CAPTION_POS$>
*
Set_Property( @WINDOW, 'TEXT', XTITLE )
End
*
XANS= APP_VER_HISTORY( 'GET_APP_REV_SHORT' )
Set_Property( @Window: '.APP_VER', 'DEFPROP', XANS )
*
Return
*
!
POPULATE_COMPANY_BRANCH:
*
/* -------------- OLD logic of reading Company & Branches directly From EMI_PROJ table
*
* Read all projects in EMI_PROJ and fill the "Company" and "Branch" dropdowns
*
Open 'EMI_PROJ' TO EP_TABLE Else
XMSG<MTEXT$>= '|Error: While opening "EMI_PROJ" table...|'
XMSG<MTEXT$>= EMI_SHOW_DETAIL_MSG( XMSG<MTEXT$> )
*
MSG( @WINDOW, XMSG )
Return
End
*
EOF = False$
EP_ID= ''
*
CO_ID_LIST = ''
CO_LIST = ''
BR_ID_LIST = ''
BR_PARENT_ID= ''
BR_LIST = ''
*
Select EP_TABLE
Loop
Readnext EP_ID ELSE EOF= TRUE$
Until EOF
Read EP_REC From EP_TABLE, EP_ID Then
*
WHICH_CO = EP_ID
THIS_DESCP= EP_REC<EMI_PROJ_CUST_NAME$>: ' (': EP_ID: ')'
*
If EP_REC<EMI_PROJ_IS_BRANCH$> Then
TTL_PARENT_CODE= DCOUNT( EP_REC<EMI_PROJ_PARENT_CODE$>,
@VM )
*
For PI= 1 To TTL_PARENT_CODE
If ( EP_REC<EMI_PROJ_PARENT_CODE$, PI> EQ EMI_PROJ@<1>
) Then
IF EP_REC<EMI_PROJ_IS_DEFAULT_BRANCH$> Then
THIS_DESCP=
EP_REC<EMI_PROJ_IS_DEFAULT_BRANCH$>: '.': THIS_DESCP
End
If ( THIS_DESCP EQ '' ) Then
THIS_DESCP= 'Error! Branch not defined.'
End
*
* Populate Branch's combobox
*
Locate THIS_DESCP IN BR_LIST BY 'AL' USING @FM
SETTING POS ELSE NULL
*
BR_ID_LIST = Insert( BR_ID_LIST, POS, 0, 0, EP_ID )
BR_PARENT_ID= Insert( BR_PARENT_ID, POS, 0, 0,
EP_REC<EMI_PROJ_PARENT_CODE$, PI> )
BR_LIST = Insert( BR_LIST, POS, 0, 0, THIS_DESCP )
End
Next PI
End Else
*
* Populate Company's combobox
*
If ( EP_ID EQ EMI_PROJ@<1> ) Then
Locate THIS_DESCP In CO_LIST BY 'AL' USING @FM SETTING POS
Else NULL
*
CO_ID_LIST= Insert( CO_ID_LIST, POS, 0, 0, EP_ID )
CO_LIST = Insert( CO_LIST, POS, 0, 0, THIS_DESCP )
End
End
End
Repeat
*
ALL_BRANCHES= ''
TTL_BR = DCount( BR_ID_LIST, @FM )
*
For I= 1 To TTL_BR
THIS_BR= BR_ID_LIST<I>
*
ALL_BRANCHES<I, 1>= BR_ID_LIST<I>
ALL_BRANCHES<I, 2>= BR_LIST<I>
ALL_BRANCHES<I, 3>= BR_PARENT_ID<I>
Next I
*
---------------------------------------------------------*/
*
Set_Property( @Window: '.STATUSLINE', 'DEFPROP', 'Searching for Branches...' )
LOGIN_ERR = False$
PROJ_ID = EMI_PROJ@<PROJ_ID_POS$>
PROJ_REC = CO_REC@
CO_ID_LIST = PROJ_ID
CO_LIST = PROJ_REC<EMI_PROJ_CUST_NAME$>: ' (': PROJ_ID: ')'
BR_ID_LIST = ''
BR_PARENT_ID= ''
BR_LIST = ''
ALL_BRANCHES= ''
DFLT_BRANCH = EMI_PROJ@<WORKSTATION_POS$>
;* it was basically defined in eminent.ini
TEMP_BR_IDS = ''
*
*TEMP_BR_IDS = EMI_PROJ( 'GET_BRANCH_IDS', PROJ_ID )
If ( DFLT_BRANCH EQ '' ) THEN
TEMP_BR_IDS= EMI_EXEC( 'CS:EMI_PROJ', 'GET_BRANCH_IDS', PROJ_ID )
End Else
TEMP_BR_IDS= DFLT_BRANCH
End
*
TTL_BR= DCount( TEMP_BR_IDS, @FM )
XANS = TEMP_BR_IDS
Convert @FM To @VM In XANS

EMI_PROJ@<BRANCH_IDS$>= XANS
;* IDs of valid Branches of this company
*
For I= 1 To TTL_BR
YIELD()
*
BR_ID = TEMP_BR_IDS<I>
*BR_REC= EMI_PROJ( 'GET_BRANCH_REC', PROJ_ID, BR_ID )
BR_REC= EMI_EXEC( 'CS:EMI_PROJ', 'GET_BRANCH_REC', PROJ_ID, BR_ID )
If ( BR_REC EQ '' ) Then
XMSG<MTEXT$>= '|An unknown Branch (': BR_ID: ') is set for this terminal...|'
XMSG<MTEXT$>= XMSG<MTEXT$>: '|Unable to log into the system!|'
Msg( @Window, XMSG )
LOGIN_ERR= True$
End
*
THIS_DESCP = BR_REC<EMI_PROJ_CUST_NAME$>: ' (': BR_ID: ')'
TTL_PARENT_CODE= DCOUNT( BR_REC<EMI_PROJ_PARENT_CODE$>, @VM )
*
For PI= 1 To TTL_PARENT_CODE
If ( BR_REC<EMI_PROJ_PARENT_CODE$, PI> EQ PROJ_ID ) Then
If BR_REC<EMI_PROJ_IS_DEFAULT_BRANCH$> Then
THIS_DESCP= BR_REC<EMI_PROJ_IS_DEFAULT_BRANCH$>: '.':
THIS_DESCP
End
If ( THIS_DESCP EQ '' ) Then
THIS_DESCP= 'Error! Branch not defined.'
End
*
* Populate Branch's combobox
*
Locate THIS_DESCP IN BR_LIST BY 'AL' USING @FM SETTING POS Else
NULL
*
BR_ID_LIST = Insert( BR_ID_LIST, POS, 0, 0, BR_ID )
BR_PARENT_ID= Insert( BR_PARENT_ID, POS, 0, 0,
BR_REC<EMI_PROJ_PARENT_CODE$, PI> )
BR_LIST = Insert( BR_LIST, POS, 0, 0, THIS_DESCP )
End
Next PI
Next I
*
For I= 1 To TTL_BR
ALL_BRANCHES<I, 1>= BR_ID_LIST<I>
ALL_BRANCHES<I, 2>= BR_LIST<I>
ALL_BRANCHES<I, 3>= BR_PARENT_ID<I>
Next I
*
* Display license information
*
COPYRIGHT = 'This copy of software is licensed to:'
COPYRIGHT:= CR_LF$
*
If PROJ_REC<EMI_PROJ_CUST_NAME$> Then COPYRIGHT:= CR_LF$:
PROJ_REC<EMI_PROJ_CUST_NAME$>
If PROJ_REC<EMI_PROJ_ADDRESS$> Then COPYRIGHT:= CR_LF$:
PROJ_REC<EMI_PROJ_ADDRESS$>
If PROJ_REC<EMI_PROJ_CITY$> Then COPYRIGHT:= CR_LF$: PROJ_REC<EMI_PROJ_CITY$>
If PROJ_REC<EMI_PROJ_COUNTRY$> Then COPYRIGHT:= ', ':
PROJ_REC<EMI_PROJ_COUNTRY$>
*
COPYRIGHT:= CR_LF$
COPYRIGHT:= CR_LF$: 'Copyright 2008-2009 Eminent Technologies.'
COPYRIGHT:= CR_LF$: 'All rights reserved.'
COPYRIGHT:= CR_LF$: 'Warning: The use of this software is subject to a license agreement and is
also'
COPYRIGHT:= ' subject to copyright and/or other laws. Unauthorized reproduction or
distribution'
COPYRIGHT:= ' of this software, or any portion of it, may result in severe civil and criminal'
COPYRIGHT:= ' penalities, and will be prosecuted to the maximum extent possible under the
law.'
Swap @VM With CR_LF$ In COPYRIGHT
*
* Populate values in the controls on screen
*
Set_Property( @WINDOW: '.COPYRIGHT', 'DEFPROP', COPYRIGHT )
Set_Property( @WINDOW: '.COMBO_COMPANY', 'LIST', CO_LIST )
Set_Property( @WINDOW: '.COMBO_COMPANY', 'DEFPROP', CO_LIST<1, 1> )
Set_Property( @WINDOW: '.COMBO_BRANCH', 'LIST', BR_LIST )
*
If TTL_BR Then
Set_Property( @WINDOW: '.COMBO_BRANCH', 'VISIBLE', True$ )
Set_Property( @WINDOW: '.BRANCH_LABEL', 'VISIBLE', True$ )
End Else
Set_Property( @WINDOW: '.COMBO_BRANCH', 'VISIBLE', False$ )
Set_Property( @WINDOW: '.BRANCH_LABEL', 'VISIBLE', False$ )
End
If ( TTL_BR LE 1 ) Then
* The following Combobox control is setting to ReadOnly usin REV_UTILITY (API)
* because OI's READONLY does not work with Combobox dropdown controls
*
XANS= Rev_Utility( 'SETREADONLY', (@WINDOW: '.COMBO_BRANCH'), True$ )
End
*
Swap @FM With @VM IN CO_LIST
Swap @FM With @VM IN CO_ID_LIST
*
ALL_CO = ''
ALL_CO<1> = CO_ID_LIST
ALL_CO<2> = CO_LIST
*
Set_Property( @Window: '.STATUSLINE', 'DEFPROP', '' )
Set_Property( @WINDOW: '.COMBO_COMPANY', '@BRANCH_LIST', ALL_BRANCHES )
;* store list of all Branches in user-defined property
Set_Property( @WINDOW: '.COMBO_COMPANY', '@CO_LIST', ALL_CO )
;* store list of all Branches in user-defined property
SEND_EVENT( @WINDOW: '.COMBO_COMPANY', 'LOSTFOCUS' )
*
Return ''
*
!
COMBO_COMPANY_LOSTFOCUS:
*
THIS_CO_POS = Get_Property( @Window: '.COMBO_COMPANY', 'SELPOS' )
THIS_CO_NAME = Get_Property( @Window: '.COMBO_COMPANY', 'TEXT' )
THIS_CO_ID = Get_Property( @Window: '.COMBO_COMPANY', '@CO_LIST' )
THIS_CO_ID = THIS_CO_ID<1, THIS_CO_POS>
ALL_BRANCHES = Get_Property( @Window: '.COMBO_COMPANY', '@BRANCH_LIST' )
LAST_LOGIN_BRANCH= OPS_Branch_ID@
DFLT_BRANCH = ''
FRESH_BR_LIST = ''
*
TTL_BR= DCount( ALL_BRANCHES, @FM )
*
If ( LAST_LOGIN_BRANCH EQ '' ) Then
LAST_LOGIN_BRANCH= EMI_UTILITY( 'GET_LOCAL_SETTINGS',
'LAST_LOGIN_BRANCH_ID' )
End
*
For I= 1 To TTL_BR
X= ALL_BRANCHES<I, 3>
Y= THIS_CO_POS
*
If ( ALL_BRANCHES<I, 3> EQ THIS_CO_ID ) Then
FRESH_BR_LIST<-1>= ALL_BRANCHES<I, 2>
End
If ( ALL_BRANCHES<I, 1> EQ LAST_LOGIN_BRANCH ) Then
DFLT_BRANCH= TRIMF( TRIMB( ALL_BRANCHES<I, 2> ) )
End
Next I
*
Set_Property( @Window: '.COMBO_BRANCH', 'LIST', FRESH_BR_LIST )
Set_Property( @WINDOW: '.COMBO_BRANCH', 'DEFPROP', DFLT_BRANCH )
*
Return ''
*
!
BTN_LOGIN_CLICK:
*
Set_Property( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', False$ )
Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
*
ERR_TEXT = ''
UP_ID = TRIM( Get_Property( @Window: '.USERNAME', 'DEFPROP' ) )
ORIG_UP_ID = UP_ID
XPASS = Get_Property( @Window: '.PASSWORD', 'DEFPROP' )
XREMEMBER_ME= Get_Property( @Window: '.REMEMBER_ME', 'DEFPROP' )
PARENT = Get_Property( @Window, 'PARENT' )
CURR_FOCUS = Get_Property( @WINDOW, 'FOCUS' )
*
XANS= IConv( XPASS, '[ENCRYPT_FORMAT]' )
EBA_INFO@<1, 1>= UP_ID
EBA_INFO@<1, 2>= XANS
*
* read Co_Id from Login screen
*
THIS_CO_ID = NO_CO_ID$
THIS_CO_POS= Get_Property( @Window: '.COMBO_COMPANY', 'SELPOS' )
CO_LIST = Get_Property( @Window: '.COMBO_COMPANY', '@CO_LIST' ) ;* Read
company list from user-defined property @Co_List
*
If ( CO_LIST<1, THIS_CO_POS> NE '' ) Then
THIS_CO_ID= CO_LIST<1, THIS_CO_POS>
End
*
* read Branch_id from login screen
*
THIS_BR_ID= NO_BR_ID$
THIS_BR = Get_Property( @Window: '.COMBO_BRANCH', 'DEFPROP' )
BR_LIST = Get_Property( @Window: '.COMBO_COMPANY', '@BRANCH_LIST' )
TTL_BR = DCount( BR_LIST, @FM )
*
If TTL_BR Then
If ( THIS_BR EQ '' ) Then
THIS_BR_ID = BR_LIST<1, 1>
XMSG<MTEXT$>= '|You are being logged into the default Branch "': BR_LIST<1,
1>: ' (': THIS_BR_ID: ')"...||Because you have forgot to select it.'
XMSG<MTYPE$>= 'BO'
Msg( @Window, XMSG )
End
End
For I = 1 To TTL_BR
If ( BR_LIST<I, 2> EQ THIS_BR ) Then
THIS_BR_ID= BR_LIST<I, 1> ;* Using the Branch Name, find & assign
the Branch ID
End
Next I
*
If ( UP_ID EQ '' ) Then
ERR_TEXT= '"User ID" is missing...'
*
Set_Property( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', True$ )
Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
Set_Property( @Window: '.USERNAMe', 'FOCUS', True$ )
*
RET_VALUE= False$
Return
End
*
UP_REC = ''
REMOTE_ID= ( UP_ID[1, 1] EQ '.' ) Or ( UP_ID[1, 1] EQ '$' )
*
If REMOTE_ID Then
REMOTE_TYPE= UP_ID[1, 1]
DRIVE_LTR = UP_ID[2, 1]
UP_ID = TRIM( UP_ID[3, 255] )
REMOTE_FILE= UP_ID
;* initialize this variable with plain UP_ID value
*
If ( REMOTE_TYPE EQ '.' ) Then
REMOTE_FILE= DRIVE_LTR: ':\': UP_ID: '.LIC'
End
If ( REMOTE_TYPE EQ '$' ) Then
If ( DRIVE_LTR EQ '/' ) Then
REMOTE_FILE= 'C:\WINDOWS\': UP_ID: '.LIC'
End
If ( DRIVE_LTR EQ '\' ) Then
REMOTE_FILE= 'D:\WINDOWS\': UP_ID: '.LIC'
End
End
*
OSRead UP_REC From REMOTE_FILE Then
UP_REC= OCONV( UP_REC, '[ENCRYPT_FORMAT, ': ENCRYPT_KEY$: ']' )
End Else
UP_REC= ''
End
End Else
*UP_REC= EMI_EXEC( 'CS:XLATE', 'USER_PROFILE', UP_ID, '', 'X' )
QUERY_SENT = "SELECT ID, DESCP, PASSWORD, USER_TYPE, INACTIVE, USER_ROLE_ID,
LAUNCH_STYLE "
QUERY_SENT:= "FROM USER_PROFILE "
QUERY_SENT:= "WHERE ID = '": UP_ID: "' "
*
UP_REC= CS_PRCS( 'QUERY', QUERY_SENT, '' )

*Open 'USER_PROFILE' To UP_TABLE Else
* ERR_TEXT= '"USER_PROFILE" is not available...'
* *
* SET_PROPERTY( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
* Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
* Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
* Set_Property( @Window: '.USERNAME', 'FOCUS', True$ )
* *
* Return
*End
**
*UP_REC= ''
*READ UP_REC FROM UP_TABLE, UP_ID ELSE
* ERR_TEXT= "Unknown user..."
* *
* SET_PROPERTY( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
* Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
* Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
* Set_Property( @Window: '.USERNAME', 'FOCUS', True$ )
* *
* Return
*End
End
If ( UP_REC EQ '' ) THEN
ERR_TEXT= 'Unknown user...'
*
Gosub RECORD_INTRUDER_ATTEMPT
*
SET_PROPERTY( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
Set_Property( @Window: '.USERNAME', 'FOCUS', True$ )
*
Return
End
*
* Now decrypt password for further checking...
*
UP_DESCP = UP_REC<2>
UP_PASSWORD = UP_REC<3>
UP_USER_TYPE = UP_REC<4>
UP_INACTIVE = UP_REC<5>
UP_USER_ROLE_ID= UP_REC<6>
UP_LAUNCH_STYLE= UP_REC<7>
*
If DO_ENCRYPT Then
UP_PASSWORD= OConv( UP_PASSWORD, '[ENCRYPT_FORMAT, ': ENCRYPT_KEY$: ']' )
End
*
If ( XPASS _NEC UP_PASSWORD ) Then
If ( UP_PASSWORD NE '' ) Then
ERR_TEXT= 'Password is required...'
End
If ( UP_PASSWORD NE '' ) And ( XPASS NE '' ) Then
ERR_TEXT= 'Invalid password entered...'
*
Gosub RECORD_INTRUDER_ATTEMPT
End
*
Set_Property( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
Set_Property( @Window: '.PASSWORD', 'SELECTION', (1:@FM:999) )
Set_Property( @Window: '.PASSWORD', 'FOCUS', True$ )
*
Return
End
*
If ( UP_USER_TYPE NE UT_SUPER_USER$ ) Then
*
* check if user's account has been expired
*
*If ( UP_REC<UP_DATE_OF_EXPIRY$> NE '' ) Then
* If ( DATE() GE UP_REC<UP_DATE_OF_EXPIRY$> ) Then
* Msg( '', '|User account has been expired,|Please contact system
Adminstrator for details...|' )
* *
* ERR_TEXT= "User account has been expired"
* *
* SET_PROPERTY( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
* Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
* Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
* Set_Property( @Window: '.USERNAME', 'FOCUS', True$ )
* *
* Return
* End
*End
*
* check if user is marked "inactive"
*
If UP_INACTIVE Then
*
* if still active, then check
*
*If ( DATE() GE UP_REC<UP_INACTIVE_FROM$> ) Then
X= Msg( '', '|User is temporarely marked as Inactive,|Please contact
system Adminstrator for details...|' )
*
ERR_TEXT= "User is temporarely marked as Inactive"
*
SET_PROPERTY( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
Set_Property( @Window: '.USERNAME', 'FOCUS', True$ )
*
Return
*End
*If ( DATE() LE UP_REC<UP_INACTIVE_TO$> ) Then
* X= Msg( '', '|User is temporarely marked as Inactive,|Please contact
system Adminstrator for details...|' )
* *
* ERR_TEXT= 'This User is temporarely marked as Inactive'
* *
* SET_PROPERTY( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
* Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
* Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
* Set_Property( @Window: '.USERNAME', 'FOCUS', True$ )
* *
* Return
*End
End
End
Set_Property( @Window: '.USERNAME', 'FOCUS', False$ )
*
* 24-07-2009, also preserve other branches of same company for later use
* Note that, EMI_PROJ<1> and <2> has already been initialized in ATTACH_DB()
*
/* ------- NO NEED To MAINTAIN EMI_PROJ@<3> --------------
**GROUP_CO= XLATE( 'EMI_PROJ', EMI_PROJ@<1>, 'PARENT_CODE', 'X' )
GROUP_CO= CO_REC@<EMI_PROJ_PARENT_CODE$>
*
IF ( GROUP_CO NE '' ) THEN
SENTENCE= 'SELECT EMI_PROJ WITH PARENT_CODE EQ "': GROUP_CO: '" BY @ID '
RList( SENTENCE, 4, 'XXX', '', '' ) ;*
4=Save result in SAVELIST, i.e, XXX
*
XANS= XLATE( 'SYSLISTS', 'XXX', '', 'X' )
XANS= Delete( XANS, 1, 0, 0 )
;* Remove first row which contains just date/time by system
CONVERT @FM TO @VM IN XANS
EMI_PROJ@<3>= XANS
;* Save the IDs of other companies in the group
END
*
ClearSelect
CALL Delete_Save_Select( 'XXX' )
----------------------------------------------------*/
*
/* --- No need To maintain it here -----------------
It is already initialized when Combo values are filled In BRANCH

SENTENCE= 'SELECT EMI_PROJ WITH IS_BRANCH AND WITH PARENT_CODE [] "':
EMI_PROJ@<1>: '" BY @ID '
RList( SENTENCE, 4, 'XXX', '', '' ) ;*
4=Save result in SAVELIST, i.e, XXX
*
XANS= Xlate( 'SYSLISTS', 'XXX', '', 'X' )
XANS= Delete( XANS, 1, 0, 0 )
;* Remove first row which contains just date/time by system
Convert @FM TO @VM IN XANS
*
Locate THIS_BR_ID In XANS USING @VM SETTING POS Then
XANS= Delete( XANS, 1, POS, 0 )
XANS= Insert( XANS, 1, 1, 0, THIS_BR_ID ) ;* Make sure
current branch is at first position
End
EMI_PROJ@<4>= XANS
;* Save the IDs of related Branches of selected company
-----------------------------------------------------*/
*
* -----------
* set application independent /common/ variables
* -----------
*
*USER_INFO = ''
*USER_INFO<1>= UP_ID
*USER_INFO<2>= UP_REC<UP_NAME$>
*USER_INFO<3>= UP_REC<UP_USER_TYPE$>
*USER_INFO<4>= THIS_CO_ID
*USER_INFO<5>= THIS_BR_ID
*
UR_ID = UP_USER_ROLE_ID
UR_REC= EMI_EXEC( 'CS:XLATE', 'USER_ROLE', UR_ID, '', 'X' )
*
USER_INFO = UP_ID
;* 18-03-2010, To extend the use of Common Variables, changing these
4-variables
USER_INFO:= @RM: UP_REC
;* USER PROFILE record
USER_INFO:= @RM: UR_REC
;* USER ROLE record
USER_INFO:= @RM: THIS_CO_ID
USER_INFO:= @RM: THIS_BR_ID
**
** Initialize @recur0 system variable. This system global variable is required to be used in
** symbolic formulas too.
**
*@RECUR0 = ''
*@RECUR0<1>= THIS_CO_ID
*@RECUR0<2>= THIS_BR_ID
*@RECUR0<3>= UP_REC<UP_USER_TYPE$>
*
XANS= EMI_PROJ( 'CONFIG_USER', USER_INFO )
XANS= EMI_PROJ( 'CONFIG_FAS' )
XANS= EMI_PROJ( 'CONFIG_BRANCH' )
*
XANS= EMI_PROJ( 'CONFIG_WORKSTATION' ) ;* 28-1-2012, To initialize
OPS_WS_ID@ and OPS_WS_REC@ common variables
If ( XANS<1> EQ ERR$ ) Then
Set_Property( @WINDOW: '.BITMAP_ERROR', 'VISIBLE', TRUE$ )
Set_Property( @Window: '.STATUSLINE', 'TEXT', ERR_TEXT )
Set_Property( @Window: '.STATUSLINE', 'VISIBLE', True$ )
Set_Property( @Window: '.PASSWORD', 'SELECTION', (1:@FM:999) )
Set_Property( @Window: '.PASSWORD', 'FOCUS', True$ )
*
Return
End
*
* Now update current login information "LAST_LOGIN_INFO" to this User Profile
* as follows:
* <1, 1> Last login machine name (@STATION)
* <1, 2> last login date (DATE())
* <1, 3> last login time (time())
*
UP_LAST_LOGIN_INFO= UP_REC<UP_LAST_LOGIN_INFO$>
*
XANS = @STATION: @SVM: DATE(): @SVM: TIME()
MAX_ENTRIES= 5
UP_REC = Insert( UP_REC, UP_LAST_LOGIN_INFO$, 1, 0, XANS )
*
TTL_ENTRIES= DCount( UP_REC<UP_LAST_LOGIN_INFO$>, @VM )
TTL_ENTRIES= (TTL_ENTRIES - 1)
;* just, preserve first (Record Creation) entry
*
For I= TTL_ENTRIES To MAX_ENTRIES STEP -1
UP_REC= Delete( UP_REC, UP_LAST_LOGIN_INFO$, I, 0 )
Next I
*
If Not( REMOTE_ID ) Then
XANS= EMI_EXEC( 'CS:USER_PROFILE', 'UPDATE_REC', UP_ID, UP_REC )
End
*
* Store current login information to LocalSettings file
*
LS_INFO= ''
*
If XREMEMBER_ME Then
LS_INFO<1>= 'LAST_LOGIN_USER_ID' : @VM: ORIG_UP_ID
LS_INFO<2>= 'LAST_LOGIN_PROJ_ID' : @VM: EMI_PROJ@<PROJ_ID_POS$>
LS_INFO<3>= 'LAST_LOGIN_REMEMBER_ME': @VM: XREMEMBER_ME
LS_INFO<4>= 'LAST_LOGIN_BRANCH_ID' : @VM: THIS_BR_ID
End Else
LS_INFO<1>= 'LAST_LOGIN_USER_ID' : @VM: ''
LS_INFO<2>= 'LAST_LOGIN_PROJ_ID' : @VM: ''
LS_INFO<3>= 'LAST_LOGIN_REMEMBER_ME': @VM: XREMEMBER_ME
;* Always save it for next session
LS_INFO<4>= 'LAST_LOGIN_BRANCH_ID' : @VM: ''
End
*
XANS= EMI_UTILITY( 'SET_LOCAL_SETTINGS', LS_INFO )
*
* -----------
* now all checks have been passed successfully,
* therefore, system is transferring the control to "Launch Option"
* Launch Priority 1 = User's Launch Option
* 2 = Application Module's Launch Option
* 3 = Eminent's Launch Option
* -----------
*
* Special 'Launch style' checking for Super Users
*
WINDOW_ID = UP_LAUNCH_STYLE
STARTUP_PAGE= '' ;* UP_REC<UP_LAUNCH_STYLE$, 2>
CREATE_PARAM= 'STARTUP=': STARTUP_PAGE
*
If ( WINDOW_ID EQ '' ) Then WINDOW_ID= 'EP_SN_FULL'
*
If ( UP_REC<UP_USER_TYPE$> EQ UT_SUPER_USER$ ) Then
X= End_Window( @Window )
Gosub CHECK_FOR_WINDOW
*
If ( WINDOW_ID EQ '' ) Then
WINDOW_ID= 'EP_EBA_CONFIG'
End
X= Start_Window( WINDOW_ID, PARENT, CREATE_PARAM )
*
End Else
If ( WINDOW_ID EQ '' ) Then
*
* Since there is no Launch Style is defined for this user,
* therefore search "Default Entry Point" defined at company level
*
WINDOW_ID = GET_APP_PARAM( '', 'DEFAULT_ENTRY_POINT', '' )
STARTUP_PAGE= GET_APP_PARAM( '', 'DEFAULT_STARTUP_PAGE', '' )
*
WINDOW_ID = WINDOW_ID<1, 1>
STARTUP_PAGE= STARTUP_PAGE<1, 1>
CREATE_PARAM= 'STARTUP=': STARTUP_PAGE
End
Gosub CHECK_FOR_WINDOW
;* Check if Window exist
*
If ( WINDOW_ID EQ '' ) Then
XX = 'There is no "Launch Style" defined for this user...|'
XX:= '|(Please contact System Administrator for assistance...)'
XX = Msg( '', XX )
*
Set_Property( @Window: '.USERNAME', 'FOCUS', True$ )
Return
End
*
X= End_Window( @Window )
X= Start_Window( WINDOW_ID, PARENT, CREATE_PARAM )
*** giving problem after client/server X= EMI_EXEC( WINDOW_ID, PARENT,
CREATE_PARAM )
End
*XANS= USER_ACCESS_LOG( 'CREATE_SESSION', UP_ID )
*XANS= EMI_EXEC( 'CS:USER_ACCESS_LOG', 'CREATE_SESSION', UP_ID )
*
XANS= GET_APP_PARAM( '', 'ENABLE_GL_MODULE' )
If XANS Then
XANS= GET_APP_PARAM( 'CHECK_GL_INTERFACE' )
End
*
Return
*
!
RECORD_INTRUDER_ATTEMPT:
*
ENABLE_INTRUDER_LOCKING= GET_APP_PARAM( '', 'ENABLE_INTRUDER_LOCKING' )
If Not( ENABLE_INTRUDER_LOCKING ) Then Return
*
LOGIN_ATTEMPTS = Get_Property( @Window: '.LOGIN_ATTEMPTS', 'DEFPROP' )
INTRUDER_USER_CNT= Get_Property( @Window: '.INTRUDER_USER_CNT', 'DEFPROP' )
USER_ID_POS = 1
USER_CNT_POS = 2
INTRUDER_TYPE = ''
*
USER_LIMIT = USER_PROFILE( 'INTRUDER_USER_LIMIT', UP_ID, UP_REC )
WORKSTATION_LIMIT= GET_APP_PARAM( '', 'INTRUDER_WORKSTATION_LIMIT' )
*
If ( USER_LIMIT LE 0 ) Then
USER_LIMIT= GET_APP_PARAM( '', 'INTRUDER_USER_LIMIT' ) ;* Get company
level intruder limit
End
*
LOGIN_ATTEMPTS<1, -1>= UP_ID: ', ': XPASS: ', ': OConv( TIME(), 'MTHS' )
TTL_LOGIN_ATTEMPTS = DCount( LOGIN_ATTEMPTS, @VM )
*
* Check for Intruder User
*
Locate UP_ID In INTRUDER_USER_CNT<USER_ID_POS> USING @VM SETTING POS Then
INTRUDER_USER_CNT<USER_CNT_POS, POS>= INTRUDER_USER_CNT<USER_CNT_POS,
POS> + 1
*
If ( INTRUDER_USER_CNT<USER_CNT_POS, POS> GT USER_LIMIT ) Then
ERR_TEXT= 'User login attempts exceeded...'
*Set_Property( @Window: '.STATUSLINE', 'DEFPROP', ERR_TEXT )
*
INTRUDER_TYPE= 'U'
End
End Else
INTRUDER_USER_CNT= Insert( INTRUDER_USER_CNT, USER_ID_POS, POS, 0, UP_ID
)
INTRUDER_USER_CNT= Insert( INTRUDER_USER_CNT, USER_CNT_POS, POS, 0, 1 )
End
*
* Check for workstation limit
*
If ( TTL_LOGIN_ATTEMPTS GT WORKSTATION_LIMIT ) Then
ERR_TEXT= 'Workstation login attempts exceeded...'
*Set_Property( @Window: '.STATUSLINE', 'DEFPROP', ERR_TEXT )
*
INTRUDER_TYPE= 'W'
End
*
Set_Property( @Window: '.INTRUDER_USER_CNT', 'DEFPROP', INTRUDER_USER_CNT )
Set_Property( @Window: '.LOGIN_ATTEMPTS', 'DEFPROP', LOGIN_ATTEMPTS )
*
* Finally record intruder information
*
If ( INTRUDER_TYPE NE '' ) Then
XUSER_CNT= INTRUDER_USER_CNT
Swap @VM With ', ' In XUSER_CNT
Convert @FM To @VM In XUSER_CNT
*
UIH_REC = ''
UIH_REC<UIH_INTRUDER_TYPE$> = INTRUDER_TYPE
;* User/Workstation
UIH_REC<UIH_USER_ID$> = UP_ID
UIH_REC<UIH_DATE$> = DATE()
UIH_REC<UIH_TIME$> = TIME()
UIH_REC<UIH_LOGIN_ATTEMPTS$>= LOGIN_ATTEMPTS
UIH_REC<UIH_USERS_CNT$> = XUSER_CNT
UIH_REC<UIH_COMPUTER_NAME$> = @STATION: '/': GetNetworkUserName()
*
UIH_ID= Xlate( 'DICT.USER_INTRUDER_HISTORY', '%SK%', '', 'X' )
*
If ( UIH_ID EQ '' ) Then UIH_ID= 0
If Not( Num( UIH_ID ) ) Then UIH_ID= 0
*
NEXT_UIH_REC:
*
UIH_ID+= 1
XANS = Xlate( 'USER_INTRUDER_HISTORY', UIH_ID, '', 'X' )
If ( XANS NE '' ) Then Goto NEXT_UIH_REC
*
WRITE_ROW( 'USER_INTRUDER_HISTORY', UIH_ID, UIH_REC, 2 )
WRITE_ROW( 'DICT.USER_INTRUDER_HISTORY', '%SK%', UIH_ID, 2 )
*
If ( INTRUDER_TYPE EQ 'U' ) Then
If Not( REMOTE_ID ) Then
If ( UP_REC NE '' ) Then
UP_REC<UP_INTRUDER_BLOCK$>= UIH_ID
*
WRITE_ROW( 'USER_PROFILE', UP_ID, UP_REC, 2 )
End
End
End
*
XANS= ALERT( 'EXECUTE_EVENT', 'OPS_INTRUDER_LOGIN' )
;* Call EBA EVENT that will further call appropriate ALERT
End
*
Return
*
!
CHECK_FOR_WINDOW:
*
XID = @APPID<1>: '**': WINDOW_ID
WINDOW_EXISTS= Xlate( 'SYSREPOSWINEXES', XID, '', 'X' )
*
If ( WINDOW_EXISTS EQ '' ) Then
XX = '|An unknown Launch Style: "': WINDOW_ID: '" is associated with this user...|'
XX:= '|': UP_ID: ' (': UP_REC<UP_NAME$>: ') can not log into the application'
XX:= '|(Please see User Profile for details...)'
XX = MSG( '', XX )
*
Set_Property( @Window: '.USERNAME', 'FOCUS', True$ )
WINDOW_ID= ''
End
*
Return
*
!
INTRUDER_LOG:
*
INTRUDER_SK = Get_Property( @Window: '.INTRUDER_SK', 'DEFPROP' )
USER_SK = INTRUDER_SK<1>
WORKSTATION_SK= INTRUDER_SK<2>
*
If Not( Num( USER_SK ) ) Then USER_SK = 0
If Not( Num( WORKSTATION_SK ) ) Then WORKSTATION_SK= 0
*
*
Return
*
*

* ------------------------ end of program --------------------------