def AddNewdRec(dbConn, ustrContent, iTypeS, ustrFromS, iFromType,
                   ustrFromGroupName, iExecStatus):
        ustrContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrContent)
        ustrFromS = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrFromS)
        ustrFromGroupName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
            ustrFromGroupName)

        iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField6(
            dbConn, CSkLBDB_ow_bot_out_chatcontent.s_strTableName, "content",
            ustrContent,
            "type_s", str(iTypeS), "from_s", ustrFromS, "fromtype",
            str(iFromType), "from_group_name", ustrFromGroupName, "ex_status",
            str(iExecStatus))
        if (iRetNewRecID > 0):
            createTime = datetime.now()
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_ow_bot_out_chatcontent.s_strTableName,
                "createtime", createTime, "id", str(iRetNewRecID))
        return iRetNewRecID
Exemple #2
0
    def ExecInsertRecField2(dbConn, strTable, strField1, strValue1, strField2,
                            strValue2):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strField1 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField1)
        strValue1 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue1)
        strField2 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField2)
        strValue2 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue2)

        strInsertSQL = "insert into " + strTable + " (" + strField1 + "," + strField2 + ") values(%s,%s)"
        # insert into table (field) values(%s)
        insertCur = dbConn.cursor()
        try:
            insertCur.execute(strInsertSQL, (strValue1, strValue2))
            iRetRecID = insertCur.lastrowid
            dbConn.commit()
        except Exception as e:
            iRetRecID = 0
        insertCur.close()
        return iRetRecID
 def GetRecID_By_AppTaskNameID_ParamID(dbConn, iBelongAppTaskNameID,
                                       strParamID):
     strParamID = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strParamID)
     strClause = "belong_app_task_name_id=%d and param_id='%s'" % (
         iBelongAppTaskNameID, strParamID)
     iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
         dbConn, CSkLBDB_result_param_block.s_strTableName, "id", strClause)
     if (not iRetID):
         iRetID = 0
     return iRetID
 def GetRecID_By_EnviruID_PropName(dbConn, iBelongEnviruID, ustrPropName):
     ustrPropName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrPropName)
     strClause = "belong_envirument_id=%d and prop_name='%s'" % (
         iBelongEnviruID, ustrPropName)
     iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
         dbConn, CSkLBDB_ea_brain_enviru_property.s_strTableName, "id",
         strClause)
     if (not iRetID):
         iRetID = 0
     return iRetID
