use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.
the class SvrUserLogin method enrollMachineInfo.
private void enrollMachineInfo(String corpNo, String userCode, String deviceId, String deviceName) {
SqlQuery ds = new SqlQuery(this);
ds.add("select * from %s", SystemTable.get(SystemTable.getDeviceVerify));
ds.add("where UserCode_='%s' and MachineCode_='%s'", userCode, deviceId);
ds.open();
if (!ds.eof()) {
return;
}
ds.append();
ds.setField("CorpNo_", corpNo);
ds.setField("UserCode_", userCode);
ds.setField("VerifyCode_", intToStr(random(900000) + 100000));
ds.setField("DeadLine_", TDateTime.Now().incDay(1));
ds.setField("MachineCode_", deviceId);
if (deviceId.startsWith("i_")) {
// iOS
ds.setField("MachineType_", 6);
ds.setField("MachineName_", ClientType.IOS.toString());
} else if (deviceId.startsWith("n_")) {
// Android
ds.setField("MachineType_", 7);
ds.setField("MachineName_", ClientType.Android.toString());
} else {
// 系统默认
ds.setField("MachineType_", 0);
ds.setField("MachineName_", deviceName);
}
ds.setField("Remark_", "");
ds.setField("Used_", 0);
ds.setField("UpdateUser_", userCode);
ds.setField("UpdateDate_", TDateTime.Now());
ds.setField("AppUser_", userCode);
ds.setField("AppDate_", TDateTime.Now());
ds.setField("UpdateKey_", newGuid());
ds.post();
}
use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.
the class SvrUserMessages method getWaitList.
/**
* @return 取出所有的等待处理的消息列表
*/
public boolean getWaitList() {
SqlQuery ds = new SqlQuery(this);
ds.setMaximum(5);
ds.add("select ms.UID_ from %s ms", SystemTable.get(SystemTable.getUserMessages));
ds.add("where ms.Level_=%s", MessageLevel.Service.ordinal());
ds.add("and ms.Process_=%s", MessageProcess.wait.ordinal());
ds.open();
this.getDataOut().appendDataSet(ds);
return true;
}
use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.
the class SvrUserMessages method readAsyncService.
/**
* @return 读取指定的消息记录
*/
public boolean readAsyncService() {
String msgId = getDataIn().getHead().getString("msgId");
SqlQuery ds = new SqlQuery(this);
ds.add("select * from %s", SystemTable.get(SystemTable.getUserMessages));
ds.add("where Level_=%s", MessageLevel.Service.ordinal());
ds.add("and Process_=%s", MessageProcess.wait.ordinal());
ds.add("and UID_='%s'", msgId);
ds.open();
if (// 此任务可能被其它主机抢占
ds.eof())
return false;
Record headOut = getDataOut().getHead();
headOut.setField("corpNo", ds.getString("CorpNo_"));
headOut.setField("userCode", ds.getString("UserCode_"));
headOut.setField("subject", ds.getString("Subject_"));
headOut.setField("content", ds.getString("Content_"));
return true;
}
use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.
the class SecurityEnvironment method getUserSecuirtyMobile.
public static String getUserSecuirtyMobile(IForm form) {
SqlQuery ds1 = new SqlQuery(form.getHandle());
ds1.add("SELECT mobile_,securityMobile_,countryCode_ FROM %s", SystemTable.getUserInfo);
ds1.add("WHERE id_='%s'", form.getHandle().getUserCode());
ds1.open();
if (ds1.eof()) {
log.error(String.format("userCode %s 找不到", form.getHandle().getUserCode()));
return "";
}
String mobile = ds1.getString("mobile_");
if (!"".equals(ds1.getString("securityMobile_"))) {
mobile = ds1.getString("securityMobile_");
} else {
mobile = ds1.getString("countryCode_") + mobile;
}
return mobile;
}
use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.
the class SecurityEnvironment method isSecurity.
private static boolean isSecurity(AbstractForm form) {
String remoteIP = RemoteIP.get(form);
String clientId = form.getClient().getId();
String userId = form.getHandle().getUserCode();
log.debug(String.format("ip: %s, clientId:%s, userId: %s", remoteIP, clientId, userId));
String mobile = getUserSecuirtyMobile(form);
if ("".equals(mobile)) {
return false;
}
SqlQuery ds2 = new SqlQuery(form.getHandle());
ds2.add("select * from %s", SystemTable.getSecurityMobile);
ds2.add("where mobile_='%s'", mobile);
ds2.open();
if (ds2.eof()) {
return false;
}
if (!clientId.equals(ds2.getString("clientId_"))) {
return false;
}
if (!remoteIP.equals(ds2.getString("remoteIP_"))) {
return false;
}
// }
return true;
}
Aggregations