def AddNewdRec(dbConn,
                   iBelongEnviruID,
                   iTaskTypeID,
                   ustrContent,
                   ustrParam,
                   ustrWhoRequestName,
                   iTaskRunAlways,
                   createTime=None,
                   requestExecTime=None,
                   iRequestExecStatus=0):
        ustrContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrContent)
        ustrParam = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrParam)
        ustrWhoRequestName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
            ustrWhoRequestName)

        iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField7(
            dbConn, CSkLBDB_ea_brain_exec_task.s_strTableName,
            'belong_envirument_id', str(iBelongEnviruID), "task_type_id",
            str(iTaskTypeID), 'content',
            ustrContent, 'param', ustrParam, 'request_exec_status',
            str(iRequestExecStatus), 'who_request_name', ustrWhoRequestName,
            'task_run_always', str(iTaskRunAlways))
        if (iRetNewRecID):
            if (not createTime):
                createTime = datetime.now()
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_ea_brain_exec_task.s_strTableName,
                "create_time", createTime, "id", str(iRetNewRecID))
        return iRetNewRecID
Example #2
0
def SubHandle_OPMonitor_Post_DisplayContent(ustrDisplayContent, ustrMonitorID,
                                            ustrDataType):
    ustrDisplayContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
        ustrDisplayContent)
    ustrMonitorID = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
        ustrMonitorID)  #{ "RunTypeID" : 902,"TaskRecID" : 24 }
    ustrDataType = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
        ustrDataType)  #"ShowNetworkAssets"

    replyJson = json.loads(ustrMonitorID)
    iRunType = replyJson["RunTypeID"]
    iTaskRecID = replyJson["TaskRecID"]

    targetData = json.loads(ustrDisplayContent)
    res = ''
    if iRunType == g_i_ExecTypeID_Monitor_ShowNetworkSituation:
        #请求API提交数据
        res = MonitorApiHandler.AddNetworkSituation(
            target=targetData['target'], target_type=targetData['type'])
    elif iRunType == g_i_ExecTypeID_Monitor_ShowNetworkAssets:
        #请求API提交数据
        res = MonitorApiHandler.AddNetworkAssets(
            target=targetData['target'], target_type=targetData['type'])

    retCommCTUnit = CTYBot_CTUnit_CommonData()
    retCommCTUnit.SetIntData(g_i_OpMonitor_SubCmd_Reply_Post_DisplayContent)
    retCommCTUnit.SetStrData(res)  #strOrigParamRunParam
    retCommCTUnit.SetParam(str(iRunType),
                           str(iTaskRecID))  #strRunType strTaskRecID
    return retCommCTUnit
    def __init__(self, ustrCfgFileName, ustrDbFileName):
        ustrCfgFileName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrCfgFileName)
        ustrDbFileName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrDbFileName)

        # 设置运行任务提交
        self.s_RunnDTaskArray = []   # 正在运行的任务队列

        # 创建机器人框架
        self.s_LessTYLB_Bot_FrameThread = CLessTYBotFrameThread(ustrCfgFileName, ustrDbFileName)
        # 设置默认环境处理
        # self.s_LessTYLB_Bot_FrameThread.SetDefaultConsoleCompatible( CtrlCHandle)
        # 准备运行
        self.s_LessTYLB_Bot_FrameThread.Prepare_Start()
        self.s_strSelfID = self.s_LessTYLB_Bot_FrameThread.GetMyName()
        # 注册 单元到达的通知,HLSession的新数据单元创建
        self.s_LessTYLB_Bot_FrameThread.RegisterNewCTUnit( CTYLB_Bot_BaseDef.s_g_iDataType_TaskRegCenter_sk_v1,
                                                           CTYLB_Bot_BaseDef.s_g_iMainCmd_TaskRegCenter_ReportResult_V2,
                                                           CTYLB_Bot_BaseDef.s_g_iSubCmd_TaskRegCenter_ReportResult_V2_PingTraceWebCrawl,
                                                           CTYBot_CTUnit_TaskRegCenter_CreateNewUnit_V2_ReportResult)
        self.s_LessTYLB_Bot_FrameThread.RegisterNewCTUnit( CTYLB_Bot_BaseDef.s_g_iDataType_TaskRegCenter_sk_v1,
                                                           CTYLB_Bot_BaseDef.s_g_iMainCmd_TaskRegCenter_ReportResult,
                                                           CTYLB_Bot_BaseDef.s_g_iSubCmd_TaskRegCenter_ReportResult_PingTraceWebCrawl,
                                                           CTYBot_CTUnit_TaskRegCenter_CreateNewUnit_ReportResult)

        # 获得管套管理对象
        self.s_hlSockMang = self.s_LessTYLB_Bot_FrameThread.s_HLSockMang
        # 读取配置参数
        ustrTaskRegCenterID = self.s_LessTYLB_Bot_FrameThread.s_execTYLB_Bot_Sample.ReadIniSectionValue( ustrCfgFileName,
                                                            u'client', u'taskcenter_id',
                                                            CTYLB_Bot_BaseDef.s_g_strBotName_TaskRegCenter_sk_v1)
        self.s_bstrTaskRegCenterID = CTYLB_MainSys_MiscFunc.SafeGetUTF8(ustrTaskRegCenterID)
        # 创建连接管套
        self.s_x_TaskRegCenter_Sock = CTYFBot_OpSession_ConnectSock(self.s_hlSockMang, self.s_bstrTaskRegCenterID,
                                                                    self.s_g_iTaskMang_Listen_Port_PromptTask)
        pass
    def AddNewdRec(dbConn,
                   iExecTaskID,
                   ustrReplyContent,
                   ustrReplyParam,
                   ustrWhoExec,
                   execStartTime=None,
                   execFinishTime=None,
                   iExecStatus=0):
        ustrReplyContent = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
            ustrReplyContent)
        ustrReplyParam = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrReplyParam)
        ustrWhoExec = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrWhoExec)

        iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField5(
            dbConn, CSkLBDB_ea_brain_exec_result.s_strTableName,
            'exec_task_id', str(iExecTaskID), "reply_content",
            ustrReplyContent, 'reply_param', ustrReplyParam, 'exec_status',
            str(iExecStatus), 'who_exec_name', ustrWhoExec)
        if (iRetNewRecID):
            if (not execStartTime):
                createTime = datetime.now()
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_ea_brain_exec_result.s_strTableName,
                "exec_start_time", execStartTime, "id", str(iRetNewRecID))
        return iRetNewRecID
    def AddNewdRec(dbConn,
                   iBelongDestOPID,
                   strSignIDFieldValue,
                   strParamBlockID,
                   iStatus,
                   operateTime,
                   createTime=None):
        strSignIDFieldValue = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
            strSignIDFieldValue)
        strParamBlockID = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
            strParamBlockID)

        iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField4(
            dbConn,
            CSkLBDB_dest_param_status.s_strTableName, "belong_dest_operate_id",
            str(iBelongDestOPID), "sign_id_field_value", strSignIDFieldValue,
            "param_block_id", strParamBlockID, "status", str(iStatus))
        if ((iRetNewRecID > 0) and (operateTime)):
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_dest_param_status.s_strTableName,
                "operate_time", operateTime, "id", str(iRetNewRecID))
        if (not createTime):
            createTime = datetime.now()
        if ((iRetNewRecID > 0) and (createTime)):
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_dest_param_status.s_strTableName,
                "create_time", createTime, "id", str(iRetNewRecID))
        return iRetNewRecID
