/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, WfConditionEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
public ActionResult SaveForm(string keyValue, WfConditionEntity entity) { string flowcode = "bosafety"; if (!string.IsNullOrEmpty(entity.SQLCONTENT)) { entity.SQLCONTENT = HttpCommon.Decrypt(entity.SQLCONTENT.ToUpper(), flowcode, flowcode); entity.SQLCONTENT = HttpUtility.UrlDecode(entity.SQLCONTENT); } wfconditionbll.SaveForm(keyValue, entity); return(Success("操作成功。")); }
public ActionResult SaveCopyForm(string keyValue) { var wfinstance = wfinstancebll.GetEntity(keyValue); //创建新的流程实例 WfInstanceEntity entity = new WfInstanceEntity(); entity = wfinstance; entity.ID = string.Empty; entity.INSTANCENAME = wfinstance.INSTANCENAME + "_复制对象"; wfinstancebll.SaveForm("", entity); string newId = entity.ID; //新的InstanceId if (!string.IsNullOrEmpty(newId)) { List <WfSettingEntity> slist = wfsettingbll.GetList(keyValue).ToList(); foreach (WfSettingEntity sentiy in slist) { string sourceSettingId = sentiy.ID; WfSettingEntity setting = new WfSettingEntity(); setting = sentiy; setting.ID = string.Empty; setting.INSTANCEID = newId; wfsettingbll.SaveForm("", setting); //新配置项 if (!string.IsNullOrEmpty(setting.ID)) { #region 新条件设置 List <WfConditionEntity> clist = wfconditionbll.GetList(sourceSettingId).ToList(); foreach (WfConditionEntity condition in clist) { string sourceConditionId = condition.ID; WfConditionEntity centity = new WfConditionEntity(); centity = condition; centity.ID = string.Empty; centity.SETTINGID = setting.ID; wfconditionbll.SaveForm("", centity); //新具体条件内容明细 if (!string.IsNullOrEmpty(centity.ID)) { List <WfConditionAddtionEntity> calist = wfconditionaddtionbll.GetList(sourceConditionId).ToList(); foreach (WfConditionAddtionEntity caentity in calist) { WfConditionAddtionEntity addentity = new WfConditionAddtionEntity(); addentity = caentity; addentity.ID = string.Empty; addentity.WFCONDITIONID = centity.ID; wfconditionaddtionbll.SaveForm("", addentity); } } } #endregion } } //条件 List <WfConditionOfRoleEntity> rolelist = wfconditionofrolebll.GetList(keyValue).ToList(); foreach (WfConditionOfRoleEntity rentity in rolelist) { WfConditionOfRoleEntity newrentity = new WfConditionOfRoleEntity(); newrentity = rentity; newrentity.ID = string.Empty; newrentity.INSTANCEID = newId; wfconditionofrolebll.SaveForm("", newrentity); } } return(Success("操作成功。")); }
/// <summary> /// 通过向导模式创建的新流程 /// </summary> /// <param name="queryJson"></param> public void SaveNewInstance(string queryJson) { try { List <ResultData> rlist = new List <ResultData>(); var queryParam = queryJson.ToJObject(); List <ResultData> resultList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ResultData> >(queryParam["RESULTDATA"].ToString()); //resultdata string intanceid = queryParam["INSTANCEID"].ToString(); //实例id string isenable = queryParam["ISENABLE"].ToString(); //是否启用 string instancename = queryParam["INSTANCENAME"].ToString(); //是否启用 #region 实例对象处理 //获取当前实例 WfInstanceEntity historyEntity = service.GetEntity(intanceid); //实例化新流程 WfInstanceEntity entity = new WfInstanceEntity(); entity = historyEntity; entity.INSTANCETYPE = "自有流程"; entity.ID = null; entity.ISENABLE = isenable; entity.INSTANCENAME = instancename; //固定配置点 --机构 rlist = resultList.Where(p => p.name == historyEntity.ORGANIZEID).ToList(); //机构id if (rlist.Count() == 1) { entity.ORGANIZEID = rlist.FirstOrDefault().value; } rlist = resultList.Where(p => p.name == historyEntity.ORGANIZENAME).ToList(); //机构名称 if (rlist.Count() == 1) { entity.ORGANIZENAME = rlist.FirstOrDefault().value; } service.SaveForm("", entity); //成功创建新流程实例 #endregion #region 实例流程转向处理 //处理流程转向配置 List <WfSettingEntity> settingList = wfsettingbll.GetList(intanceid).ToList(); foreach (WfSettingEntity historySetting in settingList) { string settingId = historySetting.ID; WfSettingEntity settingEntity = new WfSettingEntity(); settingEntity = historySetting; settingEntity.ID = null; settingEntity.INSTANCEID = entity.ID; //新的流程实例ID string replaceStr = historySetting.FLOWCODE.Split('-')[0].ToString(); settingEntity.FLOWCODE = historySetting.FLOWCODE.Replace(replaceStr, Str.PinYin(entity.ORGANIZENAME).ToUpper()); //固定配置点 --起始脚本 if (!string.IsNullOrEmpty(historySetting.SCRIPTCURCONTENT)) { foreach (ResultData resultdata in resultList) { if (historySetting.SCRIPTCURCONTENT.Contains(resultdata.name)) { historySetting.SCRIPTCURCONTENT = historySetting.SCRIPTCURCONTENT.Replace(resultdata.name, resultdata.value); } } settingEntity.SCRIPTCURCONTENT = historySetting.SCRIPTCURCONTENT; } //固定配置点--目标脚本 if (!string.IsNullOrEmpty(historySetting.SCRIPTCONTENT)) { foreach (ResultData resultdata in resultList) { if (historySetting.SCRIPTCONTENT.Contains(resultdata.name)) { historySetting.SCRIPTCONTENT = historySetting.SCRIPTCONTENT.Replace(resultdata.name, resultdata.value); } } settingEntity.SCRIPTCONTENT = historySetting.SCRIPTCONTENT; } wfsettingbll.SaveForm("", settingEntity); //新配置项 #region 新配置项 if (!string.IsNullOrEmpty(settingEntity.ID)) { //新条件设置 List <WfConditionEntity> clist = wfconditionbll.GetList(settingId).ToList(); //历史流程转向条件明细 foreach (WfConditionEntity historyCondition in clist) { string conditionId = historyCondition.ID; WfConditionEntity conditionEntity = new WfConditionEntity(); conditionEntity = historyCondition; conditionEntity.ID = null; conditionEntity.SETTINGID = settingEntity.ID; //固定配置点 --机构 rlist = resultList.Where(p => p.name == historyCondition.ORGANIZEID).ToList(); //机构id if (rlist.Count() == 1) { conditionEntity.ORGANIZEID = rlist.FirstOrDefault().value; } //机构名称 rlist = resultList.Where(p => p.name == historyCondition.ORGANIZENAME).ToList(); if (rlist.Count() == 1) { conditionEntity.ORGANIZENAME = rlist.FirstOrDefault().value; } //固定配置点--目标脚本 if (!string.IsNullOrEmpty(historyCondition.SQLCONTENT)) { foreach (ResultData resultdata in resultList) { if (historyCondition.SQLCONTENT.Contains(resultdata.name)) { historyCondition.SQLCONTENT = historyCondition.SQLCONTENT.Replace(resultdata.name, resultdata.value); } } conditionEntity.SQLCONTENT = historyCondition.SQLCONTENT; } wfconditionbll.SaveForm("", conditionEntity); //新具体条件内容明细 #region 新具体条件内容明细 if (!string.IsNullOrEmpty(conditionEntity.ID)) { List <WfConditionAddtionEntity> calist = wfconditionaddtionbll.GetList(conditionId).ToList(); foreach (WfConditionAddtionEntity historyAddtion in calist) { WfConditionAddtionEntity addtionEntiy = new WfConditionAddtionEntity(); addtionEntiy = historyAddtion; addtionEntiy.ID = string.Empty; addtionEntiy.WFCONDITIONID = conditionEntity.ID; //固定配置点 --机构 rlist = resultList.Where(p => p.name == historyAddtion.ORGANIZEID).ToList(); //机构id if (rlist.Count() == 1) { addtionEntiy.ORGANIZEID = rlist.FirstOrDefault().value; } //机构名称 rlist = resultList.Where(p => p.name == historyAddtion.ORGANIZENAME).ToList(); if (rlist.Count() == 1) { addtionEntiy.ORGANIZENAME = rlist.FirstOrDefault().value; } //固定配置点 --部门 rlist = resultList.Where(p => p.name == historyAddtion.DEPTNAME).ToList(); if (rlist.Count() == 1) { addtionEntiy.DEPTNAME = rlist.FirstOrDefault().value; } rlist = resultList.Where(p => p.name == historyAddtion.DEPTID).ToList(); if (rlist.Count() == 1) { addtionEntiy.DEPTID = rlist.FirstOrDefault().value; } rlist = resultList.Where(p => p.name == historyAddtion.DEPTCODE).ToList(); if (rlist.Count() == 1) { addtionEntiy.DEPTCODE = rlist.FirstOrDefault().value; } //固定配置点 --人员 rlist = resultList.Where(p => p.name == historyAddtion.USERNAME).ToList(); if (rlist.Count() == 1) { addtionEntiy.USERNAME = rlist.FirstOrDefault().value; } rlist = resultList.Where(p => p.name == historyAddtion.USERACCOUNT).ToList(); if (rlist.Count() == 1) { addtionEntiy.USERACCOUNT = rlist.FirstOrDefault().value; } wfconditionaddtionbll.SaveForm("", addtionEntiy); } } #endregion } } #endregion } #endregion } catch (Exception) { throw; } }