1. DinoQ Hello World

<%
scout.print("DinoQ Hello World.");
%>

2. Test Callee Program

Testing Call This Program by Other
<%
System.out.println("Count 1");
Thread.sleep(3000);
System.out.println("Count 2");
Thread.sleep(3000);
System.out.println("Count 3");
%>

3. Test Call Program

<%
scout.clear();
scout.print(scmain.call("ex.utils.testCallee"));
%>

4. Test Call Program with Async Process

<%
boolean ret = scmain.callAsync("ex.utils.testCallee");
if(ret){
scout.print("Completed call process.");
}else{
scout.print("Error in call process.");
}
%>

5. Get HTTP Info

<%
if(scin.httpRequest().getMethod().equals("GET")){
if(scin.httpRequest().getRequestURI().equals("/ex.utils.oauth20-TokenValidate")){
/* For Get */
scout.print(OAuthMain.handleTokenValidate(scin.httpRequest()));
}
}
%>

6. Gen Web to Picture

<%
scout.clear();
scout.set(x.Web.toJPG("https://www.dinoq.com/axahealthagent.Index"));
%>

7. Sent Mail

<%
String tt = scin.geti("param1") + "ATESTING :: DinoQ Alert: Your DinoQ account has been login to DinoQ platform.";
String ss = scin.geti("param2") + "Hi,\n\n"+
"Your security is very important to us. This email address was used to access the DinoQ platform from your account:\n"+
"------------------------------------------\n"+
"email: saksit@aibizz.com\n"+
"time: 2019-05-21 07:18:34 UTC\n"+
"IP address: 103.5.25.112\n"+
"browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15\n"+
"------------------------------------------\n\n"+
"If this was you, you can ignore this alert. If you suspect any suspicious activity on your account, please change your password and enable two-factor authentication: https://dinoq.com/profile\n\n"+
"If you have any questions or concerns, don't hesitate to get in touch: support@dinoq.com\n\n"+
"Best,\n\n"+
"DinoQ Team"+
"";
GMailUtility.send("saksit@dinoq.com", tt, ss);
%>

8. Gen QR Code

<%
scout.clear();
scout.set(x.QR.gen("TESTQR", 400, 400));
%>

9. Fill and Gen PDF file

<@
import java.util.HashMap;
import java.util.Map;
@>
<%
HashMap mapV = new HashMap();
mapV.put("Num1", "1-1111-11111-11-1");
mapV.put("Num2", "9-9999-99999-99-9");
scout.clear();
scout.set(x.PDF.genTemplate(mapV, "https://cdn.dinoq.com/datacontents/docs/OS4.pdf"));
%>

10. Gen CSV file

<%
List rows = new ArrayList();
rows.add(new String[]{"10","FirstName10","LastName10","100000"});
rows.add(new String[]{"11","FirstName11","LastName11","110000"});
rows.add(new String[]{"12","FirstName12","LastName12","120000"});
rows.add(new String[]{"13","FirstName13","LastName13","130000"});

scout.clear();
scout.set(x.CSV.toCSV(rows));
%>

11. Gen RSA Key

<%
String cc = "KKKKKKKK";
byte[] oo = x.QKey.rsaEncrypt(cc, x.QKey.pub());
scout.print(x.QKey.rsaDecrypt(oo, x.QKey.pri()));
scout.print(x.QKey.rsaDecrypt(oo, x.QKey.pri()));
String b64 = x.QKey.b64EncodeURL(oo);
scout.print(x.QKey.rsaDecrypt(x.QKey.b64DecodeByte(b64.getBytes()), x.QKey.pri()));
scout.print(x.QKey.rsaDecrypt(oo, x.QKey.pri()));
%>

12. Use Session Variable

<%
x.Session.get("name", scin);
x.Session.set("name", "value", scin);
x.Session.remove("name", scin);
%>

13. Get Parameter

<%
String query_empid = scin.isNullParam("empid")?"":scin.param("empid");
String query_name = scin.isNullParam("name")?"":scin.param("name");
%>

14. Get Parameter2

<%
if(scin.isParamValue("empid")){
scout.print("document.theFormSearch.empid.value = '" + scin.param("empid") + "';");
}
if(scin.isParamValue("name")){
scout.print("document.theFormSearch.name.value = '" + scin.param("name") + "';");
}
%>

15. Define Variable

<%
String entityName = "EmployeeInformationDB";
String baseName = "EmployeeInformation";
XData entity = new XData(entityName);
XDataModel dataModel = entity.getModel();
%>

16. Generate HTML from x.html library

<%=
lib.Html.A()
.clazz("btn btn-sm btn-bpuristblue f16")
.href(lib.Html.inScript("history.go(-1)"))
.text("Back")
.go();
=%>

17. Generate field from Data object

<%=
lib.Html.Div().clazz("ui form").text(
lib.Html.Div().clazz("field").texts(
lib.Html.Label().clazz("f16").text("Empoyee ID : ").go(),
lib.Html.Input().clazz("f16").id("empid").name("empid").type("text").value(lib.Sys.toValue(entity.get("empid"))).go()
).go()
).go();
=%>

18. Import Class

<@
import java.util.List;
import java.util.Collection;
import th.co.skylogicsystem.skyframework.core.datalayer.XData;
import x.data.common.XDataModel;
import org.apache.commons.lang.StringUtils;
import th.co.skylogicsystem.skyframework.core.utils.security.SecurityUtils;
import th.co.skylogicsystem.skyframework.core.utils.web.MultipartFormUtil;
@>

19. Check MultipartForm value

<%
MultipartFormUtil mForm = new MultipartFormUtil(scin.httpRequest());
Boolean chkFlag = new Boolean(true);
if(x.Str.isEmpty(mForm.getField("empid"))){
chkFlag = false;
}
%>

20. Get realid from fakeid

<%
XData data = new XData();
if(!x.Str.isEmpty(mForm.getField("id"))){
String fake_id = mForm.getField("id").toString();
String real_id = lib.Data.getID4MapObjects(entityName, fake_id, scin);
data.set("id", real_id);
}
%>

21. Check require fields

<%=
lib.Html.Div().clazz("alert alert-warning").text(
(!x.Str.isEmpty(mForm.getField("empid"))?"":"Please enter Employee ID" + lib.Html.br()) +
(!x.Str.isEmpty(mForm.getField("name"))?"":"Please enter Name" + lib.Html.br()) +
"Can not save data."
).go();
=%>