Overview: We now have many routines that set locks on the data, but we don’t have any calls to tell the DB when to release these locks. We need to add calls to the database specifying when some transaction that was displayed in an editable fashion is now off the screen.
There are multiple types of lock we have to notify the DB to release.
- LOGIN
- PROFILE
- CART
- CUSTOMER
Each of those locks has certain places to be released.
- LOGIN – When the user leaves the site or clicks the logout button. Actually in those situations we will release all locks because the session has essentially ended.
- PROFILE – When the user leaves the My Account area of the site.
- CART – Either when the user selects a different cart (already handled in the database side) or when leaving the site.
- CUSTOMER – When they are no longer editing a customer in MY Account Area.
Process:
- Create UtilityService method for releasing various locks.
- Name: ReleaseLock
- Input Params:
- LockType – String – PROFILE, CART, CUSTOMER, ALL
- LockID – String – CartName if type is Cart, CustNbr if type = Customer,
- BaseParameters
- Return Value:
- Success Flag – Boolean
- DB Call:
- RoutineName: RPC$UTILITY_RELEASELOCK
- Input Params:
- LOCK.TYPE – String – LockType from parameters
- LOCK.ID
- Return Params
- SERVER.STATUS
- ERROR.MSG
- ERROR.CODE
- On main layout add a JQuery handler for window.onbeforeunload to do an AJAX post to the new UtilityService method passing ALL for lockType. No matter what the return is, do not return any string.
- Add an onClick handler to the Logo to AJAX post to the new service method passing PROFILE as the lockType.
- Note: This approach should release all locks when the user leaves the site, and release the profile lock when they leave the profile area to go back to the tab area.