Subject: Get local time based on field
You could write this using Java and the Domino supported Java classes.
We have a Java app we include in our applications for checking for updates. The applications are distributed to customers who, from their Notes client, select an option from the actions menu to check for updates to the application.
A java agent runs on the Notes client, connects to a webpage on our website and parses the retrieved HTML code to get the value(s) of the fields we need to determine if an update is available.
Alex
Here’s a sample of the Java code to get you started…
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
// Product update URL
String productURL = "<put url address here>";
// Connect to the URL and pull down the page
URL applicationURL = new URL(productURL);
BufferedReader bin = new BufferedReader ( new InputStreamReader(applicationURL.openStream( ) ));
String line;
StringBuffer sb = new StringBuffer();
while ( (line = bin.readLine( )) != null ) {
sb.append(line);
}
String responseString = sb.toString();
// Create a document in this database and call ComputeWithForm to parse the
// received data.
Document updateDoc = db.createDocument();
updateDoc.replaceItemValue ("Form", "UpdateForm");
updateDoc.replaceItemValue ("ApplicationPage", responseString);
updateDoc.computeWithForm( true , false);
updateDoc.save( true, true );
// Check the NewUpdateFound field to see if a new version was detected.
String newVersionFound = updateDoc.getItemValueString("NewUpdateFound");
.
.
.
.
.
And then we have an editable field on the form we created which does the actual parsing (processing each Input item & value to get what we need) and its Input Translation formula is:
TextToParse:=@LowerCase(ApplicationPage);
ItemString:=“”;
ItemName:=“”;
ItemValue:=“”;
@While(
@Contains(TextToParse; "input name=\"");
@Do(
@Set("ItemString"; @Right(TextToParse; "input name=\""));
@If(
@Contains(ItemString; ">");
@Set("ItemString"; @Left(ItemString; ">"));
""
);
@Set("TextToParse"; @Right(TextToParse; ItemString));
@If(
@Contains(ItemString; "\"");
@Set("ItemName"; @Left(ItemString; "\""));
@Set("ItemName"; "")
);
@If(
@Contains(ItemString; "value=\"");
@Set("ItemValue"; @Right(ItemString; "value=\""));
@Set("ItemValue"; "")
);
@If(
@Contains(ItemValue; "\"");
@Set("ItemValue"; @Left(ItemValue; "\""));
""
);
@ReplaceSubstring(ItemName; " "; "_");
@If(
@Trim(ItemName) != "";
@SetField(ItemName; ItemValue);
""
);
@If(
@Trim(ItemName) = "version";
@If(
@Contains(ItemValue; ".");
@Do(
@SetField("MajorVersionNew"; @TextToNumber(@Left(ItemValue; ".")));
@SetField("MinorVersionNew"; @TextToNumber(@Right(ItemValue; ".")))
);
@Do(
@SetField("MajorVersionNew"; @TextToNumber(ItemValue));
@SetField("MinorVersionNew"; 0)
)
);
""
)
)
);
NewMajorVersion:=
@If(
@Trim(@Text(MajorVersionNew)) = "";
MajorVersionCurrent;
MajorVersionNew
);
NewMinorVersion:=
@If(
@Trim(@Text(MinorVersionNew)) = "";
MinorVersionCurrent;
MinorVersionNew
);
NewVersionCheck:=(NewMajorVersion*100) + NewMinorVersion;
CurrentVersionCheck:=(MajorVersionCurrent*100) + MinorVersionCurrent;
FIELD NewUpdateFound:=
@If(
NewVersionCheck > CurrentVersionCheck;
"A newer version (release " + @Trim(@Text(MajorVersionNew)) + "." + @Trim(@Text(MinorVersionNew)) + ") of this application was found. You are currently using release " + @Trim(@Text(MajorVersionCurrent)) + "." + @Trim(@Text(MinorVersionCurrent)) + ". It is recommended you download the latest release to benefit from new features, fixes and enhancements";
""
);