コード例 #1
0
ファイル: authapi.py プロジェクト: nguyenhuong791123/api
def getLogin():
    auth = request.headers.get('authorization', None)

    result = None
    if request.json is not None:
        u = request.json['username']
        if u is None or len(u) <= 0:
            return jsonify({'username': '******'}), 200
        p = request.json['password']
        if p is None or len(u) <= 0:
            return jsonify({'password': '******'}), 200

        conn = None
        try:
            conn = DB(get_common_db_info())
            uconn = User(conn)
            user = uconn.get_login(u, p)
            users = UserSchema(many=False).dump(user)
            result = {'user': users}
        except Exception as ex:
            result = {'error': str(ex)}
        finally:
            if conn is not None:
                conn.close_session()

    # print(result)
    return jsonify(result), 200
コード例 #2
0
ファイル: page.py プロジェクト: nguyenhuong791123/api
def setServiceGroupPage(page, cId, uId):
    conn = None
    pconn = None
    lconn = None
    prconn = None
    result = None
    try:
        conn = DB(get_common_db_info())
        conn = Server(conn)
        server = conn.get_server_by_type(cId, 0)
        if server is not None:
            server = ServerInfo(many=False).dump(server)
            conn = DB(get_db_info(server))
            pconn = Page(conn)
            #page['page_layout'] = 0
            #page['page_open'] = 0
            pconn.__json__(page, cId, uId)
            pconn.add(pconn)
            result = PageMenuSchema(many=False).dump(pconn)
            pconn.update_all(page['items'])

            plsconn = Label(conn)
            pln = {}
            pln['schema_id'] = result['page_id']
            pln['properties_name'] = str(result['page_id'])
            pln['object_label'] = {'ja': page['page_name']}
            plsconn.__json__(pln)
            plsconn.add(plsconn)

            pIds = [p["page_id"] for p in page['items']]
            for pId in pIds:
                prconn = PageRel(conn)
                prconn.delete(pId, False)
                prconn.__json__(result['page_id'], pId)
                prconn.add(prconn)

            sconn = PageMenu(conn, 'items')
            menu = sconn.get_menus(cId, 'ja')
            result = PageMenuSchema(many=True).dump(menu)
        else:
            result = {'error': 'Not Server Info!!!'}

    except Exception as ex:
        if prconn is not None and is_exist(result, 'page_id') == True:
            prconn.delete(result['page_id'], True)
        if lconn is not None and is_exist(result, 'page_id') == True:
            lconn.delete(result['page_id'], 1)
        if pconn is not None and is_exist(result, 'page_id') == True:
            pconn.delete(result['page_id'])

        result = {'error': str(ex)}
    finally:
        if conn is not None:
            conn.close_session()

    return result
コード例 #3
0
def getOptionByPatition():
    auth = request.headers.get('authorization', None)

    result = None
    if request.json is not None:
        cId = request.json.get('cId', None)
        if cId is None or cId <= 0:
            return jsonify({'cId': 'incorrect company id'}), 200
        uId = request.json.get('uId', None)
        if uId is None or uId <= 0:
            return jsonify({'uId': 'incorrect user id'}), 200
        patition = request.json.get('patition', None)
        if patition is None or len(patition) <= 0:
            return jsonify({'patition': 'incorrect patition'}), 200
        gIds = request.json.get('gIds', None)

        conn = None
        try:
            conn = DB(get_common_db_info())
            conn = Server(conn)
            server = conn.get_server_by_type(cId, 0)
            if server is not None:
                server = ServerInfo(many=False).dump(server)
                conn = DB(get_db_info(server))
                if patition == 'group_info':
                    giconn = OptionPatitions(conn)
                    giconn = giconn.get_option_groups()
                    result = OptionPatitionsSchema(many=True).dump(giconn)
                    if result:
                        result = result[0]['patitions']
                elif patition == 'users_info':
                    uiconn = OptionPatitions(conn)
                    uiconn = uiconn.get_option_users(gIds)
                    result = OptionPatitionsSchema(many=True).dump(uiconn)
                    if result:
                        result = result[0]['patitions']
                else:
                    pconn = Options(conn)
                    pconn = pconn.get_options_by_patition(cId, patition)
                    result = OptionsSchema(many=True).dump(pconn)

            else:
                result = {'error': 'Not Server Info!!!'}

        except Exception as ex:
            result = {'error': str(ex)}
        finally:
            if conn is not None:
                conn.close_session()

    return jsonify(result), 200
