示例#1
0
def cdata(request):
    '''
    设备向服务器的http:://xxx/cdata请求
    '''
    network_monitor(request)
    try:
        from mysite import authorize_fun
        language=request.REQUEST.get('language',None)   #---获得语言参数
        authorize_fun.check_push_device(language)   #---连接设备数量控制
        device = check_device(request, True)    #---检测、验证当前发出请求的设备
        if device is None: 
            return unknown_device_response()
        else:
            if device.deviceType==POSDEVICE:#消费机
                from mysite.pos.posdevview import pos_cdata
                ret = pos_cdata(request)
                return device_response_write(ret)
            elif device.deviceType in ['ACP', 'ACD']:#控制器or一体机:
                from mysite.iaccess.push_comm_center import acc_cdata
                ret = acc_cdata(request)
                return device_response_write(ret)
            
            if request.REQUEST.has_key('action'):
                return ok_response(device)
            elif request.method == 'GET':
                return cdata_get(request,device)
            elif request.method == 'POST':
                try:
                    return cdata_post(request, device)
#                    resp =cdata_post(request, device)
#                    return device_response_write(resp)
                except Exception, e:
                    return erro_response(e)
            else:
示例#2
0
def cdata(request):
    '''
    设备向服务器的http:://xxx/cdata请求
    '''
    from protocol_content import POSDEVICE
    network_monitor(request)
    try:
        device_type = request.REQUEST.get('devicetype')  #设备类型参数
        pos_device_type = request.REQUEST.get('device_type',
                                              None)  #兼容ID消费固件,后期统一使用devicetype
        if (device_type == POSDEVICE or pos_device_type == POSDEVICE):  #ID消费机
            from mysite.pos.pos_id.posdevview import pos_cdata
            if get_option("POS_ID"):
                resp = pos_cdata(request)
            else:  #防止IC消费软件,连接ID消费机
                from protocol_content import pos_return
                resp = pos_return()
            return device_response_write(resp)
        else:
            device = check_device(request, True, True)  #---检测、验证当前发出请求的设备
            if device is None:
                return unknown_device_response()
            else:
                if device.deviceType in ['ACP', 'ACD']:  #控制器or一体机:
                    from mysite.iaccess.push_comm_center import acc_cdata
                    ret = acc_cdata(request)
                    return device_response_write(ret)

                if request.REQUEST.has_key('action'):
                    return ok_response(device)
                elif request.method == 'GET':
                    return cdata_get(request, device)
                elif request.method == 'POST':
                    try:
                        return cdata_post(request, device)
    #                    resp =cdata_post(request, device)
    #                    return device_response_write(resp)
                    except Exception, e:
                        return erro_response(e)
                else:
                    return unknown_data_response(device)
示例#3
0
            if request.REQUEST.has_key('action'):
                return ok_response(device)
            elif request.method == 'GET':
                return cdata_get(request,device)
            elif request.method == 'POST':
                try:
                    return cdata_post(request, device)
#                    resp =cdata_post(request, device)
#                    return device_response_write(resp)
                except Exception, e:
                    return erro_response(e)
            else:
                return unknown_data_response(device)
            check_and_save_cache(device)    #----暂为空函数
    except  Exception, e:
        return erro_response(e)

def update_device_info(device,info):
    '''
    更新设备信息
    '''
    info = info.split(",")
    device.fw_version=info[0]   #---主版本号
    device.user_count=int(info[1])  #---注册用户数
    device.fp_count=int(info[2])    #---注册指纹数
    device.fp_count=int(info[2])
    device.transaction_count=int(info[3])   #---考勤记录数
    if len(info)>4:
        device.ipaddress=info[4]    #---考勤机IP地址
        if device.alias=="auto_add":
            device.alias=info[4]#由于网关问题,使名称对应的IP地址与机器IP不同时的更正。