Exemplo n.º 1
0
 def CheckOnLine(userInfo, onLineState):
     """
     检查在线状态
     Args:
         userInfo (string): 用户
         onLineState (string): 用户在线状态
     Returns:
         returnValue (int): 离线人数
     """
     #设置为在线状态
     LogOnService.OnLine(None, userInfo.Id, onLineState)
     returnValue = LogOnService.CheckOnLine(None)
     return returnValue
Exemplo n.º 2
0
    def CheckLogin(ctx, Account, Password):
        if Account == SystemInfo.CurrentUserName:
            if Password == SystemInfo.CurrentPassword:
                imanageuser = UserInfo()
                imanageuser.Id = 'Administrator'
                imanageuser.UserName = '******'
                imanageuser.Code = 'Administrator'
                imanageuser.CompanyId = '系统'
                imanageuser.DepartmentId = '系统'
                imanageuser.IPAddress = ctx.transport.req["REMOTE_ADDR"]
                imanageuser.IsAdministrator = True
                # TODO:需要做在线人数统计


                user = json.dumps(imanageuser, default=UserInfo.obj_2_json)
                user = SecretHelper.AESEncrypt(user)
                Msg = str(user, encoding = "utf8")
            else:
                Msg = "['认证失败']"
        else:

            returnStatusCode = ''

            returnStatusCode, userInfo = LogOnService.UserLogOn(Account, Password, '', False, ctx.transport.req["REMOTE_ADDR"])

            if returnStatusCode == StatusCode.statusCodeDic.get('OK'):
                user = json.dumps(userInfo, default=UserInfo.obj_2_json)
                user = SecretHelper.AESEncrypt(user)
                Msg = str(user, encoding="utf8")
            else:
                Msg = "['认证失败']"

        yield Msg
Exemplo n.º 3
0
def SetUserDimission(request):
    response = HttpResponse()
    curUser = CommonUtils.Current(response, request)
    userEntity = Piuser()
    userEntity.loadJson(request)
    if userEntity.username and userEntity.id:
        userEntity.username = UserSerivce.GetEntity(curUser.Id).username
    returnValue = LogOnService.UserDimission(None, userEntity.username,
                                             userEntity.dimissioncause,
                                             userEntity.dimissiondate,
                                             userEntity.dimissionwhither)

    if returnValue > 0:
        response = HttpResponse()
        response.content = json.dumps({
            'Success': True,
            'Data': '1',
            'Message': FrameworkMessage.MSG3010
        })
        return response
    else:
        response = HttpResponse()
        response.content = json.dumps({
            'Success': False,
            'Data': '0',
            'Message': FrameworkMessage.MSG3020
        })
        return response
Exemplo n.º 4
0
def SetUserPassword(request):
    userId = ''
    password = ''
    try:
        userId = request.POST['userId']
    except:
        userId = ''

    try:
        password = request.POST['password']
    except:
        password = ''

    if userId and password:
        returnCode, returnValue = LogOnService.SetPassword(
            None, [userId], password)
        if returnCode and returnCode == StatusCode.statusCodeDic[
                'SetPasswordOK']:
            response = HttpResponse()
            response.content = json.dumps({
                'Success': True,
                'Data': '1',
                'Message': FrameworkMessage.MSG9963
            })
            return response
        else:
            response = HttpResponse()
            response.content = json.dumps({
                'Success': True,
                'Data': '1',
                'Message': FrameworkMessage.MSG3020
            })
            return response
Exemplo n.º 5
0
def OutLogin(request):
    response = HttpResponse()
    LogOnService.OnExit(None, CommonUtils.Current(response, request).Id)
    CommonUtils.EmptyCurrent(response, request)
    request.session.flush()
    response.content = '1'
    return response
Exemplo n.º 6
0
 def MessageChek(self, userInfo, onLineState, lastChekDate):
     """
     获取消息状态
     Args:
         userInfo (string): 用户
         onLineState (string): 用户在线状态
         lastChekDate (string): 最后检查日期
     Returns:
     """
     returnValue = []
     LogOnService.OnLine(None, userInfo.Id, onLineState)
     messageCount = MessageService.GetNewCount(userInfo,
                                               MessageFunction.Message)
     returnValue[0] = str(messageCount)
     if len(messageCount) > 0:
         messageEntity = MessageService.GetNewOne(userInfo)
         latCheckDate = datetime.datetime.min
         if messageEntity.createon:
             lastChekDate = messageEntity.createon
             returnValue[1] = time.struct_time(lastChekDate,
                                               SystemInfo.DateTimeFormat)
         returnValue[2] = messageEntity.createuserid
         returnValue[3] = messageEntity.createby
         returnValue[4] = messageEntity.objectid
         returnValue[5] = messageEntity.msgcontent
     return returnValue
Exemplo n.º 7
0
def CheckLogin(request):
    if request.method == 'GET':
        return render(request, 'Login/Index.html')
    else:
        Msg = ''
        IPAddress = NetHelper.GetIpAddress(request)
        Account = ''
        Password = ''
        Token = ''
        try:
            Account = request.POST['Account']
            Password = request.POST['Password']

            if Account == SystemInfo.CurrentUserName:
                if Password == SystemInfo.CurrentPassword:
                    imanageuser = UserInfo()
                    imanageuser.Id = 'Administrator'
                    imanageuser.UserName = '******'
                    imanageuser.Code = 'Administrator'
                    imanageuser.CompanyId = '系统'
                    imanageuser.DepartmentId = '系统'
                    imanageuser.IPAddress = IPAddress
                    imanageuser.IsAdministrator = True
                    #TODO:需要做在线人数统计

                    Msg = '3'
                    response = HttpResponse(Msg)
                    CommonUtils.AddCurrent(imanageuser, response, request)
                    response.set_cookie(
                        'UIStyle',
                        CommonUtils.UIStyle(imanageuser, response, request))
                    return response
                else:
                    Msg = '4'
                    return HttpResponse(Msg)
            else:

                returnStatusCode = ''

                returnStatusCode, userInfo = LogOnService.UserLogOn(
                    Account, Password, '', False, IPAddress)

                if returnStatusCode == StatusCode.statusCodeDic.get('OK'):
                    Msg = '3'
                    response = HttpResponse(Msg)
                    CommonUtils.AddCurrent(userInfo, response, request)
                    response.set_cookie(
                        'UIStyle',
                        CommonUtils.UIStyle(userInfo, response, request))
                    return response
                else:
                    Msg = '4'

        except Exception as e:
            print(e)

        return HttpResponse(Msg)
Exemplo n.º 8
0
 def GetOnLineState(userInfo):
     """
     获取在线用户列表
     Args:
         userInfo (string): 用户
     Returns:
         returnValue (Ciuser[]): 数据表
     """
     #设置为在线状态
     getOnLine = False
     LogOnService.OnLine(None, userInfo.Id)
     if MessageService.LastCheckOnLineState == datetime.datetime.min:
         getOnLine = True
     else:
         timeSpan = datetime.datetime.now() - MessageService.LastCheckOrgTime
         if timeSpan.minute * 60 + timeSpan.second >= SystemInfo.OnLineCheck * 100:
             getOnLine = True
     if MessageService.OnLineStateDT == None or getOnLine:
         #检查用户在线状态(服务器专用)
         LogOnService.CheckOnLine()
         MessageService.OnLineStateDT = LogOnService.GetOnLineStateDT(None)
         MessageService.LastCheckOnLineState = datetime.datetime.now()
     return MessageService.OnLineStateDT