Search in sources :

Example 1 with NodeScriptExecuteLogServer

use of io.jpom.service.node.script.NodeScriptExecuteLogServer in project Jpom by dromara.

the class CheckMonitor method pullScriptLogItem.

/**
 * 同步 节点的脚本模版日志
 *
 * @param nodeModel 节点
 */
private static void pullScriptLogItem(NodeModel nodeModel) {
    try {
        NodeScriptExecuteLogServer nodeScriptExecuteLogServer = SpringUtil.getBean(NodeScriptExecuteLogServer.class);
        Collection<String> strings = nodeScriptExecuteLogServer.syncExecuteNodeInc(nodeModel);
        if (strings == null) {
            return;
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("ids", strings);
        JsonMessage<Object> jsonMessage = NodeForward.requestBody(nodeModel, NodeUrl.SCRIPT_DEL_EXEC_LOG, null, jsonObject);
        if (jsonMessage.getCode() != HttpStatus.HTTP_OK) {
            DefaultSystemLog.getLog().error("删除脚本模版执行数据错误:{}", jsonMessage);
        }
    } catch (Exception e) {
        DefaultSystemLog.getLog().error("同步脚本异常", e);
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) NodeScriptExecuteLogServer(io.jpom.service.node.script.NodeScriptExecuteLogServer) JSONObject(com.alibaba.fastjson.JSONObject)

Example 2 with NodeScriptExecuteLogServer

use of io.jpom.service.node.script.NodeScriptExecuteLogServer in project Jpom by dromara.

the class NodeScriptHandler method createLog.

/**
 * 创建执行日志
 *
 * @param attributes 参数属性
 * @return 执行ID
 */
private String createLog(Map<String, Object> attributes) {
    NodeModel nodeInfo = (NodeModel) attributes.get("nodeInfo");
    UserModel userModel = (UserModel) attributes.get("userInfo");
    ScriptCacheModel dataItem = (ScriptCacheModel) attributes.get("dataItem");
    NodeScriptExecuteLogServer logServer = SpringUtil.getBean(NodeScriptExecuteLogServer.class);
    NodeScriptServer nodeScriptServer = SpringUtil.getBean(NodeScriptServer.class);
    // 
    try {
        BaseServerController.resetInfo(userModel);
        // 
        ScriptCacheModel scriptCacheModel = new ScriptCacheModel();
        scriptCacheModel.setId(dataItem.getId());
        scriptCacheModel.setLastRunUser(userModel.getId());
        nodeScriptServer.update(scriptCacheModel);
        // 
        ScriptExecuteLogCacheModel scriptExecuteLogCacheModel = new ScriptExecuteLogCacheModel();
        scriptExecuteLogCacheModel.setScriptId(dataItem.getScriptId());
        scriptExecuteLogCacheModel.setNodeId(nodeInfo.getId());
        scriptExecuteLogCacheModel.setScriptName(dataItem.getName());
        scriptExecuteLogCacheModel.setTriggerExecType(0);
        scriptExecuteLogCacheModel.setWorkspaceId(nodeInfo.getWorkspaceId());
        logServer.insert(scriptExecuteLogCacheModel);
        return scriptExecuteLogCacheModel.getId();
    } finally {
        BaseServerController.removeAll();
    }
}
Also used : UserModel(io.jpom.model.data.UserModel) NodeModel(io.jpom.model.data.NodeModel) NodeScriptServer(io.jpom.service.node.script.NodeScriptServer) NodeScriptExecuteLogServer(io.jpom.service.node.script.NodeScriptExecuteLogServer) ScriptExecuteLogCacheModel(io.jpom.model.node.ScriptExecuteLogCacheModel) ScriptCacheModel(io.jpom.model.node.ScriptCacheModel)

Aggregations

NodeScriptExecuteLogServer (io.jpom.service.node.script.NodeScriptExecuteLogServer)2 JSONObject (com.alibaba.fastjson.JSONObject)1 NodeModel (io.jpom.model.data.NodeModel)1 UserModel (io.jpom.model.data.UserModel)1 ScriptCacheModel (io.jpom.model.node.ScriptCacheModel)1 ScriptExecuteLogCacheModel (io.jpom.model.node.ScriptExecuteLogCacheModel)1 NodeScriptServer (io.jpom.service.node.script.NodeScriptServer)1