Example #6
0
def SubHandle_OPActionBrain_ReplyExecResult(strPeerName, strTaskValue,
                                            strTaskTypeIDRecID,
                                            strTaskResultParam):
    strPeerName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strPeerName)
    strTaskValue = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTaskValue)
    strTaskTypeIDRecID = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
        strTaskTypeIDRecID)
    strTaskResultParam = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
        strTaskResultParam)
    # 提取参数结果内容
    paramCollect = json.loads(strTaskValue)
    iExecResultCode = paramCollect[g_str_Alarm_Reply_V_ResultCode]
    strRunResult = paramCollect[g_str_Alarm_Reply_V_RunResult]
    strNeedUpdateRunParam = paramCollect[
        g_str_Alarm_Reply_V_NeedUpdateRunParam]
    strNeedSendUserContent = paramCollect[g_str_Alarm_Reply_V_SendUserContent]

    paramCollect = json.loads(strTaskTypeIDRecID)
    iRunTaskTypeID = paramCollect[g_str_Alarm_Reply_P1_RunTypeID]
    iTaskRecID = paramCollect[g_str_Alarm_Reply_P1_TaskRecID]

    iExecBelongEnviruID, iExecTaskTypeID, strExecContent, strExecParam, strExecWhoRequestName, execCreateTime, \
    execRequestExecTime, iExecRequestExecStatus, iExecTaskRunAlways, execLastCheckTime, strExecTaskRunParam = \
        CSkLBDB_ea_brain_exec_task.ReadByRecID(g_mainOperate_RealActionDB.s_DbConn, iTaskRecID)

    iDestSetStatus = CTYOp_ReActBrain_Store.s_g_iStatus_Finish
    if (iExecResultCode == g_i_Code_Finish_Stop_Task):
        # 0 –完成,可以停止本次任务;
        pass
    elif (iExecResultCode == g_i_Code_Finish_Need_Run_Update_RunParam):
        # 1-本次完成,下次还要继续运行,需要更新运行时参数
        iDestSetStatus = CTYOp_ReActBrain_Store.s_g_iStatus_Free
        CSkLBDB_ea_brain_exec_task.Update_RunParam(
            g_mainOperate_RealActionDB.s_DbConn, iTaskRecID,
            strNeedUpdateRunParam)
        pass
    elif (iExecResultCode == g_i_Code_Finish_Need_Run):
        # 2-本次完成,还要继续运行,不修改参数内容
        iDestSetStatus = CTYOp_ReActBrain_Store.s_g_iStatus_Free
        pass

    # 发送内容用户,提交到微信输出表
    if (strNeedSendUserContent):
        CTYReActBrainBot_Track_Checker.AddReplyTextInfoToUser(
            g_mainOperate_RealActionDB.s_DbConn, iExecBelongEnviruID,
            strNeedSendUserContent)

    # 更新任务状态
    CSkLBDB_ea_brain_exec_task.Update_ExStatus(
        g_mainOperate_RealActionDB.s_DbConn, iTaskRecID, iDestSetStatus)
    CSkLBDB_ea_brain_exec_task.Update_LastCheckTime(
        g_mainOperate_RealActionDB.s_DbConn, iTaskRecID)

    # 构建返回数据包
    sendCTUnit = CTYBot_CTUnit_CommonData()
    sendCTUnit.SetIntData(g_i_OpAction_SubCmd_Reply_ReplyExecResult)
    retCTUnitArray = [sendCTUnit]
    return retCTUnitArray
