def __init__(self, arg=None): """ :rtype: object """ super(KnowlegeForm, self).__init__(arg) self.setWindowIcon(QIcon(r'Res\logo.png')) self.setWindowTitle("超级智慧终端") wd = QApplication.desktop().width() hd = QApplication.desktop().height() self.setMinimumWidth(wd * 0.8) self.setMinimumHeight(hd * 0.8) self.setupUi(self) self.setWindowFlags(Qt.CustomizeWindowHint) self.setWindowFlags(Qt.FramelessWindowHint) self.setStyleSheet( "#middleWidget{border-radius:2px; background:rgba(255, 255, 255,1);};border:1px groove gray;" ) # 窗口移动 self.m_flag = False self.m_Position = None self.initLogger() StorageHelper(ShareDatas.Global_LOGGER, "ns_account") StorageHelper(ShareDatas.Global_LOGGER, "ns_knowleges") StorageHelper(ShareDatas.Global_LOGGER, "ns_knowlege_map_lab") StorageHelper(ShareDatas.Global_LOGGER, "ns_labels") return
def createCustom(ucode): handle = StorageHelper(None, StorageType.Custom) data = ReadDataHelper() data.SetDBService(handle) handle.StartStorageServce() register = {} register["name"] = "未知" register["ucode"] = ucode register["sex"] = "男" register["age"] = 26 register["idcard"] = "" register["feature"] = None register["photo"] = None register["level"] = 1000 handle.InsertData(register) # # 重新查询终端文档 # results = data.QueryData() # rtnHandle = None # for oneT in results: # if oneT["conid"] == conid: # rtnHandle = oneT # break # handle.StopStorageServce()
def delete(self): handle = StorageHelper(None, StorageType.Custom) handle.StartStorageServce() try: result = handle.GetDBHandle().delete(self.recordInstance) result = True except Exception as ex: result = False handle.StopStorageServce() # db.delete(doc) return result
def saveDoc(doc): handle = StorageHelper(None, StorageType.Custom) handle.StartStorageServce() try: result = handle.GetDBHandle().update(doc) result = True except Exception as ex: result = False handle.StopStorageServce() # db.delete(doc) return result
def queryCustomActivity(startDate, stopDate): # 查询客户活动数据 handle = StorageHelper(None, StorageType.Activity) data = ReadDataHelper() data.SetDBService(handle) handle.StartStorageServce() # 重新查询终端文档 activitys = data.QueryRangeData(lgt_conditions=startDate, ltt_condition=stopDate, cmp_key="actdate") handle.StopStorageServce() # 查询客户数据 handle = StorageHelper(None, StorageType.Custom) dataCustom = ReadDataHelper() dataCustom.SetDBService(handle) handle.StartStorageServce() # 查询客户数据 customs = dataCustom.QueryData() # 返回客户活动数据 # 遍历 活动数据 # rtnCustomActivity = [] for oneActivity in activitys: uCode = oneActivity["ucode"] inDate = oneActivity["actdate"] seconds = oneActivity["measure1"] # 缺省为普通账户 uLevel = None userName = None userSex = "男" userAge = 26 for oneCustom in customs: if not isinstance(oneCustom, dict): continue if oneCustom["ucode"] == uCode: uLevel = oneCustom["level"] userName = oneCustom["name"] userSex = oneCustom["sex"] userAge = int(oneCustom["age"]) break if not uLevel: continue rtnCustomActivity.append({ "ucode": uCode, "date": inDate, "seconds": seconds, "ulevel": uLevel, "name": userName, "sex": userSex, "age": userAge }) handle.StopStorageServce() return rtnCustomActivity
def queryCustom(ucode): handle = StorageHelper(None, StorageType.Custom) data = ReadDataHelper() data.SetDBService(handle) handle.StartStorageServce() conditions = {'ucode': ucode} # 重新查询终端文档 results = data.QueryData(conditions=conditions) rtnHandle = None for oneT in results: rtnHandle = oneT break handle.StopStorageServce() return rtnHandle
def queryCustoms(): handle = StorageHelper(None, StorageType.Custom) data = ReadDataHelper() data.SetDBService(handle) handle.StartStorageServce() # 重新查询终端文档 results = data.QueryData() allCustoms = [] for oneT in results: oneCustom = CustomModel() oneCustom.recordInstance = oneT oneCustom.UCode = oneCustom.recordInstance["ucode"] allCustoms.append(oneCustom) handle.StopStorageServce() return allCustoms
def save(self): handle = StorageHelper(None, StorageType.Custom) handle.StartStorageServce() # 先尝试更新 try: result = handle.GetDBHandle().update(self.recordInstance) result = True except Exception as ex: result = False # 再尝试插入 if not result: try: result = handle.GetDBHandle().insert(self.recordInstance) result = True except Exception as ex: result = False handle.StopStorageServce() # db.delete(doc) return result