/// <summary> /// 实体类转视图类 /// </summary> /// <param name="model">实体类</param> /// <returns>视图类</returns> private ModelView.ApoActView Model2View(Model.TableModel.Apo_act model) { ModelView.ApoActView view = new ModelView.ApoActView(); view.id = model.id; view.status_name = model.status_name; view.status_no = model.status_no; view.act_no = model.act_no; view.apo_no = model.apo_no; view.apo_item_no = model.apo_item_no; view.apo_item_name = model.apo_item_name; view.apo_index = model.apo_index.ToString(); view.next_item_no = model.next_item_no; view.next_item_name = model.next_item_name; view.next_user_name = model.next_user_name; view.act_desc = model.act_desc; view.act_result = model.act_result?"通过":"驳回"; view.act_step = model.act_step.ToString(); view.act_user_no = model.act_user_no; view.act_user_name = model.act_user_name; view.act_time = model.act_time.ToString("yyyy-MM-dd HH:mm:ss.fff"); view.ralate_no = model.ralate_no; view.ralate_file_name = model.ralate_file_name; view.ralate_file_extension = model.ralate_file_extension; view.ralate_type_no = model.ralate_type_no; view.step_finished = model.step_finished ? "是" : "否"; view.apo_finished = model.apo_finished ? "是" : "否"; Ctrl.GlobalDataCtrl gdc = new GlobalDataCtrl(); view.dept_no = gdc.GetStrByField("dept_no", "sys_user", "user_no", view.act_user_no); view.dept_name = gdc.GetStrByField("dept_name", "sys_dept", "dept_no", view.act_user_no); return(view); }
/// <summary> /// 获取审核路径 /// </summary> /// <param name="apoCode">审核类型编码</param> /// <param name="ralateFileNo">审核的文件编号</param> /// <returns>标准审核流程列表</returns> public List <ModelView.ApoActView> GetList(string apoCode, string ralateFileNo) { List <ModelView.ApoActView> res = new List <ModelView.ApoActView>(); GlobalDataCtrl gdc = new GlobalDataCtrl(); string apoNo = gdc.GetStrByField("file_type_name", "dms_file_type", "file_type_no", apoCode); List <Model.TableModel.Apo_item> list = DbEngine.QueryList <Model.TableModel.Apo_item>(string.Format("apo_no='{0}' order by apo_index asc", apoNo)); if (list == null || list.Count <= 0) { return(res); } string lastApoItemNo = gdc.GetStrByField("apo_item_no", "apo_item", string.Format("next_item_no='-1' and apo_no='{0}'", apoNo)); List <Model.TableModel.Apo_act> listApoActAll = DbEngine.QueryList <Model.TableModel.Apo_act>(string.Format("ralate_no='{0}' and apo_finished='0'", ralateFileNo)); List <Model.TableModel.Apo_act> listApoAct = listApoActAll.FindAll(a => a.apo_item_no == lastApoItemNo); DateTime timeLine = DateTime.Now; List <DateTime> tmpTims = listApoAct.Select <Model.TableModel.Apo_act, DateTime>(a => a.act_time).ToList(); bool isBigAndEqual = false; if (tmpTims.Count > 0) { timeLine = tmpTims.Max(); isBigAndEqual = false; } else { List <DateTime> tmpTims2 = listApoActAll.Select <Model.TableModel.Apo_act, DateTime>(a => a.act_time).ToList(); timeLine = tmpTims2.Min(); isBigAndEqual = true; } List <Model.TableModel.Apo_act> listApoActStep = isBigAndEqual ? listApoActAll.FindAll(a => a.act_time >= timeLine) : listApoActAll.FindAll(a => a.act_time > timeLine); foreach (Model.TableModel.Apo_item item in list) { Model.TableModel.Apo_act modelApoAct = listApoActStep.Find(a => a.apo_no == item.apo_no && a.apo_index == item.apo_index); if (modelApoAct != null) { res.Add(Model2View(modelApoAct)); } else { res.Add(Model2View(item)); } } return(res); }
/// <summary> /// 根据当前登陆人员的编号,获取是否存在需要当前用户处理的动作 /// </summary> /// <param name="currentUserNo">当前用户编号</param> /// <returns>是否存在需要处理的动作</returns> private bool HasAction2User(string currentUserNo) { if (string.IsNullOrEmpty(currentUserNo)) { return(false); } GlobalDataCtrl globalDataCtrl = new GlobalDataCtrl(); string userName = globalDataCtrl.GetStrByField("user_name", "sys_user", "user_no", currentUserNo); List <Model.TableModel.Apo_act> list = DbEngine.QueryList <Model.TableModel.Apo_act>(string.Format("next_user_name='{0}' and step_finished='0' and apo_finished='0'", userName)); if (list == null) { return(false); } return(list.Count > 0); }
/// <summary> /// 获取下一审批实体 /// </summary> /// <param name="apoNo">审核流程</param> /// <param name="apoItemNo">当前审批实体流程编号</param> /// <returns>审批实体</returns> public ModelView.ApoItemView GetNext(string apoNo, string apoItemNo) { GlobalDataCtrl gdc = new GlobalDataCtrl(); string nextApoItemNo = gdc.GetStrByField("next_item_no", "apo_item", string.Format("apo_no='{0}' and apo_item_no='{1}'", apoNo, apoItemNo)); List <Model.TableModel.Apo_item> list = DbEngine.QueryList <Model.TableModel.Apo_item>(string.Format("apo_no='{0}' and apo_item_no='{1}'", apoNo, nextApoItemNo)); if (list == null) { return(null); } if (list.Count != 1) { return(null); } return(Model2View(list[0])); }
/// <summary> /// 视图类转实体类 /// </summary> /// <param name="view">视图类</param> /// <returns>实体类</returns> private Model.TableModel.Adn View2Model(ModelView.AdnView view) { Model.TableModel.Adn model = new Model.TableModel.Adn(); if (string.IsNullOrEmpty(view.id)) { model.id = Common.Md5Operate.CreateGuidId(); } else { model.id = view.id; } model.status_name = view.status_name; model.status_no = string.IsNullOrEmpty(view.status_no) ? "310" : view.status_no; GlobalDataCtrl globalDataCtrl = new GlobalDataCtrl(); model.andon_no = string.IsNullOrEmpty(view.andon_no) ? globalDataCtrl.GetNextNoByTblName("adn") : view.andon_no; model.andon_type_no = string.IsNullOrEmpty(view.andon_type_no) ? "01" : view.andon_type_no; model.andon_type_name = view.andon_type_name; model.andon_desc = view.andon_desc; model.dept_no = view.dept_no; model.eqm_no = string.IsNullOrEmpty(view.eqm_no)?"Default":view.eqm_no; model.andon_music_no = (model.dept_no + "_" + model.eqm_no + ".mp3").Replace("?", "").Replace("*", "").Replace(":", "\"").Replace("<", "").Replace(">", "").Replace("\\", "").Replace("/", "").Replace("|", ""); model.call_user_no = string.IsNullOrEmpty(view.call_user_no) ? "Server" : view.call_user_no; model.call_user_name = string.IsNullOrEmpty(view.call_user_name) ? "Server" : view.call_user_name; DateTime dt = DateTime.Now; model.call_time = DateTime.TryParse(view.call_time, out dt) ? dt : DateTime.Now; model.reply_user_no = string.IsNullOrEmpty(view.call_user_no) ? "Server" : view.call_user_no; model.reply_user_name = string.IsNullOrEmpty(view.call_user_name) ? "Server" : view.call_user_name; dt = DateTime.Now; model.reply_time = string.IsNullOrEmpty(view.reply_time) ? (DateTime?)null : (DateTime.TryParse(view.reply_time, out dt) ? dt : DateTime.Now); model.ralate_no = view.ralate_no; model.is_finished = string.IsNullOrEmpty(view.is_finished)?false:(view.is_finished == "是" ? true : false); GlobalDataCtrl gdc = new GlobalDataCtrl(); string tmp = gdc.GetStrByField("andon_play_eqm", "adn_type", "andon_type_no", model.andon_type_no); model.play_record = string.IsNullOrEmpty(tmp)?"0":tmp; return(model); }
/// <summary> /// 用户校验 /// </summary> /// <param name="userNo">用户编号</param> /// <param name="userPwd">用户密码</param> /// <returns>校验结果</returns> public bool UserValid(string userNo, string userPwd) { string encryptPwd = _gdc.GetStrByField("user_pwd", "sys_user", "user_no", userNo); return(Common.Md5Operate.GetMD5String(userPwd) == encryptPwd); }