Example #7
0
    def ExecUpdateRecField1(dbConn, strTable, strClause, strField1, strValue1):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strClause = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strClause)
        strField1 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField1)
        strValue1 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue1)

        strSetField = strField1 + "='" + strValue1 + "'"
        strModifySQL = "update " + strTable + " set " + strSetField + "  where " + strClause
        CSkLBDB_CommFuncShare.__ExecUpdateSQL(dbConn, strModifySQL)
Example #8
0
    def ReConnect(self, strHost, iPort, strUserName, strPasswd, strDatabase):
        strHost = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strHost)
        strUserName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strUserName)
        strPasswd = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strPasswd)
        strDatabase = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strDatabase)

        self.CloseConnection()
        self.s_DbConn = CSkLBDB_MainConn.__ExecPyMysqlConnect(
            strHost, iPort, strUserName, strPasswd, strDatabase)
Example #9
0
    def ExecInsertRecField4(dbConn, strTable, strField1, strValue1, strField2,
                            strValue2, strField3, strValue3, strField4,
                            strValue4):
        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)
        strField3 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField3)
        strValue3 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue3)
        strField4 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField4)
        strValue4 = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue4)

        strTotalFields = "%s,%s,%s,%s" % (strField1, strField2, strField3,
                                          strField4)
        strInsertSQL = "insert into " + strTable + " (" + strTotalFields + ") values(%s,%s,%s,%s)"
        insertCur = dbConn.cursor()
        try:
            insertCur.execute(strInsertSQL,
                              (strValue1, strValue2, strValue3, strValue4))
            iRetRecID = insertCur.lastrowid
            dbConn.commit()
        except Exception as e:
            iRetRecID = 0
        insertCur.close()
        return iRetRecID
Example #10
0
    def AddNewdRec(dbConn, strAppName, strSubTaskName):
        strAppName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strAppName)
        strSubTaskName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strSubTaskName)

        iRetNewRecID = CSkLBDB_result_app_task_name.GetRecID_By_App_SubTask_Name(
            dbConn, strAppName, strSubTaskName)
        if (iRetNewRecID == 0):
            iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField2(
                dbConn, CSkLBDB_result_app_task_name.s_strTableName,
                "app_name", strAppName, "sub_task_name", strSubTaskName)
        return iRetNewRecID
Example #11
0
    def ExecDeleteFrom(dbConn, strTable, strField, strValue):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strField = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField)
        strValue = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue)

        strClause = strField + "='" + strValue + "'"
        strModifySQL = "delete from " + strTable + " where " + strClause
        deleteCur = dbConn.cursor()
        deleteCur.execute(strModifySQL)
        deleteCur.close()
        dbConn.commit()  # 确认更新记录
