示例#1
0
def sql_is_admin_online():
    admin = SQLClientHelper.GetAccountByField1('username', 'admin')
    if admin.id <= 0:
        return False
    else:
        # 查找当前登录账户
        account_id = CbmClientHelper.GetOnlineAccountId()
        return account_id == admin.id
示例#2
0
def sql_login_status():
    # 查找管理员账户
    admin = SQLClientHelper.GetAccountByField1('username', 'admin')
    if admin.id <= 0:
        return 0  # 内部错误(无管理员账户)
    else:
        # 查找当前登录账户
        account_id = CbmClientHelper.GetOnlineAccountId()
        if account_id <= 0:
            return 2  # 没有用户登录
        elif account_id == admin.id:
            return 3  # 管理员已登录
        else:
            mine_id = SQLClientHelper.GetMineIdByForeignKey(
                'account_id', account_id)
            if mine_id <= 0:  # 内部错误(用户没有关联的矿井)
                return -1
            else:  # 普通用户已登陆
                return 1
示例#3
0
 def login_or_switch(self, uname, pwd):
     account_id = SQLClientHelper.GetAccountIdByField2(
         'username', uname, 'password', pwd)
     # 查找已登录用户
     pre_account_id = CbmClientHelper.GetOnlineAccountId()
     # 当前没有用户登录
     if pre_account_id <= 0:
         # 用户登陆(记录在sys_info表中)
         DataHelper.sql_login_user(account_id)
         # UiHelper.MessageBox('恭喜您,登录成功!')
     # 当前已有用户登录
     elif pre_account_id == account_id:
         # UiHelper.MessageBox('您已经登录过了!')
         pass
     else:
         reply = UiHelper.MessageBox('是否注销并切换到用户%s?' % uname, True)
         if reply == True:
             # 切换用户
             DataHelper.sql_switch_user(account_id)