Method 1: directly modify the startuppost method of the info class. Because the modification is complicated, I will directly reference the junevoful code as an example below.
Void startuppost ()
{
Int counter;
Int num = 0;
Int maxsessions = info: licenseduserstotal ();
Xsession session;
Userinfo;
Userid currentuserid;
;
Currentuserid = curuserid ();
For (counter = 1; counter <maxsessions; counter ++)
{
Session = new xsession (counter, true );
If (Session & session. userid ())
{
Select firstonly userinfo
Where userinfo. ID = session. userid ();
If (userinfo & (currentuserid = session. userid ()))
{
Num ++;
}
}
}
If (Num> 1)
{
Box: Info ("this user ID has been logged in. Please exit. ")
{
Infolog. Shutdown (true );
}
}
}
Method 2: Further improvement of method 1 is also in use.
Different departments may have different working hours. In this way, when licence is limited, many people may log on to the department that is working earlier, but cannot log on to the department at night. To avoid this unfair phenomenon, we first create a department field in the sysuserinfo table, and then create a table to indicate the number of people that can log on to each department at the same time. Then, code similar to method 1 is used to control the number of login users.