Example #12
0
    def GetRecID_By_App_SubTask_Name(dbConn, strAppName, strSubTaskName):
        strAppName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strAppName)
        strSubTaskName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strSubTaskName)

        strClause = "app_name='%s' and sub_task_name='%s'" % (strAppName,
                                                              strSubTaskName)
        iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
            dbConn, CSkLBDB_result_app_task_name.s_strTableName, "id",
            strClause)
        if (not iRetID):
            iRetID = 0
        return iRetID
Example #13
0
    def ReadField_Single_WithClause(dbConn, strTable, strField, strClause):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strField = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField)
        strClause = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strClause)

        objRetFieldValue = None

        strQueryReply = "select " + strField + " from " + strTable + " where " + strClause
        recFrameReply = pd.read_sql_query(strQueryReply, dbConn)  # 转成DataFrame
        recCount = len(recFrameReply)  # 记录个数
        if (recCount > 0):
            objRetFieldValue = recFrameReply[strField][0]
        return objRetFieldValue
Example #14
0
    def GetRecCount(dbConn, strTable, strClause=''):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strClause = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strClause)

        iRetCount = 0  # 初始化
        strQuery = "select count(*) from " + strTable
        if (strClause and (len(strClause) > 0)):
            strQuery = strQuery + " where " + strClause
        recFrame = pd.read_sql_query(strQuery, dbConn)  # 转成DataFrame
        recCount = len(recFrame)  # 记录个数
        if (recCount > 0):
            iRetCount = recFrame["count(*)"][0]
        return iRetCount
    def UpdateRecordContent(dbConn, iRecID, ustrURL, ustrImage, execDateTime):
        ustrURL = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrURL)
        ustrImage = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrImage)

        strClause = 'id=%d' % (iRecID)
        CSkLBDB_CommFuncShare.ExecUpdateRecField2(
            dbConn, CSkLBDB_ow_bot_out_logincode.s_strTableName, strClause,
            'url', ustrURL, 'qrcodecontent', ustrImage)
        if (execDateTime):
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(
                dbConn, CSkLBDB_ow_bot_out_logincode.s_strTableName,
                'create_time', execDateTime, 'id', str(iRecID))
        pass
Example #16
0
    def ExecInsertRecField1(dbConn, strTable, strField, strValue):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strField = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField)
        strValue = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strValue)

        strInsertSQL = "insert into " + strTable + " (" + strField + ") values(%s)"  # insert into table (field) values(%s)
        insertCur = dbConn.cursor()
        try:
            insertCur.execute(strInsertSQL, (strValue))
            iRetRecID = insertCur.lastrowid
            dbConn.commit()
        except Exception as e:
            iRetRecID = 0
        insertCur.close()
        return iRetRecID
    def AddNewdRec(dbConn, iBelongEnviruID, ustrPropName, ustrPropValue):
        ustrPropName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrPropName)
        ustrPropValue = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrPropValue)

        iRetNewRecID = CSkLBDB_ea_brain_enviru_property.GetRecID_By_EnviruID_PropName(
            dbConn, iBelongEnviruID, ustrPropName)
        if (not iRetNewRecID):
            iRetNewRecID = CSkLBDB_CommFuncShare.ExecInsertRecField3(
                dbConn, CSkLBDB_ea_brain_enviru_property.s_strTableName,
                'belong_envirument_id', str(iBelongEnviruID), "prop_name",
                ustrPropName, 'prop_value', ustrPropValue)
        else:
            CSkLBDB_ea_brain_enviru_property.Update_PropValue(
                dbConn, iRetNewRecID, ustrPropValue)
        return iRetNewRecID
Example #18
0
    def ExecUpdateRecField_To_DateTime(dbConn, strTable, strTimeField,
                                       dateTimeValue, strClauseField,
                                       strClauseValue):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strTimeField = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTimeField)
        strClauseField = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strClauseField)
        strClauseValue = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strClauseValue)

        strClause = strClauseField + "='" + strClauseValue + "'"
        strModifyRecSameID = "update " + strTable + " set " + strTimeField + "=CAST('" + dateTimeValue.strftime("%Y-%m-%d %H:%M:%S") \
                + "' as datetime) where " + strClause
        updateCur = dbConn.cursor()
        updateCur.execute(strModifyRecSameID)
        updateCur.close()
        dbConn.commit()  #确认更新记录
