/// <summary> /// 验证提交值 /// </summary> /// <param name="entity"></param> /// <param name="result"></param> private void EntityValiable(BLL.FW.BF_ST_FLOW.Entity entity, ref JsonResultData result) { result.IsSuccess = true; List <string> Message = new List <string>(); if (string.IsNullOrEmpty(entity.NAME)) { Message.Add("脚本流名称不能为空!"); } else { var _IsDuplicate = BLL.FW.BF_ST_FLOW.Instance.IsDuplicate(entity.ID, "NAME", entity.NAME); if (_IsDuplicate == true) { Message.Add("脚本流名称重复!"); } } if (entity.TYPE_ID == 0) { Message.Add("脚本流类型不能为空!"); } if (string.IsNullOrEmpty(entity.CRON)) { Message.Add("时间表达式不能为空!"); } if (Message.Count > 0) { result.IsSuccess = false; result.Message = string.Join("<br/>", Message); return; } }
public ActionResult Edit(int id = 0) { ViewBag.Result = false; ViewBag.Message = string.Empty; //渠道类型信息 DataTable dt = BLL.FW.BF_ST_TYPE.Instance.GetTable(); if (dt == null) { ViewBag.ScriptTypeSelect = "[]"; } else { var obj = new List <object>(); foreach (DataRow dr in dt.Rows) { obj.Add( new { id = Convert.ToInt32(dr["ID"]), pId = Convert.ToInt32(dr["PID"]), name = dr["NAME"].ToString() }); } ViewBag.ScriptTypeSelect = SerializeObject(obj); } //获取 IList <BLL.FW.BF_ST_FLOW_NODE.Entity> EntityFlowNode = new List <BLL.FW.BF_ST_FLOW_NODE.Entity>(); // BLL.FW.BF_ST_FLOW.Entity entity = new BLL.FW.BF_ST_FLOW.Entity(); entity.OFFSET = -1; if (id > 0) { entity = BLL.FW.BF_ST_FLOW.Instance.GetEntityByKey <BLL.FW.BF_ST_FLOW.Entity>(id); if (entity == null) { ViewBag.Message = "流程不存在"; entity = new BLL.FW.BF_ST_FLOW.Entity(); entity.ID = -1; } EntityFlowNode = BLL.FW.BF_ST_FLOW_NODE.Instance.GetList <BLL.FW.BF_ST_FLOW_NODE.Entity>(" FLOW_ID = ?", id); } ViewBag.ScriptFlowNode = SerializeObject(EntityFlowNode); return(View(entity)); }
public ActionResult Edit(BLL.FW.BF_ST_FLOW.Entity entity, FormCollection collection) { // JsonResultData result = new JsonResultData(); //验证 EntityValiable(entity, ref result); if (result.IsSuccess == false) { return(Json(result, JsonRequestBehavior.AllowGet)); } // var FLowId = entity.ID; string FlowNodeStr = Request["dicFlowNode"]; // Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("NAME", entity.NAME); dic.Add("TYPE_ID", entity.TYPE_ID); dic.Add("CRON", entity.CRON); dic.Add("OFFSET", entity.OFFSET); dic.Add("PARAMETERS", entity.PARAMETERS); dic.Add("RETRY_TIMES", entity.RETRY_TIMES); dic.Add("REMARK", entity.REMARK); dic.Add("UPDATE_UID", BLL.FW.SystemSession.UserID); dic.Add("UPDATE_TIME", DateTime.Now); if (entity.ID > 0) { var r = BLL.FW.BF_ST_FLOW.Instance.UpdateByKey(dic, entity.ID); if (r > 0) { result.IsSuccess = true; result.Message = "更新成功!"; } } else { dic.Add("IS_ENABLE", 1); dic.Add("CREATE_UID", BLL.FW.SystemSession.UserID); dic.Add("CREATE_TIME", DateTime.Now); var r = BLL.FW.BF_ST_FLOW.Instance.Add(dic, true); if (r > 0) { result.IsSuccess = true; result.Message = "添加成功!"; FLowId = entity.ID; } } if (result.IsSuccess) { if (!string.IsNullOrEmpty(FlowNodeStr)) { //更新节点 先删除 BLL.FW.BF_ST_FLOW_NODE.Instance.Delete(" FLOW_ID = ?", FLowId); // var _FlowNode = DeserializeObject <List <BLL.FW.BF_ST_FLOW_NODE.Entity> >(FlowNodeStr); List <Dictionary <string, object> > dicNodeList = new List <Dictionary <string, object> >(); foreach (var item in _FlowNode) { Dictionary <string, object> dicNode = new Dictionary <string, object>(); dicNode.Add("FLOW_ID", FLowId); dicNode.Add("NODE_ID", item.NODE_ID); dicNode.Add("PRE_NODE_IDS", item.PRE_NODE_IDS); dicNode.Add("DIV_X", item.DIV_X); dicNode.Add("DIV_Y", item.DIV_Y); dicNodeList.Add(dicNode); } var r = BLL.FW.BF_ST_FLOW_NODE.Instance.LoadDataInList(dicNodeList); if (r == _FlowNode.Count) { result.IsSuccess = true; result.Message = "更新条数"; } else { result.IsSuccess = false; result.Message = string.Format("更新条数不符合,需加入节点数:{0},导入节点数:{1}", _FlowNode.Count, r); } } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult look(int id = 0) { ViewBag.Result = false; ViewBag.Message = string.Empty; ViewBag.TASK_ID = id; //渠道类型信息 DataTable dt = BLL.FW.BF_ST_TYPE.Instance.GetTable(); if (dt == null) { ViewBag.ScriptTypeSelect = "[]"; } else { var obj = new List <object>(); foreach (DataRow dr in dt.Rows) { obj.Add( new { id = Convert.ToInt32(dr["ID"]), pId = Convert.ToInt32(dr["PID"]), name = dr["NAME"].ToString() }); } ViewBag.ScriptTypeSelect = SerializeObject(obj); } //获取 IList <BLL.FW.BF_ST_TASK_FLOW_NODE.Entity> EntityTaskFlowNode = new List <BLL.FW.BF_ST_TASK_FLOW_NODE.Entity>(); // BLL.FW.BF_ST_FLOW.Entity entity = new BLL.FW.BF_ST_FLOW.Entity(); if (id > 0) { var StTask = BLL.FW.BF_ST_TASK.Instance.GetEntityByKey <BLL.FW.BF_ST_TASK.Entity>(id); if (StTask == null) { ViewBag.Message = "脚本流不存在!"; entity.ID = -1; } else { //当脚本流ID大于0时,默认为脚本流 if (StTask.FLOW_ID > 0) { entity = BLL.FW.BF_ST_FLOW.Instance.GetEntityByKey <BLL.FW.BF_ST_FLOW.Entity>(StTask.FLOW_ID); if (entity == null) { ViewBag.Message = "流程不存在"; entity.ID = -1; } } EntityTaskFlowNode = BLL.FW.BF_ST_TASK_FLOW_NODE.Instance.GetList <BLL.FW.BF_ST_TASK_FLOW_NODE.Entity>(" TASK_ID = ? ", StTask.ID); var _r = EntityTaskFlowNode.Select(x => new { ID = x.ID, FLOW_ID = x.FLOW_ID, NODE_ID = x.NODE_ID, PRE_NODE_IDS = x.PRE_NODE_IDS, DIV_X = x.DIV_X, DIV_Y = x.DIV_Y, RUN_STATUS = x.RUN_STATUS, IS_SUCCESS = x.IS_SUCCESS, NODE_NAME = GetNodeNameByID(x.NODE_ID) }); ViewBag.ScriptFlowNode = SerializeObject(_r); } } else { ViewBag.ScriptFlowNode = SerializeObject(EntityTaskFlowNode); } return(View(entity)); }