示例#1
0
def AdminLogin(request):
    try:
        starttime=datetime.datetime.now()
        global log
        log, fh=public.loger_init('Admin')
        #print('public.logger.handlers',public.logger.handlers)
        log.info('----------------------Admin-begin---------------------------')
        log.info("请求:[%s]" % request)
        log.info("请求path:[%s]" % request.path)
        log.info("请求method:[%s]"  %  request.method)
        log.info("请求GET:[%s]"  %  request.GET)
        log.info("请求body:[%s]"  % request.body)
        log.info("请求POST:[%s]" % request.POST)

        respinfo=None
        respinfo=useract.UserLogin_Qrcode(request)  #用户扫码登陆处理主流程

    except Exception as e :
        log.warning('程序运行错误', exc_info = True)
        s = public.setrespinfo({"respcode": "999999", "respmsg": "系统错误:"+str(e)})
        respinfo=HttpResponse(s)
        log.info(respinfo.getvalue().decode(encoding='utf-8'))
        log.info('----------------------Admin-end---------------------------')
        if fh:
            fh.close()
            log.removeHandler(fh)
        return respinfo
    finally:
        if not respinfo: #如果返回信息为空
            s = public.setrespinfo({"respcode": "999999", "respmsg": "系统错误"})
            respinfo=HttpResponse(s)
        try:
            log.info(respinfo)
            log.info(respinfo.getvalue().decode(encoding='utf-8'))
        except:
            pass
        log.info('----------------------Admin-end---------------------------')
        print('处理时间:', datetime.datetime.now()-starttime)
        if fh:
            fh.close()
            log.removeHandler(fh)
        return respinfo
示例#2
0
 def render(path: str, params: dict, filename: str):
     template = get_template(path)
     html = template.render(params)
     response = io.BytesIO()
     pdf = pisa.pisaDocument(io.BytesIO(html.encode("UTF-8")), response)
     if not pdf.err:
         response = HttpResponse(response.getvalue(),
                                 content_type='application/pdf')
         response[
             'Content-Disposition'] = 'attachment; filename=%s.pdf' % filename
         return response
     else:
         return HttpResponse("Error Rendering PDF", status=400)
示例#3
0
def admin(request):
    try:
        starttime = datetime.datetime.now()
        global log
        log, fh = public.loger_init('Admin')
        log.info(
            '----------------------Admin-begin---------------------------')
        log.info("请求:[%s]" % request)
        log.info("请求path:[%s]" % request.path)
        log.info("请求method:[%s]" % request.method)
        log.info("请求GET:[%s]" % request.GET)

        global location_href
        location_href = 'https://localhost:8000' + request.get_full_path()
        log.info("请求full_path:[%s]" % location_href)
        if request.path[-1] == '/':
            param1 = request.path.rsplit('/')[-2]
        else:
            param1 = request.path.rsplit('/')[-1]
        logmsg = 'param1=[' + param1 + ']'
        log.info(logmsg)

        global respinfo
        respinfo = None

        # 记录交易处理开始的时间点
        mysavepoint = transaction.savepoint()

        if param1 == 'useract':
            # 登录、注册接口
            respinfo = useract.admin(request)
            return respinfo
        elif param1 == 'filecfg':
            # 文件上传接口
            respinfo = filecfg.admin(request)
            return respinfo
        elif param1 == 'readact':
            # 阅读接口
            respinfo = readact.admin(request)
            return respinfo
        elif param1 == 'appview':
            # app信息展示
            respinfo = appview.admin(request)
            return respinfo
        elif param1 == 'appreadact':
            # app阅读接口
            respinfo = appreadact.admin(request)
            return respinfo
        elif param1 == 'appuseract':
            # app用户个人信息操作接口
            respinfo = appuseract.admin(request)
            return respinfo
        else:
            respinfo = render(request, 'index.html')
            return respinfo
    except Exception as e:
        log.error('程序运行错误', exc_info=True)
        try:
            transaction.savepoint_rollback(mysavepoint)
        except:
            pass

        s = public.setrespinfo({
            "respcode": "999999",
            "respmsg": "系统错误:" + str(e)
        })
        respinfo = HttpResponse(s)

    finally:
        try:
            transaction.savepoint_rollback(mysavepoint)
        except:
            pass
        if not respinfo:  # 如果返回信息为空
            s = public.setrespinfo({
                "respcode": "999999",
                "respmsg": "系统错误[返回数据异常]"
            })
            respinfo = HttpResponse(s)

        try:
            if len(str(respinfo)) < 1024:
                log.info(respinfo)
                log.info(respinfo.getvalue().decode(encoding='utf-8'))
        except:
            pass
        log.info('----------------------Admin-end---------------------------')
        log.info('交易处理时间: %s' % str(datetime.datetime.now() - starttime))
        if fh:
            fh.close()
            log.removeHandler(fh)
        return respinfo