Exemple #5
0
    def __listen_basic_handle(self, sockManager, clientSock, ctUnitArray):
        strPeerName, iPeerPort = sockManager.GetSockPeerAddr(clientSock)
        if isinstance(strPeerName, bytes):
            strPeerName = strPeerName.decode()
        retDataArray = []
        isNonePackageReply = True
        arrayLen = len(ctUnitArray)
        packageCount = 0
        for eachCTUnit in ctUnitArray:
            packageCount += 1
            eachRetCommCTUnitArray = []
            if (eachCTUnit.s_iMyDataType ==
                    CTYLB_Bot_BaseDef.s_g_iDataType_CommonTask):

                if eachCTUnit.s_iValue in self.__listen_callbacks.keys():
                    eachRetCommCTUnitArray = self.__listen_callbacks[
                        eachCTUnit.s_iValue](
                            CTYLB_MainSys_MiscFunc.SafeGetUnicode(strPeerName),
                            CTYLB_MainSys_MiscFunc.SafeGetUnicode(
                                eachCTUnit.s_strValue),
                            CTYLB_MainSys_MiscFunc.SafeGetUnicode(
                                eachCTUnit.s_strParam1),
                            CTYLB_MainSys_MiscFunc.SafeGetUnicode(
                                eachCTUnit.s_strParam2),
                            packageCount == arrayLen)

            if (eachRetCommCTUnitArray):
                isNonePackageReply = False
                retDataArray.extend(eachRetCommCTUnitArray)
        # 如果没有内容,那么,放一个空单元
        if isNonePackageReply:
            sendCTUnit = CTYBot_CTUnit_CommonData()
            retDataArray.append(sendCTUnit)
        sockManager.PassiveSend_To_AcceptSock(clientSock, retDataArray)
        if self.__report_status:
            if strPeerName in self.__node_status.SocksInfo['Socks'].keys():
                self.__node_status.SocksInfo['Socks'][strPeerName][
                    'Status'] = "Up"
                self.__node_status.SocksInfo['Socks'][strPeerName][
                    'TotalSend'] += len(ctUnitArray)
                self.__node_status.SocksInfo['Socks'][strPeerName][
                    'LastSendTime'] = NodeStatus.get_now_timestamp()
                self.__node_status.SocksInfo['TotalSend'] += len(ctUnitArray)
 def AddNewdRec(dbConn, iBelongAppTaskNameID, strParamID):
     strParamID = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strParamID)
     iRetNewRecID = CSkLBDB_result_param_block.GetRecID_By_AppTaskNameID_ParamID(
         dbConn, iBelongAppTaskNameID, strParamID)
     if (iRetNewRecID == 0):
         iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField2(
             dbConn, CSkLBDB_result_param_block.s_strTableName,
             "belong_app_task_name_id", str(iBelongAppTaskNameID),
             "param_id", strParamID)
     return iRetNewRecID
 def AddNewdRec(dbConn,
                iBelongParamID,
                strTitleName,
                strResultContent,
                createTime=None):
     strTitleName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTitleName)
     strResultContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
         strResultContent)
     iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField3(
         dbConn, CSkLBDB_result_content.s_strTableName, "belong_param_id",
         str(iBelongParamID), "title_name", strTitleName, "result_content",
         strResultContent)
     if (not createTime):
         createTime = datetime.now()
     if ((iRetNewRecID > 0) and (createTime)):
         CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
             dbConn, CSkLBDB_result_content.s_strTableName, "create_time",
             createTime, "id", str(iRetNewRecID))
     return iRetNewRecID
Exemple #8
0
    def __ExecUpdateSQL(dbConn, strUpdateSQL):
        strUpdateSQL = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strUpdateSQL)

        updateCur = dbConn.cursor()
        try:
            updateCur.execute(strUpdateSQL)
        except Exception as e:
            pass
        updateCur.close()
        dbConn.commit()  # 确认更新记录
Exemple #9
0
    def Read3Fields_Array_WithClause_limit(dbConn,
                                           strTable,
                                           strField1,
                                           strField2,
                                           strField3,
                                           strClause,
                                           iLimitCount,
                                           bExecCommit=True):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strField1 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField1)
        strField2 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField2)
        strField3 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField3)
        strClause = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strClause)

        objRetField1Array = []
        objRetField2Array = []
        objRetField3Array = []
        strCombFields = strField1
        if (len(strField2) > 0):
            strCombFields += "," + strField2
        if (len(strField3) > 0):
            strCombFields += "," + strField3

        strLimitClause = ""
        if (iLimitCount > 0):
            strLimitClause = " limit %d" % (iLimitCount)

        strQueryReply = "select " + strCombFields + " from " + strTable + " where " + strClause + strLimitClause
        recFrameReply = pd.read_sql_query(strQueryReply, dbConn)  # 转成DataFrame
        recCount = len(recFrameReply)  # 记录个数
        for iIndex in range(recCount):
            objFieldValue = recFrameReply[strField1][iIndex]
            objRetField1Array.append(objFieldValue)
            if (len(strField2) > 0):
                objFieldValue = recFrameReply[strField2][iIndex]
                objRetField2Array.append(objFieldValue)
            if (len(strField3) > 0):
                objFieldValue = recFrameReply[strField3][iIndex]
                objRetField3Array.append(objFieldValue)
        if (bExecCommit):
            dbConn.commit()
        return objRetField1Array, objRetField2Array, objRetField3Array
 def AddNewdRec(dbConn, ustrUserName):
     ustrUserName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrUserName)
     iOrigRecID = CSkLBDB_ea_brain_usermang.GetRecID_By_UserName(
         dbConn, ustrUserName)
     if (not iOrigRecID):
         iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField1(
             dbConn, CSkLBDB_ea_brain_usermang.s_strTableName, "username",
             ustrUserName)
     else:
         iRetNewRecID = iOrigRecID
     return iRetNewRecID
 def GetRecID_By_UserID_GroupName(dbConn, iUserNameID, ustrBelongGroupName):
     ustrBelongGroupName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
         ustrBelongGroupName)
     strClause = "belong_usermang_id=%d and belong_group_name='%s'" % (
         iUserNameID, ustrBelongGroupName)
     iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
         dbConn, CSkLBDB_ea_brain_envirument.s_strTableName, "id",
         strClause)
     if (not iRetID):
         iRetID = 0
     return iRetID