コード例 #4
0
ファイル: searchapi.py プロジェクト: nguyenhuong791123/api
def getDatas():
    auth = request.headers.get('authorization', None)

    result = None
    if request.json is not None:
        cId = request.json['cId']
        if is_integer(cId) == False:
            return jsonify({'error': 'incorrect company id'}), 200
        uId = request.json['uId']
        if is_integer(uId) == False:
            return jsonify({'error': 'incorrect user id'}), 200
        page = request.json['page']
        if is_empty(page) == True or is_exist(page, 'page_key') == False:
            return jsonify({'error': 'incorrect page info'}), 200
        schema = page['page_key']
        columns = page['columns']
        idSeq = page['page_id_seq']
        if is_empty(columns) == True:
            return jsonify({'error': 'incorrect columns info'}), 200
        reference = None
        if is_exist(request.json, 'reference') == True:
            reference = request.json['reference']
        where = None
        if is_exist(request.json, 'where') == True:
            where = request.json['where']

        conn = None
        try:
            conn = DB(get_common_db_info())
            conn = Server(conn)
            server = conn.get_server_by_type(cId, 0)
            if server is not None:
                server = ServerInfo(many=False).dump(server)
                conn = DB(get_db_info(server))
                sconn = PageMenu(conn)
                datas = sconn.get_datas(schema, columns, idSeq, where,
                                        reference)
                if datas:
                    result = json.dumps([(dict(row.items())) for row in datas])
                    result = json.loads(result)[0]['result']

            else:
                result = {'error': 'Not Server Info!!!'}

        except Exception as ex:
            result = {'error': str(ex)}
        finally:
            if conn is not None:
                conn.close_session()

    return jsonify(result), 200
コード例 #5
0
ファイル: authapi.py プロジェクト: nguyenhuong791123/api
def getBasic():
    auth = request.headers.get('authorization', None)
    result = {}
    if auth is not None and auth[:5] == 'Basic':
        auth = auth.replace('Basic ', '')
        auth = base64.b64decode(auth).decode('utf-8')
        auth = auth.split(':')

        conn = None
        try:
            conn = DB(get_common_db_info())
            cconn = Company(conn)
            basic = cconn.get_basic(auth[0], auth[1])
            result = CompanyBasic(many=False).dump(basic)
        except Exception as ex:
            result = str(ex)
        finally:
            if conn is not None:
                conn.close_session()

    return jsonify(result), 200
コード例 #6
0
def getPatitions():
    auth = request.headers.get('authorization', None)

    result = None
    if request.json is not None:
        cId = request.json['cId']
        if cId is None or cId <= 0:
            return jsonify({'cId': 'incorrect company id'}), 200
        uId = request.json['uId']
        if uId is None or uId <= 0:
            return jsonify({'uId': 'incorrect user id'}), 200
        language = request.json['language']
        if language is None or len(language) <= 0:
            return jsonify({'language': 'incorrect patition'}), 200

        conn = None
        try:
            conn = DB(get_common_db_info())
            conn = Server(conn)
            server = conn.get_server_by_type(cId, 0)
            if server is not None:
                server = ServerInfo(many=False).dump(server)
                conn = DB(get_db_info(server))
                pconn = OptionPatitions(conn)
                pconn = pconn.get_patitions(cId, language)
                result = OptionPatitionsSchema(many=True).dump(pconn)

                if result:
                    result = result[0]['patitions']
            else:
                result = {'error': 'Not Server Info!!!'}

        except Exception as ex:
            result = {'error': str(ex)}
        finally:
            if conn is not None:
                conn.close_session()

    return jsonify(result), 200
コード例 #7
0
ファイル: page.py プロジェクト: nguyenhuong791123/api
def updateServicePage(page, cId):
    result = None
    try:
        conn = DB(get_common_db_info())
        conn = Server(conn)
        server = conn.get_server_by_type(cId, 0)
        if server is not None:
            server = ServerInfo(many=False).dump(server)
            conn = DB(get_db_info(server))
            pconn = Page(conn)
            pconn.update(page)
            result = page

        else:
            result = {'error': 'Not Server Info!!!'}
    except Exception as ex:
        result = {'error': str(ex)}
    finally:
        if conn is not None:
            conn.close_session()

    return result
