def import_schedule(self):
        rlist = []
        if('rnumbers_file' in request.files):
            f = request.files['rnumbers_file']            
            rlist = [x.decode('utf-8') for x in f.stream.readlines()]
            
        elif('rnumbers' in request.form):
            rlist = request.form['rnumbers'].splitlines()

        if(len(rlist)>0):
            #data = request.form['rnumbers'].splitlines()
            rnumbers = bu.remove_duplicate(rlist)            
            
            for rnumber in rnumbers:                
                rnumber = rnumber.strip()

                if(len(rnumber)==10):
                    #person
                    params = {
                        'id':'01',
                        'expression':'c.registerno',
                        'inputVal':rnumber,
                        'isCitizen': 'true'
                    } 
                elif(len(rnumber)==7):
                    #company
                    params = {
                        'id':'03',
                        'expression':'c.registerno',
                        'inputVal':rnumber
                    }
                else: continue

                filename = Info.generateFilename()
            
                info = Info(
                    user_uuid='ab6ea344-ccd9-4e87-8e85-2d457a52d77e',
                    rnumber=rnumber,
                    params = json.dumps(params, ensure_ascii=False),
                    filename = filename,
                    mode= Info.MODE_SCHEDULE,
                    status=Info.STATUS_PENDING
                )
                session.add(info)

            session.flush()
            return redirect("/home/index")
        return render_template("info/import_schedule.html")
    def creates(self):
        try:
            requestParams = {
                'fields': {
                    'rnumbers': {
                        "type": "list",
                        "required": True
                    },
                    'mode': {
                        "type": "integer",
                        "allowed": [0, 1],
                        "required": True
                    }
                },
                'message': {
                    'rnumbers': {
                        "type": "өгөгдлийн төрөл буруу байна",
                        "required": "Регистрийн дугаар тодорхойгүй байна"
                    },
                    'mode': {
                        "type": "өгөгдлийн төрөл буруу байна",
                        "allowed": "Буруу утгатай байна",
                        "required": "Утга тодорхойгүй байна"
                    }
                }
            }
            v = BuValidator(requestParams)
            v.validate(request.json)
            for rnumber in request.json['rnumbers']:
                if (len(rnumber) == 10):
                    #person
                    params = {
                        'id': '01',
                        'expression': 'c.registerno',
                        'inputVal': rnumber,
                        'isCitizen': 'true'
                    }
                elif (len(rnumber) == 7):
                    #company
                    params = {
                        'id': '03',
                        'expression': 'c.registerno',
                        'inputVal': rnumber
                    }
                else:
                    continue

                filename = Info.generateFilename()

                info = Info(user_uuid=self.auth.uuid,
                            rnumber=rnumber,
                            params=json.dumps(params, ensure_ascii=False),
                            filename=filename,
                            mode=request.json['mode'],
                            status=Info.STATUS_PENDING)
                session.add(info)

            session.flush()
            return json.dumps({
                'result': 'success'
            }, ensure_ascii=False).encode('utf8')
        except Exception as e:
            msg = e.args if len(e.args) > 0 else str(e)
            traceback.print_exc()
            return json.dumps({
                'result': 'error',
                'msg': msg
            },
                              ensure_ascii=False).encode('utf8')
    if (len(rnumber) == 10):
        #person
        params = {
            'id': '01',
            'expression': 'c.registerno',
            'inputVal': rnumber,
            'isCitizen': 'true'
        }
    elif (len(rnumber) == 7):
        #company
        params = {
            'id': '03',
            'expression': 'c.registerno',
            'inputVal': rnumber
        }
    else:
        continue

    filename = Info.generateFilename()

    info = Info(user_uuid='ab6ea344-ccd9-4e87-8e85-2d457a52d77e',
                rnumber=rnumber,
                params=json.dumps(params, ensure_ascii=False),
                filename=filename,
                mode=mode,
                status=Info.STATUS_PENDING)
    session.add(info)
    i += 1
    if (i % 2 == 0): session.flush()

session.flush()