Exemple #12
0
    def ReadField_Array_WithClause(dbConn,
                                   strTable,
                                   strField,
                                   strClause,
                                   bExecCommit=True):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strField = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField)
        strClause = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strClause)

        objRetFieldArray = list()

        strQueryReply = "select " + strField + " from " + strTable + " where " + strClause
        recFrameReply = pd.read_sql_query(strQueryReply, dbConn)  # 转成DataFrame
        recCount = len(recFrameReply)  # 记录个数
        for iIndex in range(recCount):
            objFieldValue = recFrameReply[strField][iIndex]
            objRetFieldArray.append(objFieldValue)
        if (bExecCommit):
            dbConn.commit()
        return objRetFieldArray
 def GetRecID_By_OperateID_ParamBlockID(dbConn, iBelongOperateID,
                                        strParamBlockID):
     strParamBlockID = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
         strParamBlockID)
     strClause = "belong_dest_operate_id=%d and param_block_id='%s'" % (
         iBelongOperateID, strParamBlockID)
     iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
         dbConn, CSkLBDB_dest_param_status.s_strTableName, "id", strClause)
     if (not iRetID):
         iRetID = 0
     return iRetID
Exemple #14
0
 def CanExecSendData(self):
     bRetValue = False
     if (not self.s_lastRecvCTArray):
         if (self.s_execHLSockMang.IsSockConnectSuccess(
                 self.s_iExecConnectSockIndex)):
             if (not self.s_bWaitReply):
                 if (CTYLB_MainSys_MiscFunc.CheckIdleTime(
                         self.s_lastSendTime,
                         self.s_iNextSendWaitCheckTick)):
                     bRetValue = True
     return bRetValue
Exemple #15
0
    def __init__(self, bstrHostName, iAcceptSockIndex):
        bstrHostName = CTYLB_MainSys_MiscFunc.SafeGetUTF8(bstrHostName)

        self.s_lastSendCmdTime = datetime(2017, 1, 1)
        self.s_lastClientStatusData = None
        self.s_bstrHostIDName = bstrHostName
        self.s_lastRecvStatusTime = datetime.now()
        self.s_bstrTaskParamSignArray = []  # 任务参数队列

        self.s_iSock_AcceptFromRemotePlugin = iAcceptSockIndex  # 连接远端插件的管套ID
        self.s_toBeSendCTUnitArray = []  # 等待发送单元队列