コード例 #8
0
ファイル: page.py プロジェクト: nguyenhuong791123/api
def updateServicePages(pages, cId):
    result = None
    try:
        conn = DB(get_common_db_info())
        conn = Server(conn)
        server = conn.get_server_by_type(cId, 0)
        if server is not None:
            server = ServerInfo(many=False).dump(server)
            conn = DB(get_db_info(server))
            pconn = Page(conn)
            pconn.update_all(pages)

            for page in pages:
                if (is_exist(page, 'items') == True
                        and is_empty(page['items']) == False
                        and is_empty(page['items'][0]) == False):
                    pconn.update_all(page['items'])
                    pIds = [p["page_id"] for p in page['items']]
                    pgconn = PageRel(conn)
                    pgconn.delete(page['page_id'], True)
                    for pId in pIds:
                        prconn = PageRel(conn)
                        prconn.delete(pId, False)
                        prconn.__json__(page['page_id'], pId)
                        prconn.add(prconn)

            sconn = PageMenu(conn, 'items')
            menu = sconn.get_menus(cId, 'ja')
            result = PageMenuSchema(many=True).dump(menu)
        else:
            result = {'error': 'Not Server Info!!!'}
    except Exception as ex:
        result = {'error': str(ex)}
    finally:
        if conn is not None:
            conn.close_session()

    return result
コード例 #9
0
ファイル: page.py プロジェクト: nguyenhuong791123/api
def getServicePage(cId, pId, language, edit):
    conn = None
    result = None
    try:
        conn = DB(get_common_db_info())
        conn = Server(conn)
        server = conn.get_server_by_type(cId, 0)
        if server is not None:
            server = ServerInfo(many=False).dump(server)
            conn = DB(get_db_info(server))
            pconn = PageForm(conn)
            if edit == True:
                page = pconn.get_edit_form_fields(cId, pId, language)
            else:
                page = pconn.get_form_fields(cId, pId, language)
            result = PageFormSchema(many=False).dump(page)

            forms = result['form']
            for f in forms:
                if f['object_type'] == 'div':
                    obj = copy.copy(f['object'][0])
                    f['object'] = obj
                elif f['object_type'] == 'tab' and isinstance(
                        f['object'], list):
                    for o in f['object']:
                        o['schema']['tab_name'] = copy.copy(
                            o['schema']['title'])
                        del o['schema']['title']
            # print(result)
        else:
            result = {'error': 'Not Server Info!!!'}
    except Exception as ex:
        result = {'error': str(ex)}
    finally:
        if conn is not None:
            conn.close_session()

    return result
コード例 #10
0
ファイル: searchapi.py プロジェクト: nguyenhuong791123/api
def getColumns():
    auth = request.headers.get('authorization', None)

    result = None
    if request.json is not None:
        cId = request.json['cId']
        if is_integer(cId) == False:
            return jsonify({'error': 'incorrect company id'}), 200
        pId = request.json['pId']
        if is_integer(pId) == False:
            return jsonify({'error': 'incorrect page id'}), 200
        language = request.json['language']
        if is_empty(language) == True:
            return jsonify({'language': 'incorrect language'}), 200

        conn = None
        try:
            conn = DB(get_common_db_info())
            conn = Server(conn)
            server = conn.get_server_by_type(cId, 0)
            if server is not None:
                server = ServerInfo(many=False).dump(server)
                conn = DB(get_db_info(server))
                sconn = PageMenu(conn)
                menu = sconn.get_colums(cId, pId, language)
                menus = PageMenuSchema(many=False).dump(menu)

            else:
                result = {'error': 'Not Server Info!!!'}

        except Exception as ex:
            result = {'error': str(ex)}
        finally:
            if conn is not None:
                conn.close_session()

    return jsonify(result), 200
コード例 #11
0
ファイル: authapi.py プロジェクト: nguyenhuong791123/api
def getMode():
    result = None
    if request.json is not None:
        auth = request.json['uuid']
        if auth is None or len(auth) <= 0:
            return jsonify({'uuid': 'incorrect uuid'}), 200

        auth = base64.b64decode(auth).decode('utf-8')
        auth = auth.split(':')

        conn = None
        try:
            conn = DB(get_common_db_info())
            cconn = Company(conn)
            mode = cconn.get_basic(auth[0], auth[1])
            result = CompanyMode(many=False).dump(mode)
        except Exception as ex:
            result = {'error': str(ex)}
            # result = str(ex)
        finally:
            if conn is not None:
                conn.close_session()

    return jsonify(result), 200
