def editLabourer(self,clientId,msgDict,sessionkey): masterDb = DatabaseAgent(conf.mdbName,conf.muserName,conf.host,conf.mdbPassword,conf.port) masterDb.initConnection() cond = {"clientid":clientId} dbData = masterDb.fetchData("regusers",["password"],cond) password = dbData[0][0] adminDb = DatabaseAgent(clientId, clientId, conf.host,password, 5432) adminDb.initConnection() condition = {"labourerid": msgDict["labourerId"]} changDist = {} for key in msgDict: if key == "labourerId": continue else: changDist[key.lower()] = (msgDict[key]) try: if adminDb.editData("labourer",changDist,condition): self.log.logEvent("labourerManage",2,"labourer Edited success",clientId,sessionMange.session[sessionkey]["userid"]) response = {"Header":{"status":"success","module":"labourerManage"},"Body":{"message":"labourer edited successfully","data":""},"Signature":{"signature":"","Key":""}} return response else: self.log.logEvent("labourerManage",2,"labourer labourer can't ediot",clientId,sessionMange.session[sessionkey]["userid"]) response = {"Header":{"status":"fail","module":"labourerManage"},"Body":{"message":"labourer canot edited","data":""},"Signature":{"signature":"","Key":""}} return response except Exception as expc: # self.syslog.eventHandle("labourerManage","exception","exception on labourerManage module",str(expc)) self.log.logEvent("labourerManage",2,"occured expection is"+str(expc),clientId,sessionMange.session[sessionkey]["userid"])
def shiftAssingn(self,clientId,msgDict,sessionkey): masterDb = DatabaseAgent(conf.mdbName,conf.muserName,conf.host,conf.mdbPassword,conf.port) masterDb.initConnection() cond = {"clientid":clientId} dbData = masterDb.fetchData("regusers",["password"],cond) password = dbData[0][0] adminDb = DatabaseAgent(clientId, clientId, conf.host,password, 5432) adminDb.initConnection() changDict = {"shiftid":msgDict["shiftId"]} condition = {} for key in msgDict: condition[key.lower()] = (msgDict[key]) self.log.logEvent("shiftManage",2,"shift assigned successfully",clientId,sessionMange.session[sessionkey]["userid"]) reval = False try: reval = adminDb.editData("labourer",changDict,condition) except Exception as expc: # self.syslog.eventHandle("shiftmanage","exception","exception on shiftManage module",str(expc)) print("oocured exception is",expc) if reval: self.log.logEvent("shiftManage",2,"shift can't assigned ",clientId,sessionMange.session[sessionkey]["userid"]) return "shift assingend successfully" #admin.labouerList()
def editProjects(self, clientId, msgDict): masterDb = DatabaseAgent(conf.mdbName, conf.muserName, conf.host, conf.mdbPassword, conf.port) masterDb.initConnection() cond = {"clientid": clientId} dbData = masterDb.fetchData("regusers", ["password"], cond) password = dbData[0][0] adminDb = DatabaseAgent(clientId, clientId, conf.host, password, 5432) adminDb.initConnection() condition = {"projectid": msgDict["projectId"]} changDist = {} for key in msgDict: if "projectId" == key: continue else: changDist[key.lowe()] = (msgDict[key]) try: if adminDb.editData("projects", changDist, condition): self.log.logEvent("projectManage", 0, "project edited successfully", clientId, sessionMange.session[sessionkey]["userid"]) response = { "Header": { "status": "success", "module": "projectManage" }, "Body": { "message": "project edited successfully", "data": "" }, "Signature": { "signature": "", "Key": "" } } return response else: self.log.logEvent("projectManage", 0, "project database error ", clientId, sessionMange.session[sessionkey]["userid"]) response = { "Header": { "status": "fail", "module": "projectManage" }, "Body": { "message": "project can't edited", "data": "" }, "Signature": { "signature": "", "Key": "" } } return response except Exception as expc: # self.syslog.eventHandle("projectmanagement","exception","exception on projectManage module",str(expc)) self.log.logEvent( "projectManage", 3, " all role permission listed occured " + str(expc), clientId, sessionMange.session[sessionkey]["userid"])
def editRoles(self, clientId, msgDict, sessionkey): masterDb = DatabaseAgent(conf.mdbName, conf.muserName, conf.host, conf.mdbPassword, conf.port) masterDb.initConnection() cond = {"clientid": clientId} dbData = masterDb.fetchData("regusers", ["password"], cond) password = dbData[0][0] adminDb = DatabaseAgent(clientId, clientId, conf.host, password, 5432) adminDb.initConnection() changDict = {} templist = [] valueList = [] for key in msgDict: if key == "roleName": continue elif key == "roleId": continue else: templist.append(msgDict[key]) bigstr = "" for val in templist: bigstr += val + "&&" # valuelist.append(bigstr) changDict["rolename"] = (msgDict["roleName"]) changDict["roleid"] = (msgDict["roleId"]) changDict["permissions"] = (bigstr) condition = {"roleid": msgDict["roleId"]} print("total.......................................", changDict) reval = False try: if adminDb.editData("permission", changDict, condition): self.log.logEvent( "roleManage", 3, msgDict["roleId"] + "role permission edited successfully", clientId, sessionMange.session[sessionkey]["userid"]) response = { "Header": { "status": "success", "module": "roleManage" }, "Body": { "message": "user role edited successfully", "data": "" }, "Signature": { "signature": "", "Key": "" } } return response else: self.log.logEvent( "roleManage", 3, msgDict["roleId"] + "role permission canot edited ", clientId, sessionMange.session[sessionkey]["userid"]) response = { "Header": { "status": "success", "module": "roleManage" }, "Body": { "message": "uerer role canot edit", "data": "" }, "Signature": { "signature": "", "Key": "" } } return response except Exception as expc: # self.syslog.eventHandle("rolemanagement","exception","exception on rolemanage module",str(expc)) self.log.logEvent("labourerManage", 2, "occured expection is" + str(expc), clientId, sessionMange.session[sessionkey]["userid"])
def editUser(self, clientId, msgDict, sessionkey): masterDb = DatabaseAgent(conf.mdbName, conf.muserName, conf.host, conf.mdbPassword, conf.port) masterDb.initConnection() cond = {"clientid": clientId} dbData = masterDb.fetchData("regusers", ["password"], cond) password = dbData[0][0] adminDb = DatabaseAgent(clientId, clientId, conf.host, password, 5432) adminDb.initConnection() condition = {"employeeid": msgDict["employeeId"]} changDist = {} for key in msgDict: if key == "emplyeeId": continue else: changDist[key.lower()] = (msgDict[key]) try: if adminDb.editData("clientusers", changDist, condition): self.log.logEvent( "Admin", 2, msgDict["employeeId"] + "user edited successfully", clientId, sessionMange.session[sessionkey]["userid"]) # datalis = ["fullname","employeeid","designation","emailid","userrole",'archive'] # adminDb.fetchData("clients",datalis) response = { "Header": { "status": "success", "module": "admin" }, "Body": { "message": "user deatils edited successfully", "data": "" }, "Signature": { "signature": "", "Key": "" } } return response else: self.log.logEvent("Admin", 2, "user cant edited", clientId, sessionMange.session[sessionkey]["userid"]) response = { "Header": { "status": "success", "module": "admin" }, "Body": { "message": "user deatils can't edited ", "data": "" }, "Signature": { "signature": "", "Key": "" } } return response except Exception as expc: self.log.logEvent("Admin", 0, "occured exception is " + str(expc), clientId, sessionMange.session[sessionkey]["userid"])