Exemple #16
0
    def ExecUpdateRecField4(dbConn, strTable, strClause, strField1, strValue1,
                            strField2, strValue2, strField3, strValue3,
                            strField4, strValue4):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strClause = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strClause)
        strField1 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField1)
        strValue1 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue1)
        strField2 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField2)
        strValue2 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue2)
        strField3 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField3)
        strValue3 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue3)
        strField4 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField4)
        strValue4 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue4)

        strSetField1 = strField1 + "='" + strValue1 + "'"
        strSetField2 = strField2 + "='" + strValue2 + "'"
        strSetField3 = strField3 + "='" + strValue3 + "'"
        strSetField4 = strField4 + "='" + strValue4 + "'"
        strTotalSetField = strSetField1 + "," + strSetField2 + "," + strSetField3 + "," + strSetField4
        strModifySQL = "update " + strTable + " set " + strTotalSetField + "  where " + strClause
        CSkLBDB_CommFuncShare.__ExecUpdateSQL(dbConn, strModifySQL)
    def AddNewdRec(dbConn, strObjName, strPwdHash, strDbName, strTableName,
                   strFieldName, strSignIDField, iLastExID):
        strObjName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strObjName)
        strPwdHash = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strPwdHash)
        strDbName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strDbName)
        strTableName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTableName)
        strFieldName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strFieldName)
        strSignIDField = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strSignIDField)

        iOrigRecID = CSkLBDB_dest_operate.GetRecID_By_Name(dbConn, strObjName)
        if (iOrigRecID == 0):
            iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField7(
                dbConn, CSkLBDB_dest_operate.s_strTableName, "obj_name",
                strObjName, "pwd_hash", strPwdHash, "database_name", strDbName,
                "table_name", strTableName, "read_field_name_array",
                strFieldName, "sign_field_id", strSignIDField,
                "last_ex_id_value", str(iLastExID))
        else:
            # 更新字段
            strClause = 'id=%d' % (iOrigRecID)
            CSkLBDB_CommFuncShare.ExecUpdateRecField4(
                dbConn, CSkLBDB_dest_operate.s_strTableName, strClause,
                "pwd_hash", strPwdHash, "database_name", strDbName,
                "table_name", strTableName, "read_field_name_array",
                strFieldName)
            CSkLBDB_CommFuncShare.ExecUpdateRecField1(
                dbConn, CSkLBDB_dest_operate.s_strTableName, strClause,
                "sign_field_id", strSignIDField)
            iRetNewRecID = iOrigRecID
        return iRetNewRecID
    def AddNewdRec(dbConn,
                   ustrContent,
                   ustrTypeS,
                   ustrToS,
                   ustrToType,
                   ustrToGroupName,
                   ustrStatusS,
                   execSendTime=None):
        ustrContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrContent)
        ustrTypeS = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrTypeS)
        ustrToS = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrToS)
        ustrToType = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrToType)
        ustrToGroupName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
            ustrToGroupName)
        ustrStatusS = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrStatusS)

        iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField6(
            dbConn, CSkLBDB_ow_bot_in_sendchatcontent.s_strTableName,
            "content", ustrContent, "type_s", ustrTypeS, "to_s", ustrToS,
            "to_type", ustrToType, "to_group_name", ustrToGroupName,
            "status_s", ustrStatusS)
        if (iRetNewRecID > 0):
            createTime = datetime.now()
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_ow_bot_in_sendchatcontent.s_strTableName,
                "createtime", createTime, "id", str(iRetNewRecID))
            if (execSendTime):
                CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                    dbConn, CSkLBDB_ow_bot_in_sendchatcontent.s_strTableName,
                    "exec_send_time", execSendTime, "id", str(iRetNewRecID))
        return iRetNewRecID
    def __init__(self, bstrSelfIDName, ustrThreadName, paramQueue, iIndex,
                 threadPluginExecEachCallBackFunc):
        bstrSelfIDName = CTYLB_MainSys_MiscFunc.SafeGetUTF8(bstrSelfIDName)
        ustrThreadName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrThreadName)

        threading.Thread.__init__(self, name=ustrThreadName)
        self.s_MyQueue = paramQueue
        self.s_iMyIndex = iIndex

        self.g_ExecMutex = threading.Lock()  # 线程执行同步锁
        self.s_bThreadRunning = True

        self.s_runParamUnit = None  # 运行参数
        self.s_runResult = None  # 运行结果
        self.s_ExecMutex = threading.Lock()  # 线程执行同步锁
        self.s_iCurStatus = 0  # 空闲
        self.s_pluginExecWebCallBackFunc = threadPluginExecEachCallBackFunc
        self.s_bstrSelfIDName = bstrSelfIDName
        self.s_resultMiddleUnitArray = []  # 结果单元队列 CThreadRunResultUnit

        if (self.s_ExecMutex.acquire()):
            self.s_ExecMutex.release()
 def AddNewdRec(dbConn, iUserNameID, ustrBelongGroupName):
     ustrBelongGroupName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
         ustrBelongGroupName)
     iOrigRecID = CSkLBDB_ea_brain_envirument.GetRecID_By_UserID_GroupName(
         dbConn, iUserNameID, ustrBelongGroupName)
     if (not iOrigRecID):
         iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField2(
             dbConn, CSkLBDB_ea_brain_envirument.s_strTableName,
             "belong_usermang_id", str(iUserNameID), 'belong_group_name',
             ustrBelongGroupName)
     else:
         iRetNewRecID = iOrigRecID
     return iRetNewRecID
    def __init__(self, iRunPluginiD, ustrRunTaskLineFile, iEachParamUnitCount=20):
        self.s_lastQueryParamTime = datetime(2017,1,1)  # 上次查询参数时间
        self.s_iRunPluginID = iRunPluginiD  # 运行的插件ID
        self.s_iCanSendRequestParamCount = 0  # 能发送请求参数的个数

        self.s_bstrPromptWaitFinishParamSignArray = []  # 提交,等待执行完成的参数标识队列
        self.s_lastSendParamTime = datetime(2017,1,1)   # 上次发送参数时间

        self.s_ustrRunTaskFileName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrRunTaskLineFile)   # 要运行的任务文件名
        self.s_bstrRunContentArray = []   # 运行内容队列
        self.s_iLastSendPos = 0  # 上次发送位置
        self.s_iEachParamBlockCount = iEachParamUnitCount   # 每次参数块,单元个数
        pass
    def __init__(self,
                 bstrSelfIDName,
                 threadPluginExecEachCallBack,
                 iThreadCount=10):
        bstrSelfIDName = CTYLB_MainSys_MiscFunc.SafeGetUTF8(bstrSelfIDName)

        self.s_runThreadMang = []  # 运行线程管理  CTYLB_HostExec_Thread
        self.s_globalQueue = queue.Queue()  # 线程同步
        self.s_waitRunParamUnit = []  # 等待运行的单元参数队列 CThreadRunParamUnit
        self.s_threadPluginExecEachCallBackFunc = threadPluginExecEachCallBack
        self.s_lastSendStatusContentTime = datetime(2017, 1, 1)
        self.s_bstrSelfIDName = bstrSelfIDName
        self.s_iSimuRunThreadCount = iThreadCount  # 线程个数
        pass
    def Viul_Notify_Recv_RunResult(self, bstrParamSign, iReplyPluginID, bstrOrigDomain, bstrResult):
        bstrParamSign = CTYLB_MainSys_MiscFunc.SafeGetUTF8(bstrParamSign)
        bstrOrigDomain = CTYLB_MainSys_MiscFunc.SafeGetUTF8(bstrOrigDomain)
        bstrResult = CTYLB_MainSys_MiscFunc.SafeGetUTF8(bstrResult)

        bstrShowResult = bstrResult
        s2 = bstrShowResult.replace(b'\r', b'')
        bstrShowResult = s2.replace(b'\n', b'')
        CTYLB_Log.ShowLog( 0, 'result-arrive', '[%s] - [%s] [%d] [%s]' % (bstrParamSign, bstrOrigDomain, iReplyPluginID, bstrShowResult))
        msgObject={
            "monitor_type":"result",
            "level":"info",
            "target":bstrOrigDomain,
            "plugin_id":self.s_iRunPluginID,
            "block_id":"",
            "block_size":0,
            "free_size":0,
            "wait_size":0,
			"success_size":0,
            "result_code":0,
            "msg":bstrResult
            }
        CTYLB_Log.ShowMonitor(msgType="PLC",msgObject=msgObject)
        pass