コード例 #12
0
ファイル: data.py プロジェクト: nguyenhuong791123/api
def getServiceUpdateData(page, cId, uId, rId):
    print(page)
    print(rId)
    print(cId)
    print(uId)
    result = None
    try:
        conn = DB(get_common_db_info())
        conn = Server(conn)
        server = conn.get_server_by_type(cId, 0)
        if server is not None:
            server = ServerInfo(many=False).dump(server)
            conn = DB(get_db_info(server))
            pconn = Page(conn)
            data = pconn.update_datas(page, cId, uId, rId)
            # print(data)
            if is_empty(data) == False and is_integer(data[0]) == True:
                cs = None
                us = None
                fs = page['form']
                for f in fs:
                    schema = []
                    if isinstance(f['object'], list):
                        for obj in f['object']:
                            fc = {}
                            fc['object'] = obj
                            schema.append(fc)
                    else:
                        schema.append(f)

                    for s in schema:
                        kp = s['object']['schema']['properties']
                        csdata = s['object']['data']
                        for key, value in kp.items():
                            if key.endswith('_customize') and is_exist(
                                    csdata, key):
                                ct = key[0:key.find('_')]
                                if ct == 'text':
                                    ct = 'varchar'
                                elif ct == 'month':
                                    ct = 'date'
                                elif ct in ['textarea', 'editor']:
                                    ct = 'text'
                                elif ct in ['file', 'image']:
                                    ct = 'file'
                                elif ct in [
                                        'number', 'checkbox', 'radio', 'select'
                                ]:
                                    if ct == 'number':
                                        ct = 'double'
                                    else:
                                        ct = 'integer'

                                if is_exist(value, 'field_id') and is_integer(
                                        value['field_id']):
                                    if us == None:
                                        us = {}
                                    if is_exist(us, ct + '_field_datas'):
                                        us[ct + '_field_datas'].append({
                                            'properties_name':
                                            key,
                                            'value':
                                            csdata[key],
                                            'field_id':
                                            value['field_id']
                                        })
                                    else:
                                        us[ct + '_field_datas'] = [{
                                            'properties_name':
                                            key,
                                            'value':
                                            csdata[key],
                                            'field_id':
                                            value['field_id']
                                        }]
                                else:
                                    if cs == None:
                                        cs = {}
                                    if is_exist(cs, ct + '_field_datas'):
                                        cs[ct + '_field_datas'].append({
                                            'properties_name':
                                            key,
                                            'value':
                                            csdata[key]
                                        })
                                    else:
                                        cs[ct + '_field_datas'] = [{
                                            'properties_name':
                                            key,
                                            'value':
                                            csdata[key]
                                        }]
                if cs:
                    pconn.save_customize_datas(page['page_id'], data[0], cs)
                if us:
                    pconn.update_customize_datas(us)
            result = {}
            result[page['page_id_seq']] = page['page_id']
        else:
            result = {'error': 'Not Server Info!!!'}
    except Exception as ex:
        result = {'error': str(ex)}
    finally:
        if conn is not None:
            conn.close_session()

    return result
