public void ChangeFlow(CheckFlow newFlow) { if (currFlow == newFlow) { return; } PerformanceCheckFlowBase temp = null; if (currFlow != CheckFlow.None) { if (FlowTable.TryGetValue(currFlow, out temp)) { temp.OnLeave(); } else { Debug.LogError("找不到flow:" + newFlow); } } if (newFlow != CheckFlow.None) { if (FlowTable.TryGetValue(newFlow, out temp)) { temp.OnEnter(); } else { Debug.LogError("找不到flow:" + newFlow); } } currFlow = newFlow; currFlowInstance = temp; }
public ActionResult CreateCheckFlow(string checkfunc) { ViewBag.winname = "win"; TempData["checkfunc"] = checkfunc; TempData["count"] = 0; LoginUser user = new LoginUser();; CheckFlow newFlow = new CheckFlow(); newFlow.Creator = user.UserName; newFlow.CreatTime = DateTime.Now; newFlow.TimeLimit = 24; return(View(newFlow)); }
public ActionResult UpdateCheckFlow(string id, string winname) { if (id != null) { ViewBag.winname = winname; T_CH_Checkflow orgin = db.T_CH_Checkflow.FirstOrDefault(l => l.ID == id); if (orgin != default(T_CH_Checkflow)) { CheckFlow orginFlow = new CheckFlow(); orginFlow.CheckFlowID = orgin.ID; orginFlow.Name = orgin.Name; orginFlow.TimeLimit = orgin.Time_limit; orginFlow.Creator = orgin.Creator; orginFlow.CreatTime = orgin.CreatorTime.datetimedata(); orginFlow.Disable = orgin.Disable.booldata(); TempData["checkfunc"] = id;//没有任何意义(仅仅是填个值使他不为空) TempData["checkflow"] = id; TempData["count"] = orginFlow.Checkers.Count - 1; return(View(orginFlow)); } } return(HttpNotFound()); }
/// <summary> /// 处理表单提交 /// </summary> /// <param name="collection"></param> /// <returns></returns> public ActionResult Submit(CheckFlow Flow, Checker[] checkers) { if (checkers.Any(item => db.T_HR_Staff.FirstOrDefault(l => l.StaffID == item.ID) == null)) { return(this.Direct(false)); } if (TempData["checkfunc"] != null) { if (TempData["checkflow"] != null) { string flowID = TempData["checkflow"].ToString(); T_CH_Checkflow orginflow = db.T_CH_Checkflow.Find(flowID); if (orginflow == null) { return(HttpNotFound()); } orginflow.ID = flowID; orginflow.Name = Flow.Name; orginflow.Time_limit = Flow.TimeLimit; orginflow.Creator = Flow.Creator; orginflow.CreatorTime = Flow.CreatTime; orginflow.Description = Flow.Description; orginflow.Disable = Flow.Disable; var orgincheckers = db.T_CH_Checker.Where(l => l.CheckFlowID == flowID).ToList(); foreach (var item in orgincheckers) { db.T_CH_Checker.Remove(item); } for (int i = 0; i < checkers.Length; i++) { T_CH_Checker item = new T_CH_Checker(); item.ID = Guid.NewGuid().ToString(); item.CheckFlowID = flowID; item.CheckerID = checkers[i].ID; item.lvl1 = checkers[i].lvl1; item.lvl2 = checkers[i].lvl2; db.T_CH_Checker.Add(item); } } else { T_CH_Checkflow newflow = new T_CH_Checkflow() { ID = Guid.NewGuid().ToString(), Name = Flow.Name, Time_limit = Flow.TimeLimit, Creator = Flow.Creator, CreatorTime = Flow.CreatTime, Description = Flow.Description, Disable = Flow.Disable }; T_CH_Checkfunc_Checkflow_relation newr = new T_CH_Checkfunc_Checkflow_relation() { Check_funcID = (string)TempData["checkfunc"], ID = Guid.NewGuid().ToString(), Check_flowID = newflow.ID }; db.T_CH_Checkflow.Add(newflow); db.T_CH_Checkfunc_Checkflow_relation.Add(newr); for (int i = 0; i < checkers.Length; i++) { T_CH_Checker item = new T_CH_Checker(); item.ID = Guid.NewGuid().ToString(); item.CheckFlowID = newr.Check_flowID; item.CheckerID = checkers[i].ID; item.lvl1 = checkers[i].lvl1; item.lvl2 = checkers[i].lvl2; db.T_CH_Checker.Add(item); } } try { db.SaveChanges(); } catch { return(this.Direct(false)); } } else { return(this.Direct(false)); } return(this.Direct()); }