示例#1
0
def Index(request):
    #tname , jsonstr = excel_to_json_new('D:/Work/Project/80_ServerProject/Source/ServerPatchUtil/WebGMTool_mvc/GameServerTableNew/ModuleItemTable.xlsm');
    #print(tname,jsonstr)
    #find_all_excel_file('D:/Work/Project/80_ServerProject/Source/ServerPatchUtil/WebGMTool_mvc/GameServerTableNew')
    #tsting = json_table_file_read('../NewTable/GameResultReward.json')
    #print(tsting)
    cbq = CouchbaseManager.instance()
    db_size = cbq.Get_DBPool_Size()

    if ( 0 == db_size) :
        InitCouchBase()

    if request.method =='POST' :
        return LoginProcess(request)

    #login_user = request.COOKIES.get('LoginUser', 'None')
    #login_user = request.session.get('LoginUser', 'None')
    #if 'None' != login_user :
    if (3 < db_size):
        return LoginMain(request)

    cbq = CouchbaseManager.instance()

    cbq.select_db(eDataBase.GM_Tool)
    list = []
    cresult = cbq.get_server_list()
    for row in cresult:
        strjson = str(row)
        cMessage = json.JSONEncoder().encode(row)
        objServer = json.loads(cMessage, object_hook=lambda d: Namespace(**d))
        list.append(objServer.name)
        cbq.AddServerInfo(objServer.name, objServer)

    return render(request,'WebTool/Index.html',{'server_list':json.dumps(list)})
示例#2
0
def SaveRotationData(request):
    data = request.POST.get('table')
    cRotationTable = json.loads(data)
    cbq = CouchbaseManager.instance()
    cbq.select_db(eDataBase.GAME_EVENT)
    cbq.get().upsert("RotationTable_Python", cRotationTable)
    return JsonResponse({'Result': "true"}, safe=False)
示例#3
0
def GetRotationTable():
    cbq = CouchbaseManager.instance()
    try:
        cbq.select_db(eDataBase.GAME_EVENT)
        cRotationTable = cbq.get().get("RotationTable_Python").value
        return json.dumps(cRotationTable, ensure_ascii=False)
    except Exception as e:
        return InitRotationTable()
示例#4
0
def LogOut(request):
    try:
        session_keys = list(request.session.keys())
        for key in session_keys:
            del request.session[key]
        cbq = CouchbaseManager.instance()
        cbq.clear()
    except Exception as e : pass
    return HttpResponseRedirect('/')
示例#5
0
def InitCouchBase( ):
    json_data = open('./WebTool/Config.json').read()
    data = json.loads(json_data)
    #print(data)

    #print(data["Config"][0])
    cbq = CouchbaseManager.instance()
    cbq.Add(data["Config"][0]["index"], data["Config"][0]["name"], data["Config"][0]["ip"], data["Config"][0]["user"], data["Config"][0]["pass"], data["Config"][0]["name"])
    cbq.Add(data["Config"][1]["index"], data["Config"][1]["name"], data["Config"][1]["ip"], data["Config"][1]["user"], data["Config"][1]["pass"], data["Config"][1]["name"])
    cbq.Add(data["Config"][2]["index"], data["Config"][2]["name"], data["Config"][2]["ip"], data["Config"][2]["user"], data["Config"][2]["pass"], data["Config"][2]["name"])
示例#6
0
def get_tree_menu():
    cbq = CouchbaseManager.instance()
    cbq.select_db(eDataBase.GM_Tool)
    cMenu = cbq.get().get("ToolMenu_Python")
    msg = str(cMenu.value)
    idx = msg.find(":")
    if (idx != -1):
        msg = msg[idx + 1:]
        msg = msg[:-1]
    return json.dumps(msg, ensure_ascii=False)
示例#7
0
def RotationView(request):
    if request.method == 'POST':
        return PostProcess(request)

    cbq = CouchbaseManager.instance()
    cServerInfo = cbq.get_select_server_info()

    return render(request, 'WebTool/Rotation.html', {
        "server_name": cServerInfo.name,
        "server_ip": cServerInfo.IP
    })