コード例 #13
0
def getOptions():
    auth = request.headers.get('authorization', None)

    result = None
    if request.json is not None:
        cId = request.json['cId']
        if cId is None or cId <= 0:
            return jsonify({'cId': 'incorrect company id'}), 200
        uId = request.json['uId']
        if uId is None or uId <= 0:
            return jsonify({'uId': 'incorrect user id'}), 200
        patitions = None
        if is_exist(request.json, 'patitions') == True:
            patitions = request.json['patitions']
        print(patitions)

        conn = None
        try:
            conn = DB(get_common_db_info())
            conn = Server(conn)
            server = conn.get_server_by_type(cId, 0)
            if server is not None:
                server = ServerInfo(many=False).dump(server)
                conn = DB(get_db_info(server))
                pconn = OptionPatitions(conn)
                pconn = pconn.get_option_patitions(cId, patitions)
                result = OptionPatitionsSchema(many=True).dump(pconn)

                if result:
                    result = result[0]['patitions']

                for p in patitions:
                    if p == 'city_info':
                        cconn = OptionPatitions(conn)
                        cconn = cconn.get_option_citys()
                        citys = OptionPatitionsSchema(many=True).dump(cconn)
                        if citys:
                            citys = {
                                'option_name': p,
                                'options': citys[0]['patitions']
                            }
                            if result:
                                result.append(citys)
                            else:
                                result = [citys]

                    if p == 'company_info':
                        ciconn = OptionPatitions(conn)
                        ciconn = ciconn.get_option_companys()
                        companys = OptionPatitionsSchema(
                            many=True).dump(ciconn)
                        if companys:
                            companys = {
                                'option_name': p,
                                'options': companys[0]['patitions']
                            }
                            if result:
                                result.append(companys)
                            else:
                                result = [companys]

                    if p == 'group_info':
                        giconn = OptionPatitions(conn)
                        giconn = giconn.get_option_groups()
                        groups = OptionPatitionsSchema(many=True).dump(giconn)
                        if groups:
                            groups = {
                                'option_name': p,
                                'options': groups[0]['patitions']
                            }
                            if result:
                                result.append(groups)
                            else:
                                result = [groups]

                    if p == 'users_info':
                        uiconn = OptionPatitions(conn)
                        uiconn = uiconn.get_option_users(None)
                        users = OptionPatitionsSchema(many=True).dump(uiconn)
                        if users:
                            users = {
                                'option_name': p,
                                'options': users[0]['patitions']
                            }
                            if result:
                                result.append(users)
                            else:
                                result = [users]

            else:
                result = {'error': 'Not Server Info!!!'}

        except Exception as ex:
            result = {'error': str(ex)}
        finally:
            if conn is not None:
                conn.close_session()

    return jsonify(result), 200
コード例 #14
0
ファイル: page.py プロジェクト: nguyenhuong791123/api
def deleteServicePage(page, cId):
    try:
        conn = DB(get_common_db_info())
        conn = Server(conn)
        server = conn.get_server_by_type(cId, 0)
        if server is not None:
            server = ServerInfo(many=False).dump(server)
            conn = DB(get_db_info(server))
            ls = []
            if is_empty(
                    page['page_key']) == False and page['page_key'].startswith(
                        'customize.table_') == True:
                ls.append(str(page['page_id']))
                fconn = Form(conn)
                fs = fconn.get_by_page_id(page['page_id'])
                if fs is not None:
                    for f in fs:
                        sconn = Schema(conn)
                        ss = sconn.get_by_form_id(f.form_id)
                        if ss is not None:
                            for s in ss:
                                ls.append(s.schema_key)
                                psconn = Properties(conn)
                                ps = psconn.get_by_schema_id(s.schema_id)
                                for p in ps:
                                    ls.append(p.properties_name)
                                psconn.delete(s.schema_id)
                                uiconn = Ui(conn)
                                uiconn.delete(s.schema_id)
                                dconn = DefaultData(conn)
                                dconn.delete(s.schema_id)
                                eoconn = EditObject(conn)
                                eoconn.delete(s.schema_id)
                        sconn.delete(f.form_id)
                    plconn = Label(conn)
                    plconn.delete_in_properties_name(ls)
                    fconn.delete(page['page_id'])

                pconn = Page(conn)
                prconn = PageRel(conn)
                pIds = prconn.gets(page['page_id'])
                if page['page_auth'] is None and is_empty(pIds) == False:
                    order = pconn.get_max_order_by()[0]
                    for idx in range(len(pIds)):
                        pr = PageRelSchema(many=False).dump(pIds[idx])
                        pconn.update({
                            'page_id': pr['page_id'],
                            'page_order': (order + idx)
                        })
                    prconn.delete(page['page_id'], True)
                pconn.delete(page['page_id'])

            sconn = PageMenu(conn, 'items')
            menu = sconn.get_menus(cId, 'ja')
            result = PageMenuSchema(many=True).dump(menu)
        else:
            result = {'error': 'Not Server Info!!!'}
    except Exception as ex:
        result = {'error': str(ex)}
        # result = str(ex)
    finally:
        if conn is not None:
            conn.close_session()

    return result
