/// <summary> /// 删除登录 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="keyId">删除登录</param> /// <returns>删除登录</returns> public bool Login_Delete(string loginKey, ref ProInterface.ErrorInfo err, int keyId) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { try { var ent = db.fa_login.SingleOrDefault(a => a.ID == keyId); db.fa_login.Remove(ent); db.SaveChanges(); GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Delete); return(true); } catch (Exception e) { err.IsError = true; err.Message = e.Message; return(false); } } }
/// <summary> /// 满足条件记录数 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="whereLambda">条件lambda表达表</param> /// <returns></returns> public int Login_Count(string loginKey, ref ProInterface.ErrorInfo err, string whereLambda) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(0); } using (DBEntities db = new DBEntities()) { IList <fa_login> content = new List <fa_login>(); Expression <Func <fa_login, bool> > whereFunc; try { if (whereLambda == null || whereLambda.Trim() == "") { return(db.fa_login.Count()); } whereFunc = StringToLambda.LambdaParser.Parse <Func <fa_login, bool> >(whereLambda); return(db.fa_login.Where(whereFunc).Count()); } catch { err.IsError = true; err.Message = "条件表态式有误"; return(0); } } }
public object Login_Save(DBEntities db, string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.LOGIN inEnt, IList <string> allPar) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } var ent = db.fa_login.SingleOrDefault(a => a.ID == inEnt.ID); bool isAdd = false; if (ent == null) { isAdd = true; ent = Mapper.Map <LOGIN, fa_login>(inEnt); ent.ID = Fun.GetCurrvalSeqID <fa_login>(); } else { ent = Fun.ClassToCopy <ProInterface.Models.LOGIN, fa_login>(inEnt, ent, allPar); } if (isAdd) { ent = db.fa_login.Add(ent); } GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit); return(ent); }
/// <summary> /// 修改系统用户 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="inEnt">实体类</param> /// <returns>修改系统用户</returns> public bool User_Edit(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.USER inEnt) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { try { var ent = db.fa_user.SingleOrDefault(a => a.ID == inEnt.ID); ent = Fun.ClassToCopy <ProInterface.Models.USER, fa_user>(inEnt, ent); db.SaveChanges(); GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit); return(true); } catch (Exception e) { err.IsError = true; err.Message = e.Message; err.Excep = e; return(false); } } }
/// <summary> /// 添加系统用户 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="inEnt">实体类</param> /// <returns>添加系统用户</returns> public object User_Add(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.USER inEnt) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { fa_user reEnt = Fun.ClassToCopy <ProInterface.Models.USER, fa_user>(inEnt); reEnt = db.fa_user.Add(reEnt); try { db.SaveChanges(); GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Add); return(reEnt.ID); } catch (Exception e) { err.IsError = true; err.Message = e.Message; err.Excep = e; return(null); } } }
/// <summary> /// 查询一条 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="whereLambda">条件lambda表达表</param> /// <returns>查询一条</returns> public ProInterface.Models.LOGIN Login_Single(string loginKey, ref ProInterface.ErrorInfo err, string whereLambda) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { IList <fa_login> content = new List <fa_login>(); Expression <Func <fa_login, bool> > whereFunc; try { whereFunc = StringToLambda.LambdaParser.Parse <Func <fa_login, bool> >(whereLambda); } catch { err.IsError = true; err.Message = "条件表态式有误"; return(null); } var reEnt = db.fa_login.Where(whereFunc).ToList(); if (reEnt.Count > 0) { return(Fun.ClassToCopy <fa_login, ProInterface.Models.LOGIN>(reEnt[0])); } return(null); } }
/// <summary> /// 删除任务 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="keyId">删除任务</param> /// <returns>删除任务</returns> public bool TaskDelete(string loginKey, ref ProInterface.ErrorInfo err, int keyId) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { try { string delSql = @" DELETE FROM YL_TASK_FLOW_HANDLE_USER WHERE TASK_FLOW_ID IN (SELECT ID FROM YL_TASK_FLOW WHERE TASK_ID={0}); DELETE FROM YL_TASK_FLOW_HANDLE_FILES WHERE FLOW_HANDLE_ID IN (SELECT ID FROM YL_TASK_FLOW_HANDLE WHERE TASK_FLOW_ID IN (SELECT ID FROM YL_TASK_FLOW WHERE TASK_ID={0})); DELETE FROM YL_TASK_FLOW_HANDLE WHERE TASK_FLOW_ID IN (SELECT ID FROM YL_TASK_FLOW WHERE TASK_ID={0}); DELETE FROM YL_TASK_FLOW WHERE TASK_ID={0}; DELETE FROM YL_TASK WHERE ID={0}; "; delSql = string.Format(delSql, keyId); int i = 0; foreach (var t in delSql.Split(';')) { i = ExecuteNonQuery(1, t); } return(true); } catch { return(false); } } }
/// <summary> /// 检测用户是否超时 /// </summary> /// <param name="loginKey">登录凭证</param> /// <returns></returns> public static GlobalUser CheckLoginKey(string loginKey, ref ProInterface.ErrorInfo err) { GlobalUser re = GetUser(loginKey); if (re == null) { err.IsError = true; err.Message = "登录凭证过期或超时"; } return(re); }
/// <summary> /// 分页查询 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="pageIndex">当前页数</param> /// <param name="pageSize">页面大小</param> /// <param name="whereLambda">条件lambda表达表</param> /// <param name="orderField">排序字段</param> /// <param name="orderBy">排序方式</param> /// <returns>返回满足条件的泛型</returns> public IList <ProInterface.Models.LOGIN> Login_Where(string loginKey, ref ProInterface.ErrorInfo err, int pageIndex, int pageSize, string whereLambda, string orderField, string orderBy) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } if (pageIndex < 1) { pageIndex = 1; } if (pageSize < 1) { pageSize = 1; } int skipCount = (pageIndex - 1) * pageSize; if (orderField == null || orderField == "") { err.IsError = true; err.Message = "排序表态式不能为空"; return(null); } using (DBEntities db = new DBEntities()) { var allList = db.fa_login.AsQueryable(); if (whereLambda != null && whereLambda != "") { try { Expression <Func <fa_login, bool> > whereFunc = StringToLambda.LambdaParser.Parse <Func <fa_login, bool> >(whereLambda); allList = db.fa_login.Where(whereFunc); } catch { err.IsError = true; err.Message = "条件表态式有误"; return(null); } } if (orderBy == "asc") { allList = StringFieldNameSortingSupport.OrderBy(allList, orderField); } else { allList = StringFieldNameSortingSupport.OrderByDescending(allList, orderField); } var content = allList.Skip(skipCount).Take(pageSize).ToList(); return(Fun.ClassListToCopy <fa_login, ProInterface.Models.LOGIN>(content)); } }
/// <summary> /// 分页查询 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <returns>返回满足条件的泛型</returns> public IList <ProInterface.Models.USER> User_FindAll(string loginKey, ref ProInterface.ErrorInfo err) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { var allList = db.fa_user.ToList(); return(Fun.ClassListToCopy <fa_user, ProInterface.Models.USER>(allList)); } }
/// <summary> /// 查询一条 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="keyId">主键ID</param> /// <returns>查询一条</returns> public ProInterface.Models.TASK TaskSingleId(string loginKey, ref ProInterface.ErrorInfo err, int keyId) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { var ent = db.YL_TASK.SingleOrDefault(x => x.ID == keyId); var reEnt = new ProInterface.Models.TASK(); if (ent != null) { reEnt = Fun.ClassToCopy <YL_TASK, ProInterface.Models.TASK>(ent); } return(reEnt); } }
/// <summary> /// 查询一条 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="keyId">主键ID</param> /// <returns>查询一条</returns> public ProInterface.Models.LOGIN Login_SingleId(string loginKey, ref ProInterface.ErrorInfo err, int keyId) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { var ent = db.fa_login.SingleOrDefault(x => x.ID == keyId); var reEnt = new ProInterface.Models.LOGIN(); if (ent != null) { reEnt = Fun.ClassToCopy <fa_login, ProInterface.Models.LOGIN>(ent); } return(reEnt); } }
public ProInterface.Models.MODULE ModuleSingleCode(string loginKey, ref ProInterface.ErrorInfo err, string code) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { var ent = db.YL_MODULE.SingleOrDefault(x => x.CODE == code); var reEnt = new ProInterface.Models.MODULE(); if (ent != null) { reEnt = Fun.ClassToCopy <YL_MODULE, ProInterface.Models.MODULE>(ent); } return(reEnt); } }
/// <summary> /// 查询一条 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="id">条件lambda表达表</param> /// <returns>查询一条</returns> public ProInterface.Models.TModule ModuleSingleId(string loginKey, ref ProInterface.ErrorInfo err, int id) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { var ent = db.YL_MODULE.SingleOrDefault(x => x.ID == id); var reEnt = new ProInterface.Models.TModule(); if (ent != null) { reEnt = Fun.ClassToCopy <YL_MODULE, ProInterface.Models.TModule>(ent); reEnt.AllRoleIdArrStr = string.Join(",", ent.YL_ROLE.Select(x => x.ID)); } return(reEnt); } }
/// <summary> /// 修改模块 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="inEnt">实体类</param> /// <param name="allPar">更新的参数</param> /// <returns>修改模块</returns> public bool ModuleSave(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.TModule inEnt, IList <string> allPar) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { try { var ent = db.YL_MODULE.SingleOrDefault(a => a.ID == inEnt.ID); bool isAdd = false; if (ent == null) { isAdd = true; ent = Fun.ClassToCopy <ProInterface.Models.MODULE, YL_MODULE>(inEnt); ent.ID = Fun.GetSeqID <YL_MODULE>(); } else { ent = Fun.ClassToCopy <ProInterface.Models.MODULE, YL_MODULE>(inEnt, ent, allPar); } var allRoleId = inEnt.AllRoleIdArrStr.Split(',').Select(x => Convert.ToInt32(x)).ToList(); ent.YL_ROLE.Clear(); ent.YL_ROLE = db.YL_ROLE.Where(x => allRoleId.Contains(x.ID)).ToList(); if (isAdd) { db.YL_MODULE.Add(ent); } db.SaveChanges(); UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit); return(true); } catch (Exception e) { err.IsError = true; err.Message = e.Message; return(false); } } }
public static bool CheckPassword(ref ProInterface.ErrorInfo err, string pwdStr) { Regex r1 = new Regex(@"^(?=.*[a-z])"); Regex r2 = new Regex(@"^(?=.*[A-Z])"); Regex r3 = new Regex(@"^(?=.*[0-9])"); Regex r4 = new Regex(@"^(?=([\x21-\x7e]+)[^a-zA-Z0-9])"); if (pwdStr.Length < ProInterface.AppSet.PwdMinLength) { err.IsError = true; err.Message = string.Format("密码长度不够{0}位", ProInterface.AppSet.PwdMinLength); return(false); } int reInt = 0; if (r1.IsMatch(pwdStr)) { reInt++; } if (r2.IsMatch(pwdStr)) { reInt++; } if (r3.IsMatch(pwdStr)) { reInt++; } if (r4.IsMatch(pwdStr)) { reInt++; } if (reInt < ProInterface.AppSet.PwdComplexity) { err.IsError = true; err.Message = string.Format("密码必须包括字母大写、字母小写、数字和特殊字符中的其中{0}种", ProInterface.AppSet.PwdComplexity); return(false); } return(true); }
/// <summary> /// 删除公告 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="keyId">删除公告</param> /// <returns>删除公告</returns> public bool BulletinDelete(string loginKey, ref ProInterface.ErrorInfo err, int keyId) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { try { var ent = db.YL_BULLETIN.SingleOrDefault(a => a.ID == keyId); ent.YL_FILES.Clear(); ent.YL_ROLE.Clear(); foreach (var t in ent.YL_BULLETIN_REVIEW.ToList()) { db.YL_BULLETIN_REVIEW.Remove(t); } foreach (var t in ent.YL_BULLETIN_LOG.ToList()) { db.YL_BULLETIN_LOG.Remove(t); } db.YL_BULLETIN.Remove(ent); db.SaveChanges(); UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Delete); return(true); } catch (Exception e) { err.IsError = true; err.Message = e.Message; return(false); } } }
/// <summary> /// 修改登录 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="inEnt">实体类</param> /// <param name="allPar">更新的参数</param> /// <returns>修改登录</returns> public object Login_Save(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.LOGIN inEnt, IList <string> allPar) { using (DBEntities db = new DBEntities()) { try { var ent = Login_Save(db, loginKey, ref err, inEnt, allPar); db.SaveChanges(); return(ent); } catch (DbEntityValidationException e) { err.IsError = true; err.Message = Fun.GetDbEntityErrMess(e); return(null); } catch (Exception e) { err.IsError = true; err.Message = e.Message; return(null); } } }
public bool TaskFlowSave(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.TTaskFlow inEnt, IList <string> allPar) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(false); } var flow = db.YL_TASK_FLOW.Single(x => x.ID == inEnt.ID); if (string.IsNullOrEmpty(inEnt.ROLE_ID_STR)) //无转派 { flow.DEAL_STATUS = "处理完成"; if (flow.PARENT_ID != null) //有上级 { //是否全部处理 var noDealNum = flow.YL_TASK_FLOW2.YL_TASK_FLOW1.Where(x => x.IS_HANDLE == 0 && x.ID != flow.ID).Count(); if (noDealNum == 0) { var taskFlowNext2 = new YL_TASK_FLOW(); taskFlowNext2.ID = Fun.GetSeqID <YL_TASK_FLOW>(); taskFlowNext2.HANDLE_USER_ID = flow.YL_TASK_FLOW2.HANDLE_USER_ID; //taskFlowNext2.DEAL_USER_NAME = flow.YL_TASK_FLOW2.DEAL_USER_NAME; taskFlowNext2.LEVEL_ID = flow.LEVEL_ID + 1; taskFlowNext2.NAME = flow.YL_TASK_FLOW2.NAME; taskFlowNext2.HANDLE_URL = "~/TaskFlow/Handle"; taskFlowNext2.SHOW_URL = "~/TaskFlow/Single"; taskFlowNext2.IS_HANDLE = 0; taskFlowNext2.PARENT_ID = flow.YL_TASK_FLOW2.PARENT_ID; taskFlowNext2.TASK_ID = flow.TASK_ID; db.YL_TASK_FLOW.Add(taskFlowNext2); } } else { flow.YL_TASK.STATUS = "完成"; flow.YL_TASK.STATUS_TIME = DateTime.Now; } } else //转派 { flow.DEAL_STATUS = "分派处理"; if (!string.IsNullOrEmpty(inEnt.UserIdArrStr)) { IList <int> userIdArr = inEnt.UserIdArrStr.Split(',').Where(x => x.IsInt32()).Select(x => Convert.ToInt32(x)).ToList(); var allUser = db.YL_USER.Where(x => userIdArr.Contains(x.ID)).ToList(); var allRole = db.YL_ROLE.Where(x => x.YL_USER.Where(y => userIdArr.Contains(y.ID)).Count() > 0).ToList(); flow.ROLE_ID_STR = string.Join(",", allRole.Select(x => x.ID).ToList()); foreach (var t in flow.YL_TASK_FLOW1.ToList()) { if (allUser.SingleOrDefault(x => x.ID == t.HANDLE_USER_ID) == null) { db.YL_TASK_FLOW.Remove(t); } } foreach (var user in allUser) { YL_TASK_FLOW taskFlowNext1 = flow.YL_TASK_FLOW1.SingleOrDefault(x => x.HANDLE_USER_ID == user.ID); if (taskFlowNext1 == null) { taskFlowNext1 = new YL_TASK_FLOW(); taskFlowNext1.ID = Fun.GetSeqID <YL_TASK_FLOW>(); taskFlowNext1.HANDLE_USER_ID = user.ID; //taskFlowNext1.DEAL_USER_NAME = user.NAME; taskFlowNext1.LEVEL_ID = flow.LEVEL_ID + 1; taskFlowNext1.NAME = "承办人办理"; taskFlowNext1.HANDLE_URL = "~/TaskFlow/Handle"; taskFlowNext1.SHOW_URL = "~/TaskFlow/Single"; taskFlowNext1.IS_HANDLE = 0; taskFlowNext1.YL_TASK_FLOW2 = flow; taskFlowNext1.TASK_ID = flow.TASK_ID; flow.YL_TASK_FLOW1.Add(taskFlowNext1); } } } else //角色下所有用户 { } } flow.IS_HANDLE = 1; //if (!string.IsNullOrEmpty(inEnt.AllFilesStr)) //{ // var fileIdList = ProInterface.JSON.EncodeToEntity<IList<FILES>>(inEnt.AllFilesStr).Select(x => x.ID); // flow.YL_FILES.Clear(); // flow.YL_FILES = db.YL_FILES.Where(x => fileIdList.Contains(x.ID)).ToList(); //} //flow.REMARK = inEnt.REMARK; db.SaveChanges(); return(true); } }
public static IEnumerable <T> GetListWhere <T>(IEnumerable <T> inList, string orderFiled, string orderType, string orderValue, ref ProInterface.ErrorInfo error) { if (string.IsNullOrEmpty(orderValue)) { return(inList); } string whereLambda = ""; orderValue = orderValue.Trim(); if (orderValue.ToLower() == "null") { whereLambda = string.Format("x=>x.{0} {1} null", orderFiled, orderType); } else { if (orderValue.Substring(0, 1) == "\"") { orderValue = orderValue.Substring(1); } if (orderValue.Substring(orderValue.Length - 1) == "\"") { orderValue = orderValue.Substring(0, orderValue.Length - 1); } if (!orderValue.IsDouble()) { orderValue = "\"" + orderValue + "\""; } whereLambda = string.Format("x => x.{0} {1} {2}", orderFiled, orderType, orderValue); if (orderType != null && orderType.ToLower() == "like") { whereLambda = string.Format("x=>x.{0} != null && x.{0}.IndexOf({1})>-1", orderFiled, orderValue); } } if (!string.IsNullOrEmpty(whereLambda)) { try { Func <T, bool> whereFunc = StringToLambda.LambdaParser.Compile <Func <T, bool> >(whereLambda); inList = inList.Where(whereFunc); } catch { error.IsError = true; error.Message = "条件表态式[" + whereLambda + "]有误"; } } return(inList); }
public static IEnumerable <T> GetListOrder <T>(IEnumerable <T> inList, string orderFiled, string orderType, ref ProInterface.ErrorInfo error) { if (!string.IsNullOrEmpty(orderFiled)) { try { var dateType = Fun.GetClassProperType <T>(orderFiled).ToLower(); switch (dateType) { case "decimal": Func <T, decimal> whereFuncDecimal = StringToLambda.LambdaParser.Compile <Func <T, decimal> >("x=>x." + orderFiled); if (orderType == "asc") { inList = inList.OrderBy(whereFuncDecimal); } else { inList = inList.OrderByDescending(whereFuncDecimal); } break; case "int": Func <T, int> whereFuncInt = StringToLambda.LambdaParser.Compile <Func <T, int> >("x=>x." + orderFiled); if (orderType == "asc") { inList = inList.OrderBy(whereFuncInt); } else { inList = inList.OrderByDescending(whereFuncInt); } break; case "int32": Func <T, Int32> whereFuncInt32 = StringToLambda.LambdaParser.Compile <Func <T, Int32> >("x=>x." + orderFiled); if (orderType == "asc") { inList = inList.OrderBy(whereFuncInt32); } else { inList = inList.OrderByDescending(whereFuncInt32); } break; case "datetime": Func <T, DateTime> whereFuncDatetime = StringToLambda.LambdaParser.Compile <Func <T, DateTime> >("x=>x." + orderFiled); if (orderType == "asc") { inList = inList.OrderBy(whereFuncDatetime); } else { inList = inList.OrderByDescending(whereFuncDatetime); } break; default: Func <T, string> whereFunc = StringToLambda.LambdaParser.Compile <Func <T, string> >("x=>x." + orderFiled); if (orderType == "asc") { inList = inList.OrderBy(whereFunc); } else { inList = inList.OrderByDescending(whereFunc); } break; } return(inList); } catch { error.IsError = true; error.Message = "条件表态式[" + orderFiled + "]有误"; } } return(inList); }
/// <summary> /// 修改任务 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="inEnt">实体类</param> /// <param name="allPar">更新的参数</param> /// <returns>修改任务</returns> public bool TaskSave(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.TTask inEnt, IList <string> allPar) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { try { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(false); } var ent = db.YL_TASK.SingleOrDefault(a => a.ID == inEnt.ID); YL_TASK_FLOW taskFlow0 = new YL_TASK_FLOW(); bool isAdd = false; if (ent == null) { isAdd = true; if (inEnt.FLOW_ID != null && inEnt.FLOW_ID.Value != 0) { #region 非任务工单 YL_FLOW flow = db.YL_FLOW.SingleOrDefault(x => x.ID == inEnt.FLOW_ID); TNode tnode = new TNode(); tnode.FlowID = inEnt.FLOW_ID.Value; tnode.TaskName = inEnt.TASK_NAME; tnode.AllFilesStr = inEnt.AllFilesStr; tnode.UserIdArrStr = inEnt.UserIdArrStr; tnode.Remark = inEnt.REMARK; FunTask.StartTask(db, ref err, gu, tnode, inEnt.NowSubmitType); #endregion } else { #region 任务工单 FunTask.StartTaskNoFlow(db, ref err, gu, inEnt.TASK_NAME, inEnt.REMARK, inEnt.AllFilesStr, inEnt.UserIdArrStr, inEnt.ROLE_ID_STR); #endregion } } else { ent = Fun.ClassToCopy <ProInterface.Models.TASK, YL_TASK>(inEnt, ent, allPar); } db.SaveChanges(); UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit); return(true); } catch (DbEntityValidationException e) { err.IsError = true; err.Message = Fun.GetDbEntityErrMess(e); return(false); } catch (Exception e) { err.IsError = true; err.Message = Fun.GetExceptionMessage(e); return(false); } } }
/// <summary> /// 查询一条 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="code">代码</param> /// <returns>查询一条</returns> public ProInterface.Models.TQuery QuerySingleByCode(string loginKey, ref ProInterface.ErrorInfo err, string code) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { var queryEnt = db.YL_QUERY.Where(x => x.CODE == code).ToList(); if (queryEnt.Count > 0) { var reEnt = Fun.ClassToCopy <YL_QUERY, ProInterface.Models.TQuery>(queryEnt[0]); GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } var allAuth = queryEnt[0].YL_ROLE_QUERY_AUTHORITY.Where(x => gu.RoleID.Contains(x.ROLE_ID)).ToList(); foreach (var t in allAuth) { if (reEnt.NoAuthority == null) { if (t.NO_AUTHORITY == null) { reEnt.NoAuthority = ""; } else { reEnt.NoAuthority = t.NO_AUTHORITY; } } else { if (reEnt.NoAuthority == null) { reEnt.NoAuthority = ""; } if (t.NO_AUTHORITY == null) { t.NO_AUTHORITY = ""; } var allNowAuth = reEnt.NoAuthority.Split(',').ToList(); var thisAuth = t.NO_AUTHORITY.Split(','); foreach (var t0 in reEnt.NoAuthority.Split(',').ToList()) { if (!thisAuth.Contains(t0)) { allNowAuth.Remove(t0); } } reEnt.NoAuthority = string.Join(",", allNowAuth); } } return(reEnt); } return(null); } }
/// <summary> /// 分页查询 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="pageIndex">当前页数</param> /// <param name="pageSize">页面大小</param> /// <param name="whereLambda">条件lambda表达表</param> /// <param name="orderField">排序字段</param> /// <param name="orderBy">排序方式</param> /// <returns>返回满足条件的泛型</returns> public IList <ProInterface.Models.MODULE> SysModuleWhere(string loginKey, ref ProInterface.ErrorInfo err, int pageIndex, int pageSize, string whereLambda, string orderField, string orderBy) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } if (pageIndex < 1) { pageIndex = 1; } if (pageSize < 1) { pageSize = 1; } int skipCount = (pageIndex - 1) * pageSize; if (orderField == null || orderField == "") { err.IsError = true; err.Message = "排序表态式不能为空"; return(null); } using (DBEntities db = new DBEntities()) { var allList = db.YL_MODULE.Where(x => x.YL_ROLE.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).AsQueryable(); if (whereLambda != null && whereLambda != "") { try { Expression <Func <YL_MODULE, bool> > whereFunc = StringToLambda.LambdaParser.Parse <Func <YL_MODULE, bool> >(whereLambda); allList = allList.Where(whereFunc); } catch { err.IsError = true; err.Message = "条件表态式有误"; return(null); } } if (orderBy == "asc") { allList = StringFieldNameSortingSupport.OrderBy(allList, orderField); } else { allList = StringFieldNameSortingSupport.OrderByDescending(allList, orderField); } var content = allList.Skip(skipCount).Take(pageSize).ToList(); return(Fun.ClassListToCopy <YL_MODULE, ProInterface.Models.MODULE>(content)); } }
/// <summary> /// 强行停止一个任务 /// </summary> /// <param name="scriptId"></param> /// <returns></returns> public bool StopTask(int scriptId) { ProServer.Service db = new Service(); ProInterface.ErrorInfo error = new ProInterface.ErrorInfo(); return(db.ScriptCancel(ref error, scriptId)); }