Exemple #24
0
    def AddNewdRec(dbConn,
                   ustrMonitorID,
                   ustrLastContent,
                   iContentType,
                   iExecStatus=0,
                   showTime=None):
        ustrMonitorID = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrMonitorID)
        ustrLastContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
            ustrLastContent)

        iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField4(
            dbConn, CSkLBDB_funcbot_op_display.s_strTableName, "monitor_id",
            ustrMonitorID, "last_content", ustrLastContent, "exec_status",
            str(iExecStatus), 'content_type', str(iContentType))
        if (iRetNewRecID > 0):
            createTime = datetime.now()
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_funcbot_op_display.s_strTableName,
                "create_time", createTime, "id", str(iRetNewRecID))
            if (showTime):
                CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                    dbConn, CSkLBDB_funcbot_op_display.s_strTableName,
                    "show_time", showTime, "id", str(iRetNewRecID))
        return iRetNewRecID
Exemple #25
0
    def Update_RecID_ShowContentStatus( dbConn, iRecID, ustrShowContent, iContentType, iExecStatus=0, createTime=None, showTime=None):
        ustrShowContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrShowContent)
        strClause = "id=%d" % (iRecID)

        CSkLBDB_CommFuncShare.ExecUpdateRecField3(dbConn, CSkLBDB_funcbot_op_display.s_strTableName, strClause,
                                                  "last_content", ustrShowContent,
                                                  'content_type', str(iContentType),
                                                  'exec_status', str(iExecStatus))

        if( not createTime):
            createTime = datetime.now()
        if( not showTime):
            showTime = datetime.now()
        CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(dbConn, CSkLBDB_funcbot_op_display.s_strTableName,
                                                             "create_time", createTime, "id", str(iRecID))
        CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(dbConn, CSkLBDB_funcbot_op_display.s_strTableName,
                                                             "show_time", showTime, "id", str(iRecID))
