控制用户重复登录AX

 1 void startupPost()
 2 {
 3     int         counter;
 4     int         num = 0;
 5     int         maxSessions = Info::licensedUsersTotal();
 6     xSession    session;
 7     UserInfo    userInfo;
 8     UserId      currentUserId;
 9     ;
10 
11     currentUserId = curuserid();
12 
13     for(counter = 1; counter < maxSessions;counter++ )
14     {
15         session = new xSession(counter, true);
16         if (session && session.userId())
17         {
18             select firstOnly userInfo
19                 where userInfo.id == session.userId();
20             if (userInfo && (currentUserId == session.userId()))
21             {  
22                 num++ ;
23             }
24         }
25     }
26     if (num > 1)
27     {
28         box::info("此用户ID已经登陆,请退出。")
29         {
30             infolog.shutDown(true);
31         }
32     }
33 }
posted @ 2012-08-30 10:52  Sprite.z  Views(206)  Comments(0Edit  收藏  举报