示例#8
0
def NewServerTableVeiw(request):

    cbq = CouchbaseManager.instance()
    cServerInfo = cbq.get_select_server_info()

    lstxlsfile = find_all_excel_file('./NewTable')
    #print(lstxlsfile)
    return render(
        request, 'WebTool/NewServerTable.html', {
            "server_name": cServerInfo.name,
            "server_ip": cServerInfo.IP,
            "lxs_files": json.dumps(lstxlsfile)
        })
示例#9
0
def GetModeTable():
    cbq = CouchbaseManager.instance()

    cbq.select_db(eDataBase.GAME_EVENT)
    cModeTable = cbq.get().get("ModeTable_Python").value
    #cResult = cbq.RunQuery("select  mode  from eventdb_dev where   strType = 'Mode'")
    #for row in cResult:
    #strJson = str(row)[9:]
    #strJson =strJson[:-1]
    #   strJson = str(row).replace("'","\"")
    #   strJson = strJson.replace("True", "\"True\"")
    #   print(strJson )

    #    cModeTable = json.loads(strJson)
    #    print(cModeTable)
    #    #list_values = [v for v in cModeTable.values()]
    return json.dumps(cModeTable, ensure_ascii=False)
示例#10
0
def GetRotationMerTable():
    cbq = CouchbaseManager.instance()
    cbq.select_db(eDataBase.GAME_EVENT)
    try:
        cMerTable = cbq.get().get("CharacterTable").value
        cSkinTable = cbq.get().get("SkinTable").value

        objServer = json.loads(cMerTable)
        objSkin = json.loads(cSkinTable)
        lstFilter = []
        for key in objSkin["m_mapTableData"]:
            if objSkin["m_mapTableData"][key]["m_iDefaultSkin"] != 1:
                icode = objSkin["m_mapTableData"][key]["m_iSkinCharacterCode"]
                lstFilter.append(icode)
        #print(lstFilter)

        strJson = "[{\"Value\": -1,\"Text\" :\"None\"},"
        for key in objServer["m_mapTableData"]:
            iMercenary = objServer["m_mapTableData"][key]["m_iCode"]
            try:
                i = lstFilter.index(iMercenary)
                if 0 < i:
                    continue
            except Exception as e:
                pass
            strJson += "{"
            strJson += "\"Value\":" + str(
                objServer["m_mapTableData"][key]["m_iCode"]) + ","
            strJson += "\"Text\" :\"" + str(objServer["m_mapTableData"][key]
                                            ["m_strCharacterName"]) + "\"},"

        strJson = strJson[:-1]
        strJson += "]"
        #print(strJson)
    except Exception as e:
        print("error : " + str(e))
    else:
        pass
    return strJson
示例#11
0
def LoginProcess(request):

    cbq = CouchbaseManager.instance()
    cBucket = cbq.get_bucket(eDataBase.GM_Tool)
    userid = request.POST.get('id')
    userpasswd = request.POST.get('userpass')
    strServer = request.POST.get('Select_Server')
    bReturn = False

    try:
        ret = cBucket.get(userid).value
        cUser = json.loads(ret, encoding="utf-8", object_hook=lambda d: Namespace(**d))
        if cUser.passwd == userpasswd:
            cbq.SelectServer(strServer)
            cbq.SetLoginUser(userid)
            bReturn = True
            #request.COOKIES["LoginUser"] = userid
            request.session['LoginUser'] = userid
        else: pass
    except Exception as e:
        print(str(e))
    else:
        pass
    return JsonResponse({'Result':bReturn}, safe=False)
示例#12
0
def LoginMain(request):
    cbq = CouchbaseManager.instance()
    cServerInfo = cbq.get_select_server_info()

    return render(request, 'WebTool/LoginMain.html',{"server_name": cServerInfo.name,"server_ip": cServerInfo.IP})
示例#13
0
def getselectserverurl(request):
    cbq = CouchbaseManager.instance()
    cServerInfo = cbq.get_select_server_info()
    return JsonResponse({'Status': '0','Url': cServerInfo.IP}, safe=False)
示例#14
0
def GetSelectServerName():
    cbq = CouchbaseManager.instance()
    return cbq.get_select_server_name()
示例#15
0
def ServerMonitorView(request):

    cbq = CouchbaseManager.instance()
    cServerInfo = cbq.get_select_server_info()

    return render(request, 'WebTool/ServerMonitor.html',{"server_name": cServerInfo.name,"server_ip": cServerInfo.IP})