use of com.rebuild.core.configuration.ConfigurationException in project rebuild by getrebuild.
the class ProjectManager method getPlanOfProject.
/**
* @param planId
* @param projectId
* @return
*/
public ConfigBean getPlanOfProject(ID planId, ID projectId) {
if (projectId == null) {
Object[] o = Application.getQueryFactory().uniqueNoFilter(planId, "projectId");
projectId = o != null ? (ID) o[0] : null;
}
for (ConfigBean e : getPlansOfProject(projectId)) {
if (e.getID("id").equals(planId))
return e;
}
throw new ConfigurationException(Language.L("无效任务面板 (%s)", planId));
}
use of com.rebuild.core.configuration.ConfigurationException in project rebuild by getrebuild.
the class SMSender method sendSMS.
/**
* @param to
* @param content
* @param specAccount
* @return <tt>null</tt> if failed or SENDID
* @throws ConfigurationException If sms-account unset
*/
public static String sendSMS(String to, String content, String[] specAccount) throws ConfigurationException {
if (specAccount == null || specAccount.length < 3 || StringUtils.isBlank(specAccount[0]) || StringUtils.isBlank(specAccount[1]) || StringUtils.isBlank(specAccount[2])) {
throw new ConfigurationException(Language.L("短信账户未配置或配置错误"));
}
Map<String, Object> params = new HashMap<>();
params.put("appid", specAccount[0]);
params.put("signature", specAccount[1]);
params.put("to", to);
// Auto append the SMS-Sign
if (!content.startsWith("【")) {
content = "【" + specAccount[2] + "】" + content;
}
params.put("content", content);
HeavyStopWatcher.createWatcher("Subsms Send", to);
JSONObject rJson;
try {
String r = OkHttpUtils.post("https://api-v4.mysubmail.com/sms/send.json", params);
rJson = JSON.parseObject(r);
} catch (Exception ex) {
log.error("Subsms failed to send : " + to + " > " + content, ex);
return null;
} finally {
HeavyStopWatcher.clean();
}
if (STATUS_OK.equalsIgnoreCase(rJson.getString("status"))) {
String sendId = rJson.getString("send_id");
createLog(to, content, TYPE_SMS, sendId, null);
return sendId;
} else {
log.error("SMS failed to send : " + to + " > " + content + "\nError : " + rJson);
createLog(to, content, TYPE_SMS, null, rJson.getString("msg"));
return null;
}
}
use of com.rebuild.core.configuration.ConfigurationException in project rebuild by getrebuild.
the class ReportTemplateController method preview.
@GetMapping("/report-templates/preview")
public void preview(@IdParam ID reportId, HttpServletRequest request, HttpServletResponse response) throws IOException {
Object[] report = Application.createQueryNoFilter("select belongEntity from DataReportConfig where configId = ?").setParameter(1, reportId).unique();
Entity entity = MetadataHelper.getEntity((String) report[0]);
String sql = String.format("select %s from %s order by modifiedOn desc", entity.getPrimaryField().getName(), entity.getName());
Object[] random = Application.createQueryNoFilter(sql).unique();
if (random == null) {
response.sendError(400, Language.L("未找到可供预览的记录"));
return;
}
File file;
try {
File template = DataReportManager.instance.getTemplateFile(entity, reportId);
file = new EasyExcelGenerator(template, (ID) random[0]).generate();
} catch (ConfigurationException ex) {
response.sendError(400, Language.L("未找到可供预览的记录"));
return;
}
FileDownloader.setDownloadHeaders(request, response, file.getName());
FileDownloader.writeLocalFile(file, response);
}
Aggregations