Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
dpastov committed Oct 23, 2023
1 parent 7d039c4 commit 0eb2635
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>net.prominic</groupId>
<artifactId>AgentsHelper</artifactId>
<packaging>jar</packaging>
<version>1.0.2</version>
<version>1.0.3</version>
<name>AgentsHelper</name>
<url>http://maven.apache.org</url>

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/AgentsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public AgentsHelper() {

@Override
protected String getJavaAddinVersion() {
return "1.0.2";
return "1.0.3";
}

@Override
protected String getJavaAddinDate() {
return "2023-10-23 15:05";
return "2023-10-23 21:00";
}

protected boolean runNotesAfterInitialize() {
Expand Down
48 changes: 21 additions & 27 deletions src/main/java/EventCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,35 @@ private void triggerFire() {

long seconds = (now.getTime()-lastRun.getTime())/1000;
if (seconds > interval) {
System.out.println(event.get("name"));
boolean allow = true;
String runIfFormula = (String) event.get("runIfFormula");
String runIfDatabase = (String) event.get("runIfDatabase");
if (!runIfFormula.isEmpty() && !runIfDatabase.isEmpty()) {
try {
Database database = session.getDatabase(null, runIfDatabase);
Document doc = database.createDocument();
@SuppressWarnings("unchecked")
Vector<Double> res = session.evaluate(runIfFormula, doc);
allow = res.get(0) == 1;
doc.recycle();
database.recycle();
} catch (NotesException e) {
this.getLogger().severe(e);
}
}

if (allow) {
triggerEvent(event);
}
else {
event.put("lastRun", new Date());
}
triggerEvent(event);
};
}
}

private void triggerEvent(HashMap<String, Object> event) {
boolean allow = true;

try {
String command = (String) event.get("command");
session.sendConsoleCommand("", command);
event.put("lastRun", new Date());
String runIfFormula = (String) event.get("runIfFormula");
String runIfDatabase = (String) event.get("runIfDatabase");
if (!runIfFormula.isEmpty() && !runIfDatabase.isEmpty()) {
Database database = session.getDatabase(null, runIfDatabase);
Document doc = database.createDocument();
@SuppressWarnings("unchecked")
Vector<Double> res = session.evaluate(runIfFormula, doc);
allow = res.get(0) == 1;
doc.recycle();
database.recycle();
}

if (allow) {
String command = (String) event.get("command");
session.sendConsoleCommand("", command);
}
} catch (NotesException e) {
e.printStackTrace();
}

event.put("lastRun", new Date());
}
}

0 comments on commit 0eb2635

Please sign in to comment.