/// <summary> /// 保存数据 /// </summary> public virtual void SaveImportData(IEnumerable <JOB_TASKJOBS_LOGModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { JOB_TASKJOBS_LOG entity = new JOB_TASKJOBS_LOG(); entity.itemID = model.itemID; entity.sno = model.sno; entity.taskName = model.taskName; entity.Id = ResultHelper.NewId; entity.executeDt = model.executeDt; entity.executeStep = model.executeStep; entity.result = model.result; db.JOB_TASKJOBS_LOG.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }
public virtual JOB_TASKJOBS_LOGModel GetById(object id) { if (IsExists(id)) { JOB_TASKJOBS_LOG entity = m_Rep.GetById(id); JOB_TASKJOBS_LOGModel model = new JOB_TASKJOBS_LOGModel(); model.itemID = entity.itemID; model.sno = entity.sno; model.taskName = entity.taskName; model.Id = entity.Id; model.executeDt = entity.executeDt; model.executeStep = entity.executeStep; model.result = entity.result; return(model); } else { return(null); } }
public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(JOB_TASKJOBS_LOGModel model) { ValidationErrors errors = new ValidationErrors(); try { JOB_TASKJOBS_LOG entity = await m_Rep.GetByIdAsync(model.itemID); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity = new JOB_TASKJOBS_LOG(); entity.itemID = model.itemID; entity.sno = model.sno; entity.taskName = model.taskName; entity.Id = model.Id; entity.executeDt = model.executeDt; entity.executeStep = model.executeStep; entity.result = model.result; if (await m_Rep.CreateAsync(entity)) { return(new Tuple <ValidationErrors, bool>(errors, true)); } else { errors.Add(Resource.InsertFail); return(new Tuple <ValidationErrors, bool>(errors, false)); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(new Tuple <ValidationErrors, bool>(errors, false)); } }
public virtual bool Edit(ref ValidationErrors errors, JOB_TASKJOBS_LOGModel model) { try { JOB_TASKJOBS_LOG entity = m_Rep.GetById(model.itemID); if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.itemID = model.itemID; entity.sno = model.sno; entity.taskName = model.taskName; entity.Id = model.Id; entity.executeDt = model.executeDt; entity.executeStep = model.executeStep; entity.result = model.result; if (m_Rep.Edit(entity)) { return(true); } else { errors.Add(Resource.NoDataChange); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public virtual bool Create(ref ValidationErrors errors, JOB_TASKJOBS_LOGModel model) { try { JOB_TASKJOBS_LOG entity = m_Rep.GetById(model.itemID); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(false); } entity = new JOB_TASKJOBS_LOG(); entity.itemID = model.itemID; entity.sno = model.sno; entity.taskName = model.taskName; entity.Id = model.Id; entity.executeDt = model.executeDt; entity.executeStep = model.executeStep; entity.result = model.result; if (m_Rep.Create(entity)) { return(true); } else { errors.Add(Resource.InsertFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }