use of cn.cerc.jdb.core.DataSet in project summer-bean by cn-cerc.
the class StartServices method doProcess.
private void doProcess(String method, HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException, IOException {
String uri = req.getRequestURI();
AppConfig conf = Application.getAppConfig();
if (!uri.startsWith("/" + conf.getPathServices()))
return;
req.setCharacterEncoding("UTF-8");
resp.setContentType("text/html;charset=UTF-8");
ResponseData respData = new ResponseData();
// 将restPath转成service代码
DataSet dataIn = new DataSet();
String str = getParams(req);
if (null != str && !"[{}]".equals(str))
dataIn.setJSON(str);
String serviceCode = getServiceCode(method, req.getRequestURI().substring(1), dataIn.getHead());
log.info(req.getRequestURI() + " => " + serviceCode);
if (serviceCode == null) {
respData.setMessage("restful not find: " + req.getRequestURI());
resp.getWriter().write(respData.toString());
return;
}
log.debug(serviceCode);
log.info(dataIn);
try (AppHandle handle = new AppHandle()) {
// 执行指定函数
handle.init(req.getParameter("token"));
handle.setProperty(sessionId, req.getSession().getId());
IService bean = Application.getService(handle, serviceCode);
if (bean == null) {
respData.setMessage(String.format("service(%s) is null.", serviceCode));
resp.getWriter().write(respData.toString());
return;
}
if (!bean.checkSecurity(handle)) {
respData.setMessage("请您先登入系统");
resp.getWriter().write(respData.toString());
return;
}
DataSet dataOut = new DataSet();
IStatus status = bean.execute(dataIn, dataOut);
respData.setResult(status.getResult());
respData.setMessage(status.getMessage());
respData.setData(bean.getJSON(dataOut));
} catch (Exception e) {
Throwable err = e.getCause() != null ? e.getCause() : e;
log.error(err.getMessage(), err);
respData.setResult(false);
respData.setMessage(err.getMessage());
}
resp.getWriter().write(respData.toString());
}
use of cn.cerc.jdb.core.DataSet in project summer-mis by cn-cerc.
the class JPushRecord method send.
public void send(IHandle handle) {
LocalService svr = new LocalService(handle, "SvrUserLogin.getMachInfo");
if (!svr.exec("CorpNo_", corpNo, "UserCode_", userCode)) {
throw new RuntimeException(svr.getMessage());
}
// 设置极光推送平台
JiguangPush push = new JiguangPush(handle);
push.setMessage(alert);
push.setMsgId("" + msgId);
push.setTitle(title);
// 将消息推送到极光平台
DataSet dataOut = svr.getDataOut();
while (dataOut.fetch()) {
String machineCode = dataOut.getString("MachineCode_");
int machineType = dataOut.getInt("MachineType_");
switch(machineType) {
case 6:
push.send(ClientType.IOS, machineCode);
break;
case 7:
// 过滤掉没有注册IMEI码的移动设备
if (!"n_null".equals(machineCode) && !"n_000000000000000".equals(machineCode)) {
push.send(ClientType.Android, machineCode);
}
break;
default:
break;
}
}
}
use of cn.cerc.jdb.core.DataSet in project summer-mis by cn-cerc.
the class ProcessService method execute.
@Override
public void execute() {
LocalService svr = new LocalService(this, "SvrUserMessages.getWaitList");
if (!svr.exec())
throw new RuntimeException(svr.getMessage());
DataSet ds = svr.getDataOut();
while (ds.fetch()) {
log.info("开始处理异步任务,UID=" + ds.getString("UID_"));
processService(ds.getString("UID_"));
}
}
use of cn.cerc.jdb.core.DataSet in project summer-mis by cn-cerc.
the class ExportService method export.
public void export() throws WriteException, IOException, AccreditException {
if (service == null || "".equals(service))
throw new RuntimeException("错误的调用:service is null");
if (exportKey == null || "".equals(exportKey))
throw new RuntimeException("错误的调用:exportKey is null");
IHandle handle = (IHandle) this.getHandle();
LocalService app = new LocalService(handle);
app.setService(service);
try (MemoryBuffer buff = new MemoryBuffer(BufferType.getExportKey, handle.getUserCode(), exportKey)) {
app.getDataIn().close();
app.getDataIn().setJSON(buff.getString("data"));
}
if (!app.exec()) {
this.export(app.getMessage());
return;
}
DataSet dataOut = app.getDataOut();
// 对分类进行处理
dataOut.first();
while (dataOut.fetch()) {
if (dataOut.getBoolean("IsType_"))
dataOut.delete();
}
this.getTemplate().setDataSet(dataOut);
super.export();
}
use of cn.cerc.jdb.core.DataSet in project summer-mis by cn-cerc.
the class BooleanField method writeInput.
private void writeInput(HtmlWriter html) {
html.print(String.format("<input type=\"checkbox\" id=\"%s\" name=\"%s\" value=\"1\"", this.getId(), this.getId()));
boolean val = false;
DataSet dataSet = dataSource != null ? dataSource.getDataSet() : null;
if (dataSet != null)
val = dataSet.getBoolean(field);
if (val)
html.print(" checked");
if (this.isReadonly())
html.print(" disabled");
if (this.onclick != null)
html.print(" onclick=\"%s\"", this.onclick);
html.print(">");
}
Aggregations