示例#4
0
def admin(request):
    try:
        starttime=datetime.datetime.now()
        #获取访问路径
        if request.path[-1] == '/':
            param1 = request.path.rsplit('/')[-2]
        else:
            param1 = request.path.rsplit('/')[-1]
        logmsg = 'param1=[' + param1 + ']'
        #初始化日志
        global log
        if param1:
            log, fh = public.loger_init(param1)
        else:
            log, fh=public.loger_init('Admin')
        #print('public.logger.handlers',public.logger.handlers)
        log.info('----------------------Admin-begin---------------------------')
        log.info("请求:[%s]" % request)
        log.info("请求path:[%s]" % request.path)
        log.info("请求method:[%s]"  %  request.method)
        log.info("请求GET:[%s]"  %  request.GET)

        global  location_href
        location_href='https://localhost:8000'+request.get_full_path()
        log.info("请求full_path:[%s]" % location_href )

        global respinfo
        respinfo = None

        if param1 not in ['useraction', 'filedue']: #上传文件的日志太大了,不再记录
            log.info("请求body:[%s]"  % request.body)
            log.info("请求POST:[%s]" % request.POST)

        #校验session
        if param1 not in ['useraction','buttontran','filedue', 'made']:
            #sesession校验
            if public.checksession(request) == False:
                s = public.setrespinfo({"respcode": "100001", "respmsg": "请重新登陆"})
                respinfo = HttpResponse(s)
                return respinfo

        #记录交易处理开始的时间点
        mysavepoint = transaction.savepoint()
        if  param1=='crudcfg':
            #管理台配置接口
            respinfo=admin_crudcfg(request)
            return respinfo
        elif  param1=='getdata':
            #管理台数据查询接口
            respinfo=admin_tabledata(request)
            return respinfo
        elif param1 == 'filedue':
            # 管理台文件处理接口
            respinfo = filecfg.admin(request)
            return respinfo
        elif param1 == 'useraction':
            # 管理台用户登陆退出等接口
            log.info("请求body:[%s]" % request.body)
            respinfo = admin_useraction(request, log)
            return respinfo
        elif param1 == 'buttontran':
            # 管理台用户登陆退出等接口
            respinfo = buttontran.tran_main(request)
            return respinfo
        elif param1 == 'lqkjsmpd':
            # 工装扫码配对模块接口
            respinfo = lqkjsmpd.main(request)
            return respinfo
        elif param1 == 'lqkjoa':
            # 联桥科技oa接口
            respinfo = lqkjoa.main(request)
            return respinfo
        elif param1 == 'lqkjmes':
            # 联桥科技oa接口
            respinfo = lqkjmes.main(request)
            return respinfo
        elif param1 == 'lqkjerp':
            # 联桥科技erp数据接口
            respinfo = lqkjerp.main(request)
            return respinfo
        elif param1 == 'lqkjbill':
            # 联桥科技评审单接口
            respinfo = lqkjbill.main(request)
            return respinfo
        elif param1 == 'lqkjsetform':
            # 联桥科技评审单接口
            respinfo = lqkjsetform.main(request)
            return respinfo
        elif param1 == 'made':
            # 联桥科技,产测、抄表等工装数据上传。
            respinfo = lqkjprod.main(request)
            return respinfo
        elif param1 == 'fileup':
            # 联桥科技,产测、抄表等工装数据上传。
            respinfo = fileup.main(request)
            return respinfo
        elif param1 == 'form_config':
            # 表单配置接口
            respinfo = form_config.main(request)
            return respinfo
        elif param1 == 'lqkjmarket':
            # 表单配置接口
            respinfo = lqkjmarket.main(request)
            return respinfo
        elif param1 == 'lqkjbuy':
            # 表单配置接口
            respinfo = lqkjbuy.main(request)
            return respinfo
        elif param1 == 'lqkjrece':
            # 销售票据录入接口
            respinfo = lqkjrece.main(request)
            return respinfo
        else:
            print('返回主页')
            respinfo=render(request, 'index.html')
            return respinfo
    except Exception as e :
        log.error('程序运行错误', exc_info = True)
        try:
            transaction.savepoint_rollback(mysavepoint)
        except:
            pass

        s = public.setrespinfo({"respcode": "999999", "respmsg": "系统错误:"+str(e)})
        respinfo=HttpResponse(s)
        # log.info(respinfo.getvalue().decode(encoding='utf-8'))
        # log.info('----------------------Admin-end---------------------------')
        # if fh:
        #     fh.close()
        #     log.removeHandler(fh)
        # return respinfo
    finally:
        #print(respinfo)
        try:
            transaction.savepoint_rollback(mysavepoint)
        except:
            pass
        if not respinfo: #如果返回信息为空
            s = public.setrespinfo({"respcode": "999999", "respmsg": "系统错误[返回数据异常]"})
            respinfo=HttpResponse(s)
    
        try:
            if len(str(respinfo)) < 1024:
                log.info(respinfo)
                log.info(respinfo.getvalue().decode(encoding='utf-8'))
        except:
            pass
        log.info('----------------------Admin-end---------------------------')
        log.info('交易处理时间: %s' %  str(datetime.datetime.now()-starttime) )
        if fh:
            fh.close()
            log.removeHandler(fh)
        return respinfo