Forcing to unlock a record

Forcing to unlock a record

Postby driessen » Wed Nov 16, 2022 3:36 pm

Hello,

If a record is locked by someone else, is there a possibility that this record can unlocked by another user?

Thank you.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Forcing to unlock a record

Postby karinha » Wed Nov 16, 2022 4:08 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Forcing to unlock a record

Postby hmpaquito » Wed Nov 16, 2022 4:23 pm

My thoughts:

Each lock is associated with a workarea. Each workarea is managed by the terminal or session of each user.

Perhaps ADS could because it is a client/server system.

But I think Harbor can't do that.

I have needed it on some occasion and I have not been able to do it

regards
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Forcing to unlock a record

Postby James Bott » Wed Nov 16, 2022 4:47 pm

Michel,

I would think that would become a nightmare. What is the reason that you want to do this?

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Forcing to unlock a record

Postby driessen » Wed Nov 16, 2022 5:27 pm

James,

I agree that this could lead to drama's.

But I have a reason.

I have customers who use my application in a remote desktop environment.
Sometimes they just close the session without login out.
So the session stays active, the files opened and the records locked.

They start a new RDP-session, launch my application and then discover that some records still are locked.
Of course, then I got a phonecall to help them out of the problem.

Since I don't have access to the server, I need to ask to my customer to reboot the server.
That means that all other users have to stop working, etc.

That's why I'm looking for another way to unlock the locked records.
Of course, I want only the administrator to do such actions.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Forcing to unlock a record

Postby karinha » Wed Nov 16, 2022 5:35 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Forcing to unlock a record

Postby nageswaragunupudi » Wed Nov 16, 2022 6:31 pm

driessen wrote:Hello,

If a record is locked by someone else, is there a possibility that this record can unlocked by another user?

Thank you.


Not possible.

In ADS, Administrator can kill a user. That frees all his locks.

Well behaved programs never lock a record and wait for a user action.
Lock only when all data is ready, then lock and write all data and unlock immediately.
The entire action should not take more than a fraction of a second.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Forcing to unlock a record

Postby Enrico Maria Giordano » Wed Nov 16, 2022 8:12 pm

nageswaragunupudi wrote:Well behaved programs never lock a record and wait for a user action.
Lock only when all data is ready, then lock and write all data and unlock immediately.
The entire action should not take more than a fraction of a second.


Perfectly said. I completely agree.
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Forcing to unlock a record

Postby Jimmy » Thu Nov 17, 2022 8:31 am

hi,

when type "compmgmt.msc" i can "see" which File are open by which User
you can "close" File to terminate Connection
Image

as i remember you can use a Powershell Script to get a List
but you need access to "Server" to do any ACTION

---

does Fivewin ACTIVATE have a "Timeout" :?:

this i do use under Xbase++ where i use Timeout and close Windows when "inactive"
Code: Select all  Expand view
  nEvent := 0
   DO WHILE !lExit
      nEvent := APPEVENT( @mp1, @mp2, @oXbp, nTime )  // 4th Parameter Timeout
      DO CASE
         CASE nEvent == xbe_None
            EXIT
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1585
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Forcing to unlock a record

Postby James Bott » Thu Dec 01, 2022 1:58 am

Driessen,

I think there is another way to handle your problem, but it is a bit complicated.

Instead of the program locking a record when a user opens it and only unlocking it when the record is saved, the record is only locked for a split second when the record saved. Thus, nobody can walk away leaving a record locked.

One solution is that when the program reads a record into a dialog for editing, it also copies the original data to a second buffer. Then when the user2 selects to save the data, first the program reads the record again and compares it to the original data in the second buffer. If a change has been made to the record, then the program notifies user2 that the data has been changed, and does user2 want to abandon their current changes or re-read the record and make their changes to the newly revised record.

If user2 wants to remake the changes, the program re-reads the record and goes back into edit mode. Next, user2 modifies the record again. When they go to save the changed data, the program again re-reads the record from the disk and then checks all the fields to see if any are different than the original in-memory copy. If not, then the modified data is written to the disk.

I have not tested this.

Like I said, it's complicated.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Forcing to unlock a record

Postby Giovany Vecchi » Thu Dec 01, 2022 8:34 am

There is a detail in the ads that must be observed when locking a record.
In a situation where we use a register to follow a sequence of numbers automatically and in the attempt at the exact moment another user is executing the addition of the number (Example) the register must be refreshed.
In my tAds class this is automatic in the rLock() method

Code: Select all  Expand view

METHOD RLock(f_nRecno, f_nLockSeconds) Class TAds
   Local lLockRecno := .F., iForTentativa := 0, lc_nLockLoops := 0

   Default f_nRecno := (::cAlias)->(Recno()), f_nLockSeconds := 5

   lc_nLockLoops := (f_nLockSeconds / 0.2)

   If (::cAlias)->(Recno()) != f_nRecno
      (::cAlias)->(DbGoTo(f_nRecno))
      ::OnSkip()
   EndIf

   For iForTentativa := 1 To lc_nLockLoops
      (::cAlias)->(AdsRefreshRecord())
      If (::cAlias)->(DbRLock())
         ::cAuditProcess += If(!Empty(::cAuditProcess),Replicate("-",80)+CRLF,"")
         ::cAuditProcess += "ACE Api > AdsLockRecord("+cValToStr(::Recno())+") Table "+;
                                     ::cTableName+CRLF
         ::lAppendRecord := .F.
         lLockRecno := .T.
         Exit
      Else
         SysWait(.2)
      EndIf
   Next

RETURN lLockRecno
 
User avatar
Giovany Vecchi
 
Posts: 207
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 90 guests