Search in sources :

Example 1 with DesignAgent

use of org.openntf.domino.design.DesignAgent in project org.openntf.domino by OpenNTF.

the class AgentLog method run.

@SuppressWarnings("unchecked")
@Override
public void run() {
    try {
        Session sess = Factory.getSession(SessionType.NATIVE);
        Database db = sess.getDatabase("PrivateTest.nsf");
        DatabaseDesign dbDesign = db.getDesign();
        StringBuilder sb = new StringBuilder();
        for (Agent agent : db.getAgents()) {
            if (null != agent.getLastRunDate()) {
                DesignAgent agentDesign = dbDesign.getAgent(agent.getActualName());
                sb.append(agentDesign.getRunLog());
                addNewLine(sb);
                List<String> strings = agentDesign.getRunLogAsList();
                sb.append("Lines = " + strings.size());
                addNewLine(sb);
                sb.append("Duration = " + agentDesign.getLastRunDuration() + " seconds");
                addNewLine(sb);
                sb.append("Exceeded timeout? " + agentDesign.isLastRunExceededTimeLimit());
                addNewLine(sb);
            }
        }
        System.out.println(sb.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DesignAgent(org.openntf.domino.design.DesignAgent) Agent(org.openntf.domino.Agent) DatabaseDesign(org.openntf.domino.design.DatabaseDesign) Database(org.openntf.domino.Database) DesignAgent(org.openntf.domino.design.DesignAgent) Session(org.openntf.domino.Session)

Example 2 with DesignAgent

use of org.openntf.domino.design.DesignAgent in project org.openntf.domino by OpenNTF.

the class AgentSchedule method run.

@SuppressWarnings("unchecked")
@Override
public void run() {
    try {
        Session sess = Factory.getSession(SessionType.NATIVE);
        Database db = sess.getDatabase("PrivateTest.nsf");
        StringBuilder sb = new StringBuilder();
        for (Agent agent : db.getAgents()) {
            sb.append("============");
            addNewLine(sb);
            DesignAgent designAgent = db.getDesign().getAgent(agent.getActualName());
            if (!designAgent.isScheduled()) {
                sb.append("Agent " + agent.getActualName() + " is not scheduled");
            } else {
                sb.append("Outputting schedule for agent " + agent.getActualName());
                addNewLine(sb);
                sb.append("Set to run on: " + designAgent.getRunLocation());
                addNewLine(sb);
                sb.append("Schedule type: " + designAgent.getScheduleType().name());
                addNewLine(sb);
                switch(designAgent.getScheduleType()) {
                    case MORE_THAN_DAILY:
                        sb.append("Set to run every " + designAgent.getIntervalHours() + " hours, every " + designAgent.getIntervalMinutes() + " minutes");
                        addNewLine(sb);
                        sb.append("Starting at " + designAgent.getStartTime() + ", ending at " + designAgent.getEndTime());
                        addNewLine(sb);
                        if (designAgent.getRunOnWeekends()) {
                            sb.append("Agent set to run on weekends");
                        } else {
                            sb.append("Agent not set to run on weekends");
                        }
                        break;
                    case DAILY:
                        sb.append("Run daily at " + designAgent.getStartTime());
                        addNewLine(sb);
                        if (designAgent.getRunOnWeekends()) {
                            sb.append("Agent set to run on weekends");
                        } else {
                            sb.append("Agent not set to run on weekends");
                        }
                        break;
                    case WEEKLY:
                        sb.append("Run every " + designAgent.getDayOfWeek() + " at " + designAgent.getStartTime());
                        break;
                    case MONTHLY:
                        sb.append("Run every month on day " + designAgent.getDayOfMonth() + " at " + designAgent.getStartTime());
                        break;
                    default:
                }
                addNewLine(sb);
                sb.append("Agent scheduled to run from " + designAgent.getStartDate() + " to " + designAgent.getEndDate());
            }
            addNewLine(sb);
            sb.append("============");
            addNewLine(sb);
        }
        System.out.println(sb.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DesignAgent(org.openntf.domino.design.DesignAgent) Agent(org.openntf.domino.Agent) Database(org.openntf.domino.Database) DesignAgent(org.openntf.domino.design.DesignAgent) Session(org.openntf.domino.Session)

Aggregations

Agent (org.openntf.domino.Agent)2 Database (org.openntf.domino.Database)2 Session (org.openntf.domino.Session)2 DesignAgent (org.openntf.domino.design.DesignAgent)2 DatabaseDesign (org.openntf.domino.design.DatabaseDesign)1