use of com.publiccms.entities.sys.SysTask in project PublicCMS-preview by sanluan.
the class SysTaskAdminController method delete.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("delete")
public String delete(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
SysTask entity = service.getEntity(id);
if (null != entity) {
if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
service.delete(id);
scheduledTask.delete(id);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.task", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysTask in project PublicCMS-preview by sanluan.
the class SysTaskAdminController method runOnce.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("runOnce")
public String runOnce(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
SysTask entity = service.getEntity(id);
if (null != entity) {
if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
scheduledTask.runOnce(site, id);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "runOnce.task", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysTask in project PublicCMS-preview by sanluan.
the class SysTaskAdminController method recreate.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("recreate")
public String recreate(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
SysTask entity = service.getEntity(id);
if (null != entity) {
if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
service.updateStatus(id, ScheduledTask.TASK_STATUS_READY);
scheduledTask.create(site, entity.getId(), entity.getCronExpression());
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.task", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysTask in project PublicCMS-preview by sanluan.
the class ScheduledTask method init.
/**
* @param startDate
*/
public void init(Date startDate) {
if (null != scheduler) {
@SuppressWarnings("unchecked") List<SysTask> sysTaskList = (List<SysTask>) sysTaskService.getPage(null, null, startDate, null, null).getList();
for (SysTask sysTask : sysTaskList) {
SysSite site = siteService.getEntity(sysTask.getSiteId());
if (TASK_STATUS_ERROR == sysTask.getStatus()) {
sysTaskService.updateStatus(sysTask.getId(), TASK_STATUS_READY);
}
create(site, sysTask.getId(), sysTask.getCronExpression());
if (TASK_STATUS_PAUSE == sysTask.getStatus()) {
pause(site, sysTask.getId());
}
}
}
}
use of com.publiccms.entities.sys.SysTask in project PublicCMS-preview by sanluan.
the class SysTaskDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Integer id = handler.getInteger("id");
SysSite site = getSite(handler);
if (CommonUtils.notEmpty(id)) {
SysTask entity = service.getEntity(id);
if (null != entity && site.getId() == entity.getSiteId()) {
handler.put("object", entity).render();
}
} else {
Integer[] ids = handler.getIntegerArray("ids");
if (CommonUtils.notEmpty(ids)) {
List<SysTask> entityList = service.getEntitys(ids);
Map<String, SysTask> map = new LinkedHashMap<>();
for (SysTask entity : entityList) {
if (site.getId() == entity.getSiteId()) {
map.put(String.valueOf(entity.getId()), entity);
}
}
handler.put("map", map).render();
}
}
}
Aggregations