public ActionResult Edit(string id) { ViewBag.Perm = GetPermission(); Flow_StepRuleModel entity = m_BLL.GetById(id); return(View(entity)); }
public bool Create(ref ValidationErrors errors, Flow_StepRuleModel model) { try { Flow_StepRule entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Suggestion.PrimaryRepeat); return(false); } entity = new Flow_StepRule(); entity.AttrId = model.AttrId; entity.Id = model.Id; entity.NextStep = model.NextStep; entity.Operator = model.Operator; entity.Result = model.Result; entity.StepId = model.StepId; if (m_Rep.Create(entity) == 1) { return(true); } errors.Add(Suggestion.InsertFail); return(false); } catch (Exception ex) { errors.Add(ex.Message); ExceptionHandler.WriteException(ex); return(false); } }
/// <summary> /// 校验Excel数据,这个方法一般用于重写校验逻辑 /// </summary> public virtual bool CheckImportData(string fileName, List <Flow_StepRuleModel> list, ref ValidationErrors errors) { var targetFile = new FileInfo(fileName); if (!targetFile.Exists) { errors.Add("导入的数据文件不存在"); return(false); } var excelFile = new ExcelQueryFactory(fileName); //对应列头 excelFile.AddMapping <Flow_StepRuleModel>(x => x.StepId, "所属步骤"); excelFile.AddMapping <Flow_StepRuleModel>(x => x.AttrId, "字段ID"); excelFile.AddMapping <Flow_StepRuleModel>(x => x.Operator, "操作符号"); excelFile.AddMapping <Flow_StepRuleModel>(x => x.Result, "结果"); excelFile.AddMapping <Flow_StepRuleModel>(x => x.NextStep, "下一步骤ID"); //SheetName var excelContent = excelFile.Worksheet <Flow_StepRuleModel>(0); int rowIndex = 1; //检查数据正确性 foreach (var row in excelContent) { var errorMessage = new StringBuilder(); var entity = new Flow_StepRuleModel(); entity.Id = row.Id; entity.StepId = row.StepId; entity.AttrId = row.AttrId; entity.Operator = row.Operator; entity.Result = row.Result; entity.NextStep = row.NextStep; //============================================================================= if (errorMessage.Length > 0) { errors.Add(string.Format( "第 {0} 列发现错误:{1}{2}", rowIndex, errorMessage, "<br/>")); } list.Add(entity); rowIndex += 1; } if (errors.Count > 0) { return(false); } return(true); }
public Flow_StepRuleModel GetById(string id) { if (IsExist(id)) { Flow_StepRule entity = m_Rep.GetById(id); Flow_StepRuleModel model = new Flow_StepRuleModel(); model.AttrId = entity.AttrId; model.Id = entity.Id; model.NextStep = entity.NextStep; model.Operator = entity.Operator; model.Result = entity.Result; model.StepId = entity.StepId; return(model); } return(null); }
public override bool Create(ref ValidationErrors errors, Flow_StepRuleModel model) { try { if (!ValidAttr(model.AttrId, model.Result)) { errors.Add("条件验证失败,类型和值不相符,如数字不能和字符串,日期类型必须是:2014-1-1格式"); return(false); } //判断条件是否可行 Flow_StepRule entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(false); } entity = new Flow_StepRule(); entity.Id = model.Id; entity.StepId = model.StepId; entity.AttrId = model.AttrId; entity.Operator = model.Operator; entity.Result = model.Result; entity.NextStep = model.NextStep; 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); } }
public virtual Flow_StepRuleModel GetById(object id) { if (IsExists(id)) { Flow_StepRule entity = m_Rep.GetById(id); Flow_StepRuleModel model = new Flow_StepRuleModel(); model.Id = entity.Id; model.StepId = entity.StepId; model.AttrId = entity.AttrId; model.Operator = entity.Operator; model.Result = entity.Result; model.NextStep = entity.NextStep; return(model); } else { return(null); } }
public JsonResult Edit(Flow_StepRuleModel model) { if (model != null && ModelState.IsValid) { if (m_BLL.Edit(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",StepId" + model.StepId, "成功", "修改", "Flow_StepRule"); return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",StepId" + model.StepId + "," + ErrorCol, "失败", "修改", "Flow_StepRule"); return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail))); } }
public JsonResult CreateStepEvent(Flow_StepRuleModel model) { model.Id = ResultHelper.NewId; if (model != null && ModelState.IsValid) { if (stepRuleBLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",StepId" + model.Id, "成功", "创建", "Flow_StepRule"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed, model.Id))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",StepId" + model.Id + "," + ErrorCol, "失败", "创建", "Flow_StepRule"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail))); } }
public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(Flow_StepRuleModel model) { ValidationErrors errors = new ValidationErrors(); try { Flow_StepRule entity = await m_Rep.GetByIdAsync(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity = new Flow_StepRule(); entity.Id = model.Id; entity.StepId = model.StepId; entity.AttrId = model.AttrId; entity.Operator = model.Operator; entity.Result = model.Result; entity.NextStep = model.NextStep; 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 bool Edit(ref ValidationErrors errors, Flow_StepRuleModel model) { try { Flow_StepRule entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Suggestion.Disable); return(false); } entity.AttrId = model.AttrId; entity.AttrName = model.AttrName; entity.Id = model.Id; entity.NextStep = model.NextStep; entity.NextStepName = model.NextStepName; entity.Operator = model.Operator; entity.Result = model.Result; entity.StepId = model.StepId; if (m_Rep.Edit(entity) == 1) { return(true); } else { errors.Add(Suggestion.EditFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public virtual bool Edit(ref ValidationErrors errors, Flow_StepRuleModel model) { try { Flow_StepRule entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.Id = model.Id; entity.StepId = model.StepId; entity.AttrId = model.AttrId; entity.Operator = model.Operator; entity.Result = model.Result; entity.NextStep = model.NextStep; 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); } }