Example #19
0
 def __connect_to_basic_handle(self, sock_id, sock_port, eachCTUnit,
                               is_last_package):
     if (eachCTUnit.s_iMyDataType ==
             CTYLB_Bot_BaseDef.s_g_iDataType_CommonTask):
         if eachCTUnit.s_iValue in self.__connect_to_callbacks[sock_id][
                 sock_port]['recv'].keys():
             eachRetCommCTUnitArray = self.__connect_to_callbacks[sock_id][
                 sock_port]['recv'][eachCTUnit.s_iValue](
                     CTYLB_MainSys_MiscFunc.SafeGetUnicode(
                         eachCTUnit.s_strValue),
                     CTYLB_MainSys_MiscFunc.SafeGetUnicode(
                         eachCTUnit.s_strParam1),
                     CTYLB_MainSys_MiscFunc.SafeGetUnicode(
                         eachCTUnit.s_strParam2), is_last_package)
             return eachRetCommCTUnitArray
Example #20
0
    def GetMinValue(dbConn, strTable, strField):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)
        strField = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strField)
        iRetValue = 0  # 初始化

        strMaxQueryField = "min(" + strField + ")"
        strQuery = "select " + strMaxQueryField + " from " + strTable
        recFrame = pd.read_sql_query(strQuery, dbConn)  # 转成DataFrame
        recCount = len(recFrame)  # 记录个数
        if (recCount > 0):
            iRetValue = recFrame[strMaxQueryField][0]
            if (not iRetValue):
                iRetValue = 0
        else:
            iRetValue = 0
        return iRetValue
 def GetRecList_By_GroupName(dbConn, ustrGroupName):
     ustrGroupName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrGroupName)
     strClause = "belong_group_name='%s'" % (ustrGroupName)
     iRetRecIDArray = CSkLBDB_CommFuncShare.ReadField_Array_WithClause(
         dbConn, CSkLBDB_ea_brain_envirument.s_strTableName, "id",
         strClause)
     return iRetRecIDArray
 def Update_RequestName(dbConn, iRecID, ustrRequestorName):
     ustrRequestorName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(
         ustrRequestorName)
     strClause = "id=%d" % (iRecID)
     CSkLBDB_CommFuncShare.ExecUpdateRecField1(
         dbConn, CSkLBDB_ea_brain_exec_task.s_strTableName, strClause,
         "who_request_name", ustrRequestorName)
Example #23
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))
 def GetRecID_By_UserName(dbConn, ustrUserName):
     ustrUserName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrUserName)
     strClause = "username='******'" % (ustrUserName)
     iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
         dbConn, CSkLBDB_ea_brain_usermang.s_strTableName, "id", strClause)
     if (not iRetID):
         iRetID = 0
     return iRetID
Example #25
0
 def GetRecID_By_MonitorID(dbConn, ustrMonitorID):
     ustrMonitorID = CTYLB_MainSys_MiscFunc.SafeGetUnicode(ustrMonitorID)
     strClause = "monitor_id='%s'" % (ustrMonitorID)
     iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
         dbConn, CSkLBDB_funcbot_op_display.s_strTableName, "id", strClause)
     if (not iRetID):
         iRetID = 0
     return iRetID
Example #26
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,
                                                                 u"monitor_id", ustrMonitorID,
                                                                 u"last_content", ustrLastContent,
                                                                 u"exec_status", str(iExecStatus),
                                                                 u'content_type', str(iContentType))
        if( iRetNewRecID > 0):
            createTime = datetime.now()
            CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime( dbConn, CSkLBDB_funcbot_op_display.s_strTableName,
                                                                  u"create_time", createTime, u"id", str(iRetNewRecID))
            if( showTime):
                CSkLBDB_CommFuncShare.ExecUpdateRecField_To_DateTime(dbConn, CSkLBDB_funcbot_op_display.s_strTableName,
                                                                     u"show_time", showTime, u"id", str(iRetNewRecID))
        return iRetNewRecID
Example #27
0
 def GetRecID_By_Name(dbConn, strObjName):
     strObjName = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strObjName)
     strClause = "obj_name='%s'" % (strObjName)
     iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
         dbConn, CSkLBDB_dest_operate.s_strTableName, "id", strClause)
     if (not iRetID):
         iRetID = 0
     return iRetID
Example #28
0
    def GetRecID_by_UID(dbConn, strTable, iUID):
        strTable = CTYLB_MainSys_MiscFunc.SafeGetUnicode(strTable)

        strClause = "unique_id=%d" % (iUID)
        iRetID = CSkLBDB_CommFuncShare.ReadField_Single_WithClause(
            dbConn, strTable, "id", strClause)
        if (not iRetID):
            iRetID = 0
        return iRetID
Example #29
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)
Example #30
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()  # 确认更新记录