コード例 #15
0
ファイル: page.py プロジェクト: nguyenhuong791123/api
def setServicePage(page, cId, uId):
    uconn = None
    pconn = None
    lconn = None
    fconn = None
    sconn = None
    osccon = None
    eoconn = None
    psconn = None
    uiconn = None
    dconn = None
    result = None
    pl = None
    pls = None
    eos = None
    ul = None
    dl = None
    # customize = []
    try:
        conn = DB(get_common_db_info())
        conn = Server(conn)
        server = conn.get_server_by_type(cId, 0)
        if server is not None:
            server = ServerInfo(many=False).dump(server)
            uconn = DB(get_db_info(server))
            pconn = Page(uconn)
            if is_integer(page['page_id']) == True:
                pconn.update(page)
                result = page
                pdplsconn = Label(uconn)
                pdplsconn.delete_page_id(page['page_id'])
            else:
                page['page_order'] = pconn.get_max_order_by()
                pconn.__json__(page, cId, uId)
                pconn.add(pconn)
                result = PageMenuSchema(many=False).dump(pconn)
                result['items'] = []
                pk = result['page_key'] + '_' + '{0:07}'.format(
                    result['page_id'])
                result['page_key'] = pk
                result['page_id_seq'] = 'integer_seq_id_' + pk.replace(
                    'customize.table_', '')
                pconn.update(result)

            ul = []
            dl = []
            pls = []
            plsconn = Label(uconn)
            pln = {}
            pln['schema_id'] = result['page_id']
            pln['properties_name'] = str(result['page_id'])
            pln['object_label'] = {'ja': page['page_name']}
            plsconn.__json__(pln)
            pls.append(plsconn)

            addIdSeq = True
            forms = page['form']
            for f in forms:
                fconn = Form(uconn)
                if is_exist(f, 'form_id') == True and is_integer(
                        f['form_id']) == True:
                    form = f
                    fconn.update(form)
                else:
                    fconn.__json__(f, result['page_id'])
                    fconn.add(fconn)
                    form = FormSchema(many=False).dump(fconn)

                schema = []
                if isinstance(f['object'], list):
                    for obj in f['object']:
                        fc = {}
                        fc['object'] = obj
                        schema.append(fc)
                else:
                    schema.append(f)

                # print(schema)
                pl = []
                os = []
                pts = []
                eos = []
                for sc in schema:
                    if is_exist(sc['object'], 'schema') == False:
                        continue

                    sconn = Schema(uconn)
                    objschema = sc['object']['schema']
                    if is_exist(objschema, 'schema_id') == True and is_integer(
                            objschema['schema_id']) == True:
                        s = objschema
                        sconn.update(s)
                    else:
                        sconn.__json__(objschema, form['form_id'])
                        sconn.add(sconn)
                        s = SchemaSchema(many=False).dump(sconn)

                    if is_integer(
                            page['page_id']) == False and addIdSeq == True:
                        psconn = Properties(uconn)
                        psconn.__json__(
                            getProperties(result['page_id_seq'],
                                          s['schema_id']))
                        pl.append(psconn)
                        plsconn = Label(uconn)
                        plsconn.__json__(
                            getLabels(result['page_id_seq'], s['schema_id'], {
                                'en': 'ID',
                                'ja': 'ID',
                                'vi': 'ID'
                            }))
                        pls.append(plsconn)
                        uiconn = Ui(uconn)
                        uiconn.__json__(
                            getUis(result['page_id_seq'], s['schema_id'],
                                   {'ui:widget': 'hidden'}))
                        ul.append(uiconn)

                        tbl = result['page_id_seq'].replace(
                            'integer_seq_id_', '')
                        createdId = 'integer_' + tbl + '_created_id'
                        psconn = Properties(uconn)
                        psconn.__json__(
                            getProperties(createdId, s['schema_id']))
                        pl.append(psconn)
                        plsconn = Label(uconn)
                        plsconn.__json__(
                            getLabels(createdId, s['schema_id'], {
                                'en': 'Author',
                                'ja': '作成者',
                                'vi': 'Author'
                            }))
                        pls.append(plsconn)
                        uiconn = Ui(uconn)
                        uiconn.__json__(
                            getUis(createdId, s['schema_id'],
                                   {'ui:widget': 'hidden'}))
                        ul.append(uiconn)
                        createdTime = 'datetime_' + tbl + '_created_time'
                        psconn = Properties(uconn)
                        psconn.__json__(
                            getProperties(createdTime, s['schema_id']))
                        pl.append(psconn)
                        plsconn = Label(uconn)
                        plsconn.__json__(
                            getLabels(
                                createdTime, s['schema_id'], {
                                    'en': 'Created date',
                                    'ja': '作成日時',
                                    'vi': 'Created date'
                                }))
                        pls.append(plsconn)
                        uiconn = Ui(uconn)
                        uiconn.__json__(
                            getUis(createdTime, s['schema_id'],
                                   {'ui:widget': 'hidden'}))
                        ul.append(uiconn)

                        updatedId = 'integer_' + tbl + '_updated_id'
                        psconn = Properties(uconn)
                        psconn.__json__(
                            getProperties(updatedId, s['schema_id']))
                        pl.append(psconn)
                        plsconn = Label(uconn)
                        plsconn.__json__(
                            getLabels(updatedId, s['schema_id'], {
                                'en': 'Changer',
                                'ja': '更新者',
                                'vi': 'Changer'
                            }))
                        pls.append(plsconn)
                        uiconn = Ui(uconn)
                        uiconn.__json__(
                            getUis(updatedId, s['schema_id'],
                                   {'ui:widget': 'hidden'}))
                        ul.append(uiconn)
                        updatedTime = 'datetime_' + tbl + '_updated_time'
                        psconn = Properties(uconn)
                        psconn.__json__(
                            getProperties(updatedTime, s['schema_id']))
                        pl.append(psconn)
                        plsconn = Label(uconn)
                        plsconn.__json__(
                            getLabels(
                                updatedTime, s['schema_id'], {
                                    'en': 'Updated date',
                                    'ja': '更新日時',
                                    'vi': 'Updated date'
                                }))
                        pls.append(plsconn)
                        uiconn = Ui(uconn)
                        uiconn.__json__(
                            getUis(updatedTime, s['schema_id'],
                                   {'ui:widget': 'hidden'}))
                        ul.append(uiconn)
                    addIdSeq = False

                    if s['schema_id'] is not None and sc['object'] is not None:
                        if is_exist(objschema, 'obj') == True:
                            eoconn = EditObject(uconn)
                            eo = {}
                            eo['properties_name'] = s['schema_key']
                            eo['schema_id'] = s['schema_id']
                            eo['edit_type'] = 1
                            eo['value'] = objschema['obj']
                            eoconn.__json__(eo)
                            eos.append(eoconn)

                            if is_exist(objschema['obj'], 'label') == True:
                                plsconn = Label(uconn)
                                pln = {}
                                pln['schema_id'] = s['schema_id']
                                pln['properties_name'] = s['schema_key']
                                pln['object_label'] = objschema['obj']['label']
                                plsconn.__json__(pln)
                                pls.append(plsconn)

                        psconn = Properties(uconn)
                        plsconn = Label(uconn)
                        pp = objschema['properties']
                        for key in pp.keys():
                            if is_exist(pp[key], 'options') == True:
                                if is_exist(
                                        pp[key],
                                        'option_target') == False or is_empty(
                                            pp[key]['option_target']) == True:
                                    osccon = Options(uconn)
                                    osccon.add_patition(key)
                                    pts.append(key)
                                    pp[key]['option_target'] = key
                                    idx = 0
                                    for opt in pp[key]['options']:
                                        osccon = Options(uconn)
                                        o = {}
                                        o['option_name'] = key
                                        o['option_code'] = opt['value']
                                        o['option_value'] = opt['label']
                                        o['option_order'] = idx
                                        o['company_id'] = cId
                                        osccon.__json__(o)
                                        os.append(osccon)
                                        idx += 1

                            psconn = Properties(uconn)
                            p = {}
                            p['properties_name'] = key
                            p['schema_id'] = s['schema_id']
                            p['value'] = pp[key]
                            psconn.__json__(p)
                            pl.append(psconn)
                            # if is_integer(page['page_id']) and key.endswith('_customize'):
                            #     customize.append(key)

                            if is_exist(pp[key], 'obj') == True and is_exist(
                                    pp[key]['obj'], 'label'):
                                plsconn = Label(uconn)
                                pln = {}
                                pln['schema_id'] = s['schema_id']
                                pln['properties_name'] = key
                                pln['object_label'] = pp[key]['obj']['label']
                                plsconn.__json__(pln)
                                pls.append(plsconn)

                                eoconn = EditObject(uconn)
                                eo = {}
                                eo['properties_name'] = key
                                eo['schema_id'] = s['schema_id']
                                eo['edit_type'] = 1
                                eo['value'] = pp[key]['obj']
                                eoconn.__json__(eo)
                                eos.append(eoconn)
                            if is_integer(
                                    page['page_id']
                            ) == True and key.find('_seq_id_') > 0:
                                plsconn = Label(uconn)
                                pln = {}
                                pln['schema_id'] = s['schema_id']
                                pln['properties_name'] = key
                                pln['object_label'] = {
                                    'en': 'ID',
                                    'ja': 'ID',
                                    'vi': 'ID'
                                }
                                plsconn.__json__(pln)
                                pls.append(plsconn)

                        if is_exist(sc['object'], 'ui') == True:
                            uiconn = Ui(uconn)
                            ui = sc['object']['ui']
                            for key in ui.keys():
                                uiconn = Ui(uconn)
                                u = {}
                                u['properties_name'] = key
                                u['schema_id'] = s['schema_id']
                                u['value'] = ui[key]
                                uiconn.__json__(u)
                                ul.append(uiconn)

                        if is_exist(sc['object'], 'data') == True:
                            dconn = DefaultData(uconn)
                            dt = sc['object']['data']
                            for key in dt.keys():
                                dconn = DefaultData(uconn)
                                d = {}
                                d['properties_name'] = key
                                d['schema_id'] = s['schema_id']
                                d['value'] = dt[key]
                                dconn.__json__(d)
                                dl.append(dconn)

                        if pl:
                            dpsconn = Properties(uconn)
                            dpsconn.delete(s['schema_id'])
                        if pls:
                            dplsconn = Label(uconn)
                            dplsconn.delete(s['schema_id'])
                        if eos:
                            deoconn = EditObject(uconn)
                            deoconn.delete(s['schema_id'])
                        if os:
                            osccon.add_all(os)
                        if ul:
                            duiconn = Ui(uconn)
                            duiconn.delete(s['schema_id'])
                        if dl:
                            ddconn = DefaultData(uconn)
                            ddconn.delete(s['schema_id'])

                if pl:
                    psconn.add_all(pl)
                if pls:
                    plsconn.add_all(pls)
                if eos:
                    eoconn.add_all(eos)
                if ul:
                    uiconn.add_all(ul)
                if dl:
                    dconn.add_all(dl)

            page['page_key'] = result['page_key']
            if is_integer(page['page_id']) == False:
                pconn.create_table(page)
            # else:
            #     print(customize)
        else:
            result = {'error': 'Not Server Info!!!'}
    except Exception as ex:
        if is_integer(page['page_id']) == False:
            if pl:
                psconn.delete(s['schema_id'])
            if pls:
                plsconn.delete_in_properties_name(
                    [d.properties_name for d in pls])
            if eos:
                eoconn.delete(s['schema_id'])
            if ul:
                uiconn.delete(s['schema_id'])
            if dl:
                dconn.delete(s['schema_id'])
            if osccon is not None and pts:
                for pt in pts:
                    osccon.drop_patition(pt)
            if uiconn is not None and is_exist(s, 'schema_id') == True:
                uiconn.delete(s['schema_id'])
            if dconn is not None and is_exist(s, 'schema_id') == True:
                dconn.delete(s['schema_id'])
            if psconn is not None and is_exist(s, 'schema_id') == True:
                psconn.delete(s['schema_id'])
            if eoconn is not None and is_exist(s, 'schema_id') == True:
                eoconn.delete(s['schema_id'])
            if sconn is not None and is_exist(form, 'form_id') == True:
                sconn.delete(form['form_id'])
            if fconn is not None and is_exist(result, 'page_id') == True:
                fconn.delete(result['page_id'])
            if lconn is not None and is_exist(result, 'page_id') == True:
                lconn.delete(result['page_id'], 1)
            if pconn is not None and is_exist(result, 'page_id') == True:
                pconn.delete(result['page_id'])

        result = {'error': str(ex)}
    finally:
        if uconn is not None:
            uconn.close_session()

    return result