@Override public Boolean SaveOrUpdateExecuteSetExecutePlan( GWTExecuteSetExecutePlan gwtExecuteSetExecutePlan) { // TODO Auto-generated method stub ExecuteSetExecutePlan old = null; if (!gwtExecuteSetExecutePlan.isNew()) { // 如果不为新增 old = esExecutePlanDAL.Get( Op.EQ( GWTExecuteSetExecutePlan.N_ID, Integer.parseInt(gwtExecuteSetExecutePlan.GetID()))); if (gwtExecuteSetExecutePlan.GetExecutePlanID().equals("-1")) { // 计划任务ID为-1,表示删除原有计划任务 esExecutePlanDAL.Del(old); return true; } } ExecuteSetExecutePlan data = ModelToBean(old, gwtExecuteSetExecutePlan); if (data.getAddUserId().equals("Administrator")) { data.setAddUserId("0"); } if (gwtExecuteSetExecutePlan.isNew()) { data.setAddTime(new Date()); esExecutePlanDAL.Add(data); } else { esExecutePlanDAL.Edit(data); } return true; }
private ExecuteSetExecutePlan ModelToBean( ExecuteSetExecutePlan bean, GWTExecuteSetExecutePlan model) { ExecuteSetExecutePlan plan; if (bean != null) { plan = bean; } else { plan = new ExecuteSetExecutePlan(); if (!model.isNew()) { plan.setId(Integer.parseInt(model.GetID())); } } plan.setAddUserId(model.GetAddUserID()); plan.setExecuteSetDirId(model.GetExecuteSetID()); plan.setExecutePlanId(Integer.parseInt(model.GetExecutePlanID())); plan.setSystemId(model.GetSystemID()); plan.setScheduledRunStatus(Integer.parseInt(model.GetScheduledRunStatus())); return plan; }
private GWTExecuteSetExecutePlan BeanToModel(ExecuteSetExecutePlan bean) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String beginRunTime = bean.getBeginRunTime() == null ? "" : sdf.format(bean.getBeginRunTime()); String endRunTime = bean.getEndRunTime() == null ? "" : sdf.format(bean.getEndRunTime()); String addTime = sdf.format(bean.getAddTime()); GWTExecuteSetExecutePlan gwtExecuteSetExecutePlan = new GWTExecuteSetExecutePlan( bean.getId().toString(), bean.getExecuteSetDirId(), bean.getExecutePlanId().toString(), bean.getSystemId(), bean.getAddUserId(), String.valueOf(bean.getScheduledRunStatus()), beginRunTime, endRunTime, addTime); String execSetName = DALFactory.GetBeanDAL(ExecuteSetDirectory.class) .Get(Op.EQ(GWTExecuteSetDirectory.N_ID, Integer.parseInt(bean.getExecuteSetDirId()))) .getName(); String execPlanName = DALFactory.GetBeanDAL(ExecutePlan.class) .Get(Op.EQ(GWTExecutePlan.N_ID, bean.getExecutePlanId())) .getName(); String userName = DALFactory.GetBeanDAL(User.class).Get(Op.EQ(GWTUser.N_id, bean.getAddUserId())).getName(); gwtExecuteSetExecutePlan.SetExecPlanName(execPlanName); gwtExecuteSetExecutePlan.SetExecuteSetName(execSetName); gwtExecuteSetExecutePlan.SetUserName(userName); return gwtExecuteSetExecutePlan; }