Exemple #26
0
 def Search_Add_Request_HostUnit_By_IDName(self,
                                           bstrHostIDName,
                                           iNewSock,
                                           bAddNew=True):
     bstrHostIDName = CTYLB_MainSys_MiscFunc.SafeGetUTF8(bstrHostIDName)
     retHostUnit = None
     for eachUnit in self.s_requestHostUnitArray:
         if (eachUnit.s_bstrHostIDName == bstrHostIDName):
             eachUnit.s_iAcceptSock = iNewSock
             retHostUnit = eachUnit
             break
     if (not retHostUnit):
         # 新主机,加入请求主机单元队列
         hostUnit = CTYLB_TaskCenter_RequestHostUnit(
             bstrHostIDName, iNewSock)
         self.s_requestHostUnitArray.append(hostUnit)
         retHostUnit = hostUnit
     return retHostUnit
Exemple #27
0
    def __init__(self, bstrHostName, iAcceptSock):
        bstrHostName = CTYLB_MainSys_MiscFunc.SafeGetUTF8(bstrHostName)

        self.s_bstrHostIDName = bstrHostName  # 主机名字
        self.s_requestParamUnitArray = [
        ]  # 请求执行的参数单元队列  CTYLB_P2P_ContentUnit_Base
        self.s_waitExecParamArray = [
        ]  #  等待执行的参数队列  CTYLB_P2P_ContentUnit_Base
        self.s_waitBroadCastParamArray = [
        ]  # 等待广播执行的参数队列  CTYLB_P2P_ContentUnit_Base
        self.s_bstrRunningParamSignArray = []  # 正在运行的参数标记队列bytes
        self.s_runningBCastParamArray = [
        ]  # 正在运行的参数队列  CTYLB_P2P_ContentUnit_Base
        self.s_lastScheduleTime = datetime(2017, 1, 1)  # 上次调度时间
        self.s_clientResultCTUnitArray = []  # 客户端结果发送的单元队列

        self.s_iAcceptSock = iAcceptSock  # 接收到请求端的管套ID
        self.s_toBeSendReplyCTUnitArray = []  # 等待发送的回复单元队列
        pass
