//获取对应的提交的值 public string GetFormAttrVal(string attrId, Flow_Form formModel, Flow_FormContent formContentModel) { //获得对象的类型,model Type formContentType = formContentModel.GetType(); Type formType = formModel.GetType(); //查找名称为"A-Z"的属性 string[] arrStr = { "AttrA", "AttrB", "AttrC", "AttrD", "AttrE", "AttrF", "AttrG", "AttrH", "AttrI", "AttrJ", "AttrK" , "AttrL", "AttrM", "AttrN", "AttrO", "AttrP", "AttrQ", "AttrR", "AttrS", "AttrT", "AttrU" , "AttrV", "AttrW", "AttrX", "AttrY", "AttrZ" }; foreach (string str in arrStr) { object o = formType.GetProperty(str).GetValue(formModel, null); object v = formContentType.GetProperty(str).GetValue(formContentModel, null); if (o != null) { //查找model类的Class对象的"str"属性的值 if (o.ToString() == attrId) { return(v.ToString()); } } } return(""); }
private void InsertChecker(Flow_FormContent model, int i, Flow_Step stepModel, Flow_FormContentStepCheck stepCheckModel) { //获得流转规则下的审核人员 List <string> userIdList = new List <string>(); if (stepModel.FlowRule == FlowRuleEnum.Customer.ToString()) { string[] arrUserList = model.CustomMember.Split(','); foreach (string s in arrUserList) { userIdList.Add(s); } } else { userIdList = GetStepCheckMemberList(stepModel.Id, model.Id); } foreach (string userId in userIdList) { //批量建立步骤审核人表 Flow_FormContentStepCheckState stepCheckModelState = new Flow_FormContentStepCheckState(); stepCheckModelState.StepCheckId = stepCheckModel.Id.ToString(); stepCheckModelState.UserId = userId; stepCheckModelState.CheckFlag = "2"; stepCheckModelState.Reamrk = ""; stepCheckModelState.TheSeal = ""; stepCheckModelState.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd"); stepCheckStateBLL.m_Rep.Create(stepCheckModelState); } }
//[SupportFilter] public ActionResult Create(string id) { Flow_Form formModel = formBLL.m_Rep.Find(Convert.ToInt32(id)); //是否已经设置布局 if (!string.IsNullOrEmpty(formModel.HtmlForm)) { ViewBag.Html = formModel.HtmlForm; } else { ViewBag.Html = ExceHtmlJs(id); } Flow_FormContent model = new Flow_FormContent(); model.FormId = id; //创建成功取出步骤 List <Flow_Step> stepModelList = stepBLL.m_Rep.FindPageList(ref setNoPagerAscById, a => a.FormId == model.FormId).ToList(); Flow_Step stepModel = stepBLL.m_Rep.Find(Convert.ToInt32(stepModelList[0].Id)); if (stepModel.FlowRule == FlowRuleEnum.Customer.ToString()) { ViewBag.Checker = null; } else { List <string> users = GetStepCheckMemberList(stepModel.Id, Convert.ToInt32(id)); ViewBag.Checker = users; } return(View(model)); }
public int Create(Flow_FormContent entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Flow_FormContent.Add(entity); return(db.SaveChanges()); } }
public int Edit(Flow_FormContent entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Flow_FormContent.Attach(entity); db.Entry <Flow_FormContent>(entity).State = System.Data.Entity.EntityState.Modified; //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(db.SaveChanges()); } }
public string GetCurrentFormStep(Flow_FormContent model) { string stepName = GetCurrentFormStepModel(model).Name; if (!string.IsNullOrEmpty(stepName)) { return(stepName); } return("结束"); }
/// <summary> /// 保存数据 /// </summary> public virtual void SaveImportData(IEnumerable <Flow_FormContentModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { Flow_FormContent entity = new Flow_FormContent(); entity.Id = ResultHelper.NewId; entity.Title = model.Title; entity.UserId = model.UserId; entity.FormId = model.FormId; entity.FormLevel = model.FormLevel; entity.CreateTime = ResultHelper.NowTime; entity.AttrA = model.AttrA; entity.AttrB = model.AttrB; entity.AttrC = model.AttrC; entity.AttrD = model.AttrD; entity.AttrE = model.AttrE; entity.AttrF = model.AttrF; entity.AttrG = model.AttrG; entity.AttrH = model.AttrH; entity.AttrI = model.AttrI; entity.AttrJ = model.AttrJ; entity.AttrK = model.AttrK; entity.AttrL = model.AttrL; entity.AttrM = model.AttrM; entity.AttrN = model.AttrN; entity.AttrO = model.AttrO; entity.AttrP = model.AttrP; entity.AttrQ = model.AttrQ; entity.AttrR = model.AttrR; entity.AttrS = model.AttrS; entity.AttrT = model.AttrT; entity.AttrU = model.AttrU; entity.AttrV = model.AttrV; entity.AttrW = model.AttrW; entity.AttrX = model.AttrX; entity.AttrY = model.AttrY; entity.AttrZ = model.AttrZ; entity.CustomMember = model.CustomMember; entity.TimeOut = model.TimeOut; entity.IsDelete = model.IsDelete; db.Flow_FormContent.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }
public int Delete(string id) { using (AppsDBEntities db = new AppsDBEntities()) { Flow_FormContent entity = db.Flow_FormContent.SingleOrDefault(a => a.Id == id); if (entity != null) { db.Flow_FormContent.Remove(entity); } return(db.SaveChanges()); } }
public override Flow_FormContentModel GetById(object id) { if (IsExists(id)) { Flow_FormContent entity = m_Rep.GetById(id); Flow_FormContentModel model = new Flow_FormContentModel(); model.Id = entity.Id; model.Title = entity.Title; model.UserId = entity.UserId; model.UserName = entity.SysUser.UserName; model.TrueName = entity.SysUser.TrueName; model.PosName = entity.SysUser.SysPosition.Name; model.DepName = entity.SysUser.SysStruct.Name; model.FormId = entity.FormId; model.FormLevel = entity.FormLevel; model.CreateTime = entity.CreateTime; model.AttrA = entity.AttrA; model.AttrB = entity.AttrB; model.AttrC = entity.AttrC; model.AttrD = entity.AttrD; model.AttrE = entity.AttrE; model.AttrF = entity.AttrF; model.AttrG = entity.AttrG; model.AttrH = entity.AttrH; model.AttrI = entity.AttrI; model.AttrJ = entity.AttrJ; model.AttrK = entity.AttrK; model.AttrL = entity.AttrL; model.AttrM = entity.AttrM; model.AttrN = entity.AttrN; model.AttrO = entity.AttrO; model.AttrP = entity.AttrP; model.AttrQ = entity.AttrQ; model.AttrR = entity.AttrR; model.AttrS = entity.AttrS; model.AttrT = entity.AttrT; model.AttrU = entity.AttrU; model.AttrV = entity.AttrV; model.AttrW = entity.AttrW; model.AttrX = entity.AttrX; model.AttrY = entity.AttrY; model.AttrZ = entity.AttrZ; model.CustomMember = entity.CustomMember; model.TimeOut = entity.TimeOut; model.IsDelete = entity.IsDelete; return(model); } else { return(null); } }
public bool IsExist(string id) { using (AppsDBEntities db = new AppsDBEntities()) { Flow_FormContent entity = GetById(id); if (entity != null) { return(true); } return(false); } }
public Flow_Step GetCurrentFormStepModel(Flow_FormContent model) { List <Flow_FormContentStepCheck> stepCheckModelList = stepCheckBLL.GetListByFormId(model.FormId, model.Id.ToString()).ToList(); for (int i = 0; i < stepCheckModelList.Count(); i++) { if (stepCheckModelList[i].State == FlowStateEnum.Progress.ToString()) { return(stepBLL.Find(Convert.ToInt32(stepCheckModelList[i].StepId))); } } return(new Flow_Step()); }
public string GetCurrentStep(Flow_FormContent model) { string str = "结束"; List <Flow_FormContentStepCheck> stepCheckModelList = stepCheckBLL.GetListByFormId(model.FormId, model.Id.ToString()).ToList(); for (int i = stepCheckModelList.Count() - 1; i >= 0; i--) { if (stepCheckModelList[i].State == "2") { str = stepBLL.m_Rep.Find(Convert.ToInt32(stepCheckModelList[i].StepId)).Name; } } return(str); }
public virtual async Task <Flow_FormContentModel> GetByIdAsync(object id) { if (IsExists(id)) { Flow_FormContent entity = await m_Rep.GetByIdAsync(id); Flow_FormContentModel model = new Flow_FormContentModel(); model.Id = entity.Id; model.Title = entity.Title; model.UserId = entity.UserId; model.FormId = entity.FormId; model.FormLevel = entity.FormLevel; model.CreateTime = entity.CreateTime; model.AttrA = entity.AttrA; model.AttrB = entity.AttrB; model.AttrC = entity.AttrC; model.AttrD = entity.AttrD; model.AttrE = entity.AttrE; model.AttrF = entity.AttrF; model.AttrG = entity.AttrG; model.AttrH = entity.AttrH; model.AttrI = entity.AttrI; model.AttrJ = entity.AttrJ; model.AttrK = entity.AttrK; model.AttrL = entity.AttrL; model.AttrM = entity.AttrM; model.AttrN = entity.AttrN; model.AttrO = entity.AttrO; model.AttrP = entity.AttrP; model.AttrQ = entity.AttrQ; model.AttrR = entity.AttrR; model.AttrS = entity.AttrS; model.AttrT = entity.AttrT; model.AttrU = entity.AttrU; model.AttrV = entity.AttrV; model.AttrW = entity.AttrW; model.AttrX = entity.AttrX; model.AttrY = entity.AttrY; model.AttrZ = entity.AttrZ; model.CustomMember = entity.CustomMember; model.TimeOut = entity.TimeOut; model.IsDelete = entity.IsDelete; return(model); } else { return(null); } }
//[SupportFilter] public ActionResult Edit(string formId, string id) { //获得当前步骤ID string currentStepId = formContentBLL.GetCurrentStepCheckId(formId, id); Flow_Form formModel = formBLL.m_Rep.Find(Convert.ToInt32(formId)); //是否已经设置布局 if (!string.IsNullOrEmpty(formModel.HtmlForm)) { ViewBag.Html = formModel.HtmlForm; } else { ViewBag.Html = ExceHtmlJs(formId); } ViewBag.StepCheckMes = formContentBLL.GetCurrentStepCheckMes(ref setNoPagerAscById, formId, id, GetUserId()); ViewBag.StepCheckId = currentStepId; ViewBag.IsCustomMember = false; if (!string.IsNullOrEmpty(currentStepId)) { List <Flow_FormContentStepCheck> stepCheckModelList = stepCheckBLL.GetListByFormId(formId, id).ToList(); int j = 0;//下一个步骤 for (int i = 0; i < stepCheckModelList.Count(); i++) { if (currentStepId == stepCheckModelList[i].Id.ToString()) { j = i; } } //获得下个步骤 if (j + 1 < stepCheckModelList.Count()) { //查询第二步是否是自选 Flow_FormContentStepCheck stepModel = stepCheckModelList[j + 1]; if (stepModel.IsCustom == "true") { ViewBag.IsCustomMember = true; } } } Flow_FormContent model = formContentBLL.m_Rep.Find(Convert.ToInt32(id)); return(View(model)); }
//[SupportFilter(ActionName = "Index")] public ActionResult Edit(string formId, string id) { Flow_Form formModel = formBLL.m_Rep.Find(Convert.ToInt32(formId)); //是否已经设置布局 if (!string.IsNullOrEmpty(formModel.HtmlForm)) { ViewBag.Html = formModel.HtmlForm; } else { ViewBag.Html = ExceHtmlJs(formId); } ViewBag.StepCheckMes = formContentBLL.GetCurrentStepCheckMes(ref setNoPagerAscById, formId, id, GetUserId()); Flow_FormContent model = formContentBLL.m_Rep.Find(Convert.ToInt32(id)); return(View(model)); }
public string GetCurrentFormState(Flow_FormContent model) { if (Convert.ToDateTime(model.TimeOut) < ResultHelper.NowTime) { return(FlowStateEnum.Closed.ToString()); } List <Flow_FormContentStepCheck> stepCheckModelList = stepCheckBLL.GetListByFormId(model.FormId, model.KEY_Id).ToList(); var passList = from r in stepCheckModelList where r.State == FlowStateEnum.Pass.ToString() select r; if (passList.Count() == stepCheckModelList.Count()) { return(FlowStateEnum.Pass.ToString()); } var rejectList = from r in stepCheckModelList where r.State == FlowStateEnum.Reject.ToString() select r; if (rejectList.Count() > 0) { return(FlowStateEnum.Reject.ToString()); } return(FlowStateEnum.Progress.ToString()); }
public bool Create(ref ValidationErrors errors, Flow_FormContentModel model) { try { Flow_FormContent entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Suggestion.PrimaryRepeat); return(false); } entity = new Flow_FormContent(); entity.AttrA = model.AttrA; entity.AttrB = model.AttrB; entity.AttrC = model.AttrC; entity.AttrD = model.AttrD; entity.AttrE = model.AttrE; entity.AttrF = model.AttrF; entity.AttrG = model.AttrG; entity.AttrH = model.AttrH; entity.AttrI = model.AttrI; entity.AttrJ = model.AttrJ; entity.AttrK = model.AttrK; entity.AttrL = model.AttrL; entity.AttrM = model.AttrM; entity.AttrN = model.AttrN; entity.AttrO = model.AttrO; entity.AttrP = model.AttrP; entity.AttrQ = model.AttrQ; entity.AttrR = model.AttrR; entity.AttrS = model.AttrS; entity.AttrT = model.AttrT; entity.AttrU = model.AttrU; entity.AttrV = model.AttrV; entity.AttrW = model.AttrW; entity.AttrX = model.AttrX; entity.AttrY = model.AttrY; entity.AttrZ = model.AttrZ; entity.CreateTime = model.CreateTime; entity.CustomMember = model.CustomMember; entity.FormId = model.FormId; entity.FormLevel = model.FormLevel; entity.Id = model.Id; entity.TimeOut = model.TimeOut; entity.Title = model.Title; entity.UserId = model.UserId; if (m_Rep.Create(entity) == 1) { return(true); } else { errors.Add(Suggestion.InsertFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public virtual async Task <Tuple <ValidationErrors, bool> > EditAsync(Flow_FormContentModel model) { ValidationErrors errors = new ValidationErrors(); try { Flow_FormContent entity = await m_Rep.GetByIdAsync(model.Id); if (entity == null) { errors.Add(Resource.Disable); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity.Id = model.Id; entity.Title = model.Title; entity.UserId = model.UserId; entity.FormId = model.FormId; entity.FormLevel = model.FormLevel; entity.CreateTime = model.CreateTime; entity.AttrA = model.AttrA; entity.AttrB = model.AttrB; entity.AttrC = model.AttrC; entity.AttrD = model.AttrD; entity.AttrE = model.AttrE; entity.AttrF = model.AttrF; entity.AttrG = model.AttrG; entity.AttrH = model.AttrH; entity.AttrI = model.AttrI; entity.AttrJ = model.AttrJ; entity.AttrK = model.AttrK; entity.AttrL = model.AttrL; entity.AttrM = model.AttrM; entity.AttrN = model.AttrN; entity.AttrO = model.AttrO; entity.AttrP = model.AttrP; entity.AttrQ = model.AttrQ; entity.AttrR = model.AttrR; entity.AttrS = model.AttrS; entity.AttrT = model.AttrT; entity.AttrU = model.AttrU; entity.AttrV = model.AttrV; entity.AttrW = model.AttrW; entity.AttrX = model.AttrX; entity.AttrY = model.AttrY; entity.AttrZ = model.AttrZ; entity.CustomMember = model.CustomMember; entity.TimeOut = model.TimeOut; entity.IsDelete = model.IsDelete; if (await m_Rep.EditAsync(entity)) { return(new Tuple <ValidationErrors, bool>(errors, true)); } else { errors.Add(Resource.NoDataChange); return(new Tuple <ValidationErrors, bool>(errors, false)); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(new Tuple <ValidationErrors, bool>(errors, false)); } }
//[SupportFilter] public JsonResult Create(Flow_FormContent model) { //当前的Form模版 Flow_Form formModel = formBLL.m_Rep.Find(Convert.ToInt32(model.FormId)); //初始化部分数据 model.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd"); model.UserId = GetUserId(); model.Title = formModel.Name; model.TimeOut = DateTime.Now.AddDays(30).ToString("yyyy-MM-dd"); if (model != null) { if (formContentBLL.m_Rep.Create(model)) { //创建成功后把步骤取出 List <Flow_Step> stepModelList = stepBLL.m_Rep.FindPageList(ref setNoPagerAscBySort, a => a.FormId == model.FormId).ToList(); //查询步骤 int listCount = stepModelList.Count(); string IsEnd = "false"; for (int i = 0; i < listCount; i++) { string nextStep = ""; Flow_Step stepModel = stepModelList[i]; List <Flow_StepRule> stepRuleModelList = stepRuleBLL.m_Rep.FindList(a => a.StepId == stepModel.Id.ToString()).ToList(); //获取规则判断流转方向 foreach (Flow_StepRule stepRuleModel in stepRuleModelList) { string val = new FlowHelper().GetFormAttrVal(stepRuleModel.AttrId, formModel, model); //有满足流程结束的条件 if (!JudgeVal(stepRuleModel.AttrId, val, stepRuleModel.Operator, stepRuleModel.Result)) { if (stepRuleModel.NextStep != "0") { //获得跳转的步骤 nextStep = stepRuleModel.NextStep; //跳到跳转后的下一步 for (int j = 0; j < listCount; j++) { if (stepModelList[j].Id.ToString() == nextStep) { i = j;//跳到分支后的下一步 } } } else { //nextStep=0流程结束 IsEnd = "true"; } } } #region 插入步骤 //插入步骤审核表 Flow_FormContentStepCheck stepCheckModel = new Flow_FormContentStepCheck(); stepCheckModel.ContentId = model.Id.ToString(); stepCheckModel.StepId = stepModel.Id.ToString(); stepCheckModel.State = FlowStateEnum.Progress.ToString(); stepCheckModel.StateFlag = "false";//true此步骤审核完成 stepCheckModel.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd"); if (nextStep != "" && nextStep != "0") { stepCheckModel.IsEnd = (i == listCount) ? "true" : IsEnd;//是否流程的最后一步 } else { stepCheckModel.IsEnd = (i == listCount - 1) ? "true" : IsEnd;//是否流程的最后一步 } stepCheckModel.IsCustom = stepModel.FlowRule == FlowRuleEnum.Customer.ToString() ? "true" : "false"; if (stepCheckBLL.m_Rep.Create(stepCheckModel))//新建步骤成功 { InsertChecker(model, i, stepModel, stepCheckModel); } #endregion #region 插入分支步骤 if (nextStep != "" && nextStep != "0") { //不是最后一个审核人 if (listCount < 1 || i != listCount - 1) { IsEnd = "false"; } else { IsEnd = "true"; } stepCheckModel = new Flow_FormContentStepCheck(); stepCheckModel.ContentId = model.Id.ToString(); stepCheckModel.StepId = stepModel.Id.ToString(); stepCheckModel.State = FlowStateEnum.Progress.ToString(); stepCheckModel.StateFlag = "false"; //true此步骤审核完成 stepCheckModel.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd"); stepCheckModel.IsEnd = IsEnd; //是否流程的最后一步 stepCheckModel.IsCustom = stepModel.FlowRule == FlowRuleEnum.Customer.ToString() ? "true" : "false"; if (stepCheckBLL.m_Rep.Create(stepCheckModel))//新建步骤成功 { InsertChecker(model, i, stepModel, stepCheckModel); } } #endregion if (IsEnd == "true")//如果是最后一步就无需要下面继续了 { break; } IsEnd = "true"; } LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",AttrA" + model.AttrA, "成功", "创建", "Flow_FormContent"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",AttrA" + model.AttrA + "," + ErrorCol, "失败", "创建", "Flow_FormContent"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail))); } }