using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMAPP.Entity.Sys; using QMFrameWork.Data; using QMAPP.DAL.Sys; using System.Data; namespace QMAPP.BLL.Sys { /// /// 流程设置逻辑层对象 /// 创建者: /// 创建日期: /// public class WorkFlowBLL : BaseBLL { #region 获取流程设置信息 /// /// 获取流程设置信息 /// /// 条件 /// 信息 public FlowSet GetWorkFlow(FlowSet model) { try { FlowSetDAL dal = new FlowSetDAL(); //获取所有流程设置信息 List resultList = dal.GetList(); FlowSet flowSet = new FlowSet(); List distinctList = FindDistinct(resultList); //将机构拼成字符串返回前台显示 if (distinctList != null && distinctList.Count > 0) { foreach (ZPFlow zpf in distinctList) { //查找等于当前结点的所有记录 List tempList =resultList.FindAll(p=>p.FlowLevel == zpf.FlowLevel); string flowLevel = ""; int index = 0; foreach (ZPFlow fl in tempList) { if (flowLevel.IndexOf(fl.SOrgaDesc) > 0) { index++; continue; } //拼接组织字符串 flowLevel += fl.SOrgaDesc; if (index < tempList.Count - 1) { flowLevel += ","; } index++; } //当前为结点1 if (zpf.FlowLevel == 1) { flowSet.FlowLevel1 = flowLevel; } //当前为结点2 if (zpf.FlowLevel == 2) { flowSet.FlowLevel2 = flowLevel; } //当前为结点3 if (zpf.FlowLevel == 3) { flowSet.FlowLevel3 = flowLevel; } } } return flowSet; } catch (Exception ex) { throw ex; } } #endregion #region 查找LIST中流程结点的唯一值 /// /// 查找LIST中流程结点的唯一值 /// /// /// private List FindDistinct(List resultList) { if (resultList == null || resultList.Count <= 0) { return null; } List distinctList = new List(); foreach (ZPFlow zpf in resultList) { //判断LIST中该 记录是否存在 if (distinctList.Find(p => p.FlowLevel == zpf.FlowLevel) == null) { distinctList.Add(new ZPFlow() { FlowLevel = zpf.FlowLevel }); } } return distinctList; } #endregion #region 获取结点下的人员信息 /// /// 获取结点下的人员信息 /// /// 条件 /// 信息 public List GetUserByFlowLevel(ZPFlow zpFlow) { try { FlowSetDAL dal = new FlowSetDAL(); return dal.GetUserByFlowLevel(zpFlow); ; } catch (Exception ex) { throw ex; } } #endregion #region 保存流程用户 /// /// 保存流程用户 /// /// 信息 public int SaveSelectOrganization(string FlowLevel, string selectKey) { List insertList = new List(); try { FlowSetDAL dal = new FlowSetDAL(); string[] selectKeyArr = selectKey.Split(new char[] { ':' }); foreach (string sdept in selectKeyArr) { if (string.IsNullOrEmpty(sdept)) { continue; } ZPFlow zpFlow = new ZPFlow(); zpFlow.PID = Guid.NewGuid().ToString(); zpFlow.FlowLevel = Convert.ToInt32(FlowLevel); zpFlow.SDept = sdept; insertList.Add(zpFlow); } return dal.SaveUser(FlowLevel,insertList); ; } catch (Exception ex) { throw ex; } } #endregion } }