Exemple #28
0
def SubHandle_OPParam_GetNextParamBlock( bstrObjName, bstrNeedCount, bstrEachBlockCount):
    iNeedExCount = int(bstrNeedCount)
    iEachBlockCount = int(bstrEachBlockCount)
    retCommCTUnitArray = []

    for i in range(iNeedExCount):
        strExecParamSignID, execParamContentArray = CTYF_OpDB_OperateParamBlock.RequestParamBlockContent( g_mainOperateDB.s_DbConn,
                                                                                                          bstrObjName, iEachBlockCount)
        bstrExecParamSignID = strExecParamSignID.encode()
        bstrParamContentArray = CTYLB_MainSys_MiscFunc.SafeGetUTF8Array(execParamContentArray)
        if( strExecParamSignID and bstrParamContentArray):
            eachRetCTUnit = CTYBot_CTUnit_CommonData()
            eachRetCTUnit.SetIntData(g_i_OpParamBlock_SubCmd_Reply_GetRunParamBlock)
            bstrExTotalContent = b'\n'.join(bstrParamContentArray)
            eachRetCTUnit.SetStrData(bstrExTotalContent)
            eachRetCTUnit.SetParam( bstrObjName, bstrExecParamSignID)
            retCommCTUnitArray.append(eachRetCTUnit)
        else:
            # 数据库没有内容了
            break

    return retCommCTUnitArray
Exemple #29
0
    def TimerCheck_UserMoodCheckTime(self, dbConn):
        bRetValue = False

        # 每2秒钟检查一次
        if (CTYLB_MainSys_MiscFunc.CheckIdleTime(
                self.s_lastCheckUserMoodTime,
                CTYReActBrainBot_Track_Checker.s_g_iTaskCheckDiffTime)):
            self.s_lastCheckUserMoodTime = datetime.now()

            # 获得用户单独对话的列表
            iUserFaceToFaceEnvRecArray = CSkLBDB_ea_brain_envirument.GetRecList_By_GroupName(
                dbConn, '')
            if (iUserFaceToFaceEnvRecArray):
                bRetValue = True
            for iEachUserEnvRecID in iUserFaceToFaceEnvRecArray:
                curCheckUserExec = CUserExecReal(dbConn, iEachUserEnvRecID)
                iContentType, strActiveSendContent = curCheckUserExec.CheckActive_DaShan_SayContent(
                )
                if (strActiveSendContent):
                    CTYReActBrainBot_Track_Checker.AddReplyTextInfoToUser(
                        dbConn, iEachUserEnvRecID, strActiveSendContent)
                pass
        return bRetValue
    def AddNewdRec(dbConn,
                   iBelongEnviruID,
                   ustrChatContent,
                   iContentType,
                   iDirection,
                   createTime=None,
                   execTime=None,
                   iExecStatus=0):
        ustrChatContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
            ustrChatContent)

        iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField5(
            dbConn, CSkLBDB_ea_brain_chatcontent.s_strTableName,
            "chat_content", ustrChatContent, 'belong_envirument_id',
            str(iBelongEnviruID), 'chat_content_type', str(iContentType),
            'chat_direction', str(iDirection), 'exec_status', str(iExecStatus))
        if (iRetNewRecID):
            if (not createTime):
                createTime = datetime.now()
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_ea_brain_chatcontent.s_strTableName,
                "create_time", createTime, "id", str(iRetNewRecID))
        return iRetNewRecID