/// <summary> /// 满足条件记录数 /// </summary> /// <param name="loginKey">登录凭证</param> /// <param name="err">错误信息</param> /// <param name="whereLambda">条件lambda表达表</param> /// <returns></returns> public int SysModuleCount(string loginKey, ref ErrorInfo err, string whereLambda) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(0); } GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(0); } using (DBEntities db = new DBEntities()) { IList <YL_MODULE> content = new List <YL_MODULE>(); Expression <Func <YL_MODULE, bool> > whereFunc; try { if (whereLambda == null || whereLambda.Trim() == "") { return(db.YL_MODULE.Where(x => x.YL_ROLE.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).Count()); } whereFunc = StringToLambda.LambdaParser.Parse <Func <YL_MODULE, bool> >(whereLambda); return(db.YL_MODULE.Where(x => x.YL_ROLE.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).Where(whereFunc).Count()); } catch { err.IsError = true; err.Message = "条件表态式有误"; return(0); } } }
public IList <TUserMessage> UserMessageGetTypeNew(string loginKey, ref ErrorInfo err, int typeId) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } GlobalUser gu = Global.GetUser(loginKey); using (DBEntities db = new DBEntities()) { var type = db.YL_MESSAGE_TYPE.SingleOrDefault(x => x.ID == typeId); if (type == null) { err.IsError = true; err.Message = "消息类型不存在"; return(null); } var allEnt = db.YL_USER_MESSAGE.Where(x => x.STATUS == "等待" && x.USER_ID == gu.UserId && x.YL_MESSAGE.MESSAGE_TYPE_ID == typeId).OrderByDescending(x => x.MESSAGE_ID).ToList(); IList <TUserMessage> allReList = new List <TUserMessage>(); foreach (var t in allEnt) { var tmp = Fun.ClassToCopy <YL_USER_MESSAGE, TUserMessage>(t); tmp.TypeName = t.YL_MESSAGE.YL_MESSAGE_TYPE.NAME; allReList.Add(tmp); } return(allReList); } }
public bool ModuleUserAuthority(string loginKey, ref ErrorInfo err, string url) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(false); } using (DBEntities db = new DBEntities()) { url = string.Format("~{0}", url.Trim('~').Trim('&').Trim('?')); var allModule = db.YL_MODULE.Where(x => x.LOCATION.Equals(url)).ToList(); if (allModule.Count() > 0) { if (allModule.Where(x => x.YL_ROLE.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).Count() > 0) { return(true); } else { //return AppMeunUserAuthority(loginKey, ref err, url); return(false); } } return(true); } }
public bool SupTaskNodeSave(string loginKey, ref ErrorInfo err, ProInterface.Models.TNode inEnt) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } GlobalUser gu = Global.GetUser(loginKey); using (DBEntities db = new DBEntities()) { FunTask.SupUpDataTaskFlow(gu, ref err, db, inEnt.ID, inEnt.ToFlowNodeID, inEnt.Remark); if (err.IsError) { return(false); } YL_TASK_FLOW taskFlow = db.YL_TASK_FLOW.SingleOrDefault(x => x.ID == inEnt.ID); try { db.SaveChanges(); return(true); } catch (DbEntityValidationException error) { err.IsError = true; err.Message = error.Message; return(false); } } }
public TRole UserGetRole(string loginKey, ref ErrorInfo err) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } using (DBEntities db = new DBEntities()) { var ent = db.fa_user.SingleOrDefault(x => x.ID == gu.UserId); var allRole = ent.fa_role.ToList(); if (allRole.Count == 0) { return(null); } var reEnt = Fun.ClassToCopy <fa_role, TRole>(allRole[0]); reEnt.RoleConfigs = Fun.ClassListToCopy <fa_role_CONFIG, ROLE_CONFIG>(allRole[0].fa_role_CONFIG.ToList()); return(reEnt); } }
public FCSingleSeries ChartGetByQueryCodeSingle(string loginKey, ref ErrorInfo err, string queryCode, IList <QueryPara> paraList, ref string reSql) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时,请重新登录"; } FCSingleSeries fc = new FCSingleSeries(); using (DBEntities db = new DBEntities()) { var query = db.YL_QUERY.SingleOrDefault(x => x.CODE == queryCode); TQuery ent = Fun.ClassToCopy <YL_QUERY, TQuery>(query); string whereStr = ""; DataTable reDt = QueryDataTable(loginKey, ref err, queryCode, null, whereStr, paraList, ref reSql); for (int i = 0; i < reDt.Rows.Count; i++) { fc.data.Add(new FCSingleSeries_data { label = reDt.Rows[i][0].ToString(), value = reDt.Rows[i][1].ToString() }); } } return(fc); }
public int UserUpdateLocked(string loginKey, ref ErrorInfo err, string userIdStr, short lockVal) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(0); } using (DBEntities db = new DBEntities()) { var allUserId = userIdStr.Split(',').Select(x => Convert.ToInt32(x)).ToList(); var allUser = db.fa_user.Where(x => allUserId.Contains(x.ID)).ToList(); var allLoginName = allUser.Select(x => x.LOGIN_NAME).ToList(); var allLogin = db.fa_login.Where(x => allLoginName.Contains(x.LOGIN_NAME)).ToList(); foreach (var t in allUser) { t.IS_LOCKED = lockVal; } foreach (var t in allLogin) { t.IS_LOCKED = lockVal; } db.SaveChanges(); return(allUser.Count()); } }
public ProInterface.Models.Api.ApiPagingDataBean BulletinList(ref ErrorInfo err, ProInterface.Models.Api.ApiRequesPageBean inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); ApiPagingDataBean reEnt = new ApiPagingDataBean(); int skip = 0; if (inEnt.currentPage > 1) { skip = (inEnt.currentPage - 1) * inEnt.pageSize; } using (DBEntities db = new DBEntities()) { var tmpEnt = db.YL_BULLETIN.AsEnumerable(); var allData = tmpEnt.Where(x => x.IS_SHOW == 1 && x.ISSUE_DATE < DateTime.Now).OrderByDescending(x => x.IS_URGENT).ThenByDescending(x => x.ISSUE_DATE).AsEnumerable(); allData = allData.Where(x => x.YL_ROLE.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).AsEnumerable(); ErrorInfo error = new ErrorInfo(); #region 过虑条件 foreach (var filter in inEnt.searchKey) { if (filter.K == "CREATE_TIME" && filter.T == ">=" && !string.IsNullOrEmpty(filter.V)) { DateTime dt1 = DateTime.ParseExact(filter.V, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture); allData = allData.Where(x => x.CREATE_TIME >= dt1).AsEnumerable(); } else if (filter.K == "CREATE_TIME" && filter.T == "<=" && !string.IsNullOrEmpty(filter.V)) { DateTime dt2 = DateTime.ParseExact(filter.V, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture); allData = allData.Where(x => x.CREATE_TIME <= dt2).AsEnumerable(); } else if (filter.V == "全部") { allData = tmpEnt.Where(x => x.IS_SHOW == 1 && x.ISSUE_DATE < DateTime.Now).OrderByDescending(x => x.IS_URGENT).ThenByDescending(x => x.ISSUE_DATE).AsEnumerable(); } else { allData = Fun.GetListWhere <YL_BULLETIN>(allData, filter.K, filter.T, filter.V, ref error); } } #endregion var allList = allData.Skip(skip).Take(inEnt.pageSize).ToList(); reEnt.currentPage = inEnt.currentPage; reEnt.pageSize = inEnt.pageSize; reEnt.totalCount = allData.Count(); reEnt.totalPage = reEnt.totalCount / reEnt.pageSize; if (reEnt.totalCount % reEnt.pageSize != 0) { reEnt.totalPage++; } IList <TBulletin> reList = new List <TBulletin>(); foreach (var t in allList) { TBulletin tmp = Fun.ClassToCopy <YL_BULLETIN, TBulletin>(t); tmp.CONTENT = Fun.NoHTML(tmp.CONTENT); reList.Add(tmp); } reEnt.data = reList; } return(reEnt); }
public DataTable QueryExecute(string loginKey, ref ErrorInfo err, string queryCode, int pageIndex, int pageSize, string orderStr, string whereJsonStr, IList <QueryPara> paraList, ref string sqlStr) { DataTable reDt = new DataTable(); GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "用户【" + loginKey + "】登录超时,请重新登录"; return(reDt); } using (DBEntities db = new DBEntities()) { var query = db.YL_QUERY.SingleOrDefault(x => x.CODE == queryCode); TQuery ent = Fun.ClassToCopy <YL_QUERY, TQuery>(query); IList <QueryCfg> cfg = JSON.EncodeToEntity <IList <QueryCfg> >(query.QUERY_CFG_JSON); string whereStr = ""; ent.QUERY_CONF = MakeSql(gu, ent.QUERY_CONF, orderStr, whereJsonStr, paraList, ref whereStr, Fun.GetDataBaseType()); try { sqlStr = ent.QUERY_CONF; reDt = ExecuteSql(ent.QUERY_CONF, pageIndex, pageSize, orderStr, whereStr, query.DB_SERVER_ID.Value, cfg.Select(x => x.FieldName).ToList()); } catch (Exception e) { err.IsError = true; err.Message = e.Message; return(reDt); } } reDt.TableName = "tables1"; return(reDt); }
public bool TaskHandle(string loginKey, ref ErrorInfo err, TTask inEnt) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(false); } using (DBEntities db = new DBEntities()) { var allFIleId = ""; if (!string.IsNullOrEmpty(inEnt.AllFilesStr)) { var allFile = JSON.EncodeToEntity <IList <FILES> >(inEnt.AllFilesStr); allFIleId = string.Join(",", allFile.Select(x => x.ID)); } if (inEnt.FLOW_ID != null) { var reBool = FunTask.FlowSubmit(db, ref err, gu, inEnt.NowFlowId, inEnt.TaskContent, allFIleId, inEnt.UserIdArrStr, inEnt.ROLE_ID_STR, inEnt.IsStage, inEnt.NowSubmitType); } else { var reBool = FunTask.NoFlowSubmit(db, ref err, gu, inEnt.NowFlowId, inEnt.TaskContent, allFIleId, inEnt.UserIdArrStr, inEnt.ROLE_ID_STR, inEnt.IsStage, inEnt.NowSubmitType); } if (err.IsError) { return(false); } db.SaveChanges(); return(true); } }
public int TaskFlowAccept(string loginKey, ref ErrorInfo err, string taskFlowIdStr) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(0); } using (DBEntities db = new DBEntities()) { var allIdList = taskFlowIdStr.Split(',').Where(x => x.IsInt32()).Select(x => Convert.ToInt32(x)).ToList(); var taskFlow = db.YL_TASK_FLOW.Where(x => allIdList.Contains(x.ID)).ToList(); var i = 0; foreach (var t in taskFlow) { if (t.ACCEPT_TIME == null) { t.ACCEPT_TIME = DateTime.Now; i++; } } db.SaveChanges(); return(i); } }
public bool ModuleDelete(string loginKey, ref ErrorInfo err, int id) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { try { GlobalUser gu = Global.GetUser(loginKey); string region = gu.Region; var ent = db.YL_MODULE.SingleOrDefault(a => a.ID == id); ent.YL_ROLE.Clear(); ent.YL_USER.Clear(); db.YL_MODULE.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); } } }
public TUser UserGetNow(string loginKey, ref ErrorInfo err) { if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } using (DBEntities db = new DBEntities()) { var reEnt = db.fa_user.SingleOrDefault(x => x.ID == gu.UserId); if (reEnt != null) { var reUser = Fun.ClassToCopy <fa_user, ProInterface.Models.TUser>(reEnt); reUser.RoleAllID = ","; reUser.RoleAllName = ""; foreach (var t in reEnt.fa_role.ToList()) { reUser.RoleAllID += t.ID + ","; reUser.RoleAllName += "," + t.NAME; } if (reUser.RoleAllName.Length > 1) { reUser.RoleAllName = reUser.RoleAllName.Substring(1); } var dis = db.fa_district.SingleOrDefault(x => x.ID == gu.DistrictId); reUser.DistrictName = dis != null?dis.NAME:""; var myDisId = reEnt.DISTRICT_ID; var changeDis = db.fa_district.Where(x => x.LEVEL_ID == 2 && x.IN_USE == 1 && (x.ID == myDisId || x.PARENT_ID == myDisId)).OrderBy(x => x.ID).ToList(); reUser.CanChangeDistrict = Fun.ClassListToCopy <fa_district, DISTRICT>(changeDis); reUser.REMARK = ""; //if (reEnt.fa_user_INFO != null && reEnt.fa_user_INFO.YL_CHANNEL_INFO.Count() > 0) //{ // var allData = db.fa_user.Where(x => x.fa_user_INFO != null && x.DISTRICT_ID == reEnt.DISTRICT_ID && x.fa_role.Where(y => y.ID == 4).Count() > 0).ToList().Select(x => string.Format("渠道经理:{0}({1}) 归属:{2}", x.NAME, x.fa_user_INFO.PHONE_NUMBER, x.fa_district.NAME)).ToList(); // if (allData.Count() > 0) // { // allData = new List<string> { allData[0] }; // } // reUser.REMARK = string.Join("<br />", allData); //} //else //{ // reUser.REMARK = ""; //} var allModule = db.YL_MODULE.Where(x => x.IS_HIDE == 0 && x.fa_role.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).ToList(); reUser.MyModule = Fun.ClassListToCopy <YL_MODULE, MODULE>(allModule); return(reUser); } return(null); } }
public DISTRICT DistrictGetByUser(string loginKey, ref ErrorInfo err) { using (DBEntities db = new DBEntities()) { GlobalUser gu = Global.GetUser(loginKey); var reEnt = db.YL_DISTRICT.SingleOrDefault(x => x.ID == gu.DistrictId); return(Fun.ClassToCopy <YL_DISTRICT, DISTRICT>(reEnt)); } }
public DISTRICT DistrictAdd(string loginKey, ref ErrorInfo err, DISTRICT inEnt) { using (DBEntities db = new DBEntities()) { YL_DISTRICT reEnt = Fun.ClassToCopy <ProInterface.Models.DISTRICT, YL_DISTRICT>(inEnt); #region 计算ID_PATH和Level_ID if (reEnt.PARENT_ID == null) { reEnt.LEVEL_ID = 1; reEnt.ID_PATH = "."; } else { var parent = db.YL_DISTRICT.Single(x => x.ID == reEnt.PARENT_ID); if (parent == null) { reEnt.LEVEL_ID = 1; reEnt.ID_PATH = "."; } else { reEnt.ID_PATH = parent.ID_PATH + reEnt.PARENT_ID + "."; reEnt.LEVEL_ID = parent.LEVEL_ID + 1; } } #endregion reEnt.ID = Fun.GetSeqID <YL_DISTRICT>(); #region 计算REGION GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { reEnt.REGION = reEnt.ID.ToString(); } else { reEnt.REGION = gu.Region; } #endregion reEnt.CODE = (string.IsNullOrEmpty(inEnt.CODE)) ? reEnt.ID.ToString() : inEnt.CODE; reEnt.IN_USE = 1; reEnt = db.YL_DISTRICT.Add(reEnt); try { db.SaveChanges(); UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Add); return(Fun.ClassToCopy <YL_DISTRICT, DISTRICT>(reEnt)); } catch (Exception e) { err.IsError = true; err.Message = e.Message; err.Excep = e; return(null); } } }
public bool UserMessageSaveByGlobalUser(GlobalUser gu, ref ErrorInfo err, string message, string allUserIdStr, int typeId) { ProInterface.Models.MESSAGE msg = new ProInterface.Models.MESSAGE(); msg.CONTENT = message; msg.MESSAGE_TYPE_ID = typeId; msg.DISTRICT_ID = AppSet.CityId; msg.PUSH_TYPE = "智能推送"; return(UserMessageSaveByGlobalUser(gu, ref err, msg, null, allUserIdStr)); }
public bool UserMessageSave(string loginKey, ref ErrorInfo err, ProInterface.Models.MESSAGE inEnt, IList <string> allPar, string allUserIdStr = null) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } GlobalUser gu = Global.GetUser(loginKey); return(UserMessageSaveByGlobalUser(gu, ref err, inEnt, allPar, allUserIdStr)); }
public ProInterface.Models.TBulletin BulletinSingle(string loginKey, ref ErrorInfo err, int?bullID) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { TBulletin reEnt = new TBulletin(); YL_BULLETIN ent = db.YL_BULLETIN.SingleOrDefault(x => x.ID == bullID); GlobalUser gu = Global.GetUser(loginKey); if (ent != null) { db.YL_BULLETIN_LOG.Add(new YL_BULLETIN_LOG { BULLETIN_ID = ent.ID, LOOK_TIME = DateTime.Now, USER_ID = gu.UserId }); db.SaveChanges(); reEnt = Fun.ClassToCopy <YL_BULLETIN, TBulletin>(ent); reEnt.AllFiles = Fun.ClassListToCopy <YL_FILES, FILES>(ent.YL_FILES.ToArray()); reEnt.AllFilesStr = JSON.DecodeToStr(reEnt.AllFiles); reEnt.AllRoleId = string.Join(",", ent.YL_ROLE.Select(x => x.ID).ToList()); var user = db.YL_USER.SingleOrDefault(x => x.ID == ent.USER_ID); if (user != null) { reEnt.DistrictName = user.YL_DISTRICT.NAME; } foreach (var t in ent.YL_BULLETIN_REVIEW.OrderBy(x => x.ADD_TIME).ToList()) { var tmp = Fun.ClassToCopy <YL_BULLETIN_REVIEW, ProInterface.Models.BulletinReview>(t); var userTmp = db.YL_USER.SingleOrDefault(x => x.ID == t.USER_ID); if (userTmp != null) { tmp.UserName = userTmp.NAME; tmp.DistictName = userTmp.YL_DISTRICT.NAME; tmp.UserPhone = userTmp.LOGIN_NAME; tmp.UserRole = string.Join(",", userTmp.YL_ROLE.Select(x => x.NAME).ToList()); } reEnt.AllChildrenItem.Add(tmp); } } else { reEnt.IS_URGENT = 1; reEnt.IS_IMPORT = 1; reEnt.IS_SHOW = 1; reEnt.REGION = gu.DistrictId.ToString(); } return(reEnt); } }
/// <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); }
public bool QuerySave(string loginKey, ref ErrorInfo err, QUERY inEnt, IList <string> allPar) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(false); } if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(false); } using (DBEntities db = new DBEntities()) { try { var ent = db.YL_QUERY.SingleOrDefault(a => a.ID == inEnt.ID); bool isAdd = false; if (ent == null) { isAdd = true; ent = Fun.ClassToCopy <ProInterface.Models.QUERY, YL_QUERY>(inEnt); } else { //if (!inEnt.QUERY_CONF.Equals(ent.QUERY_CONF)) //{ // inEnt.QUERY_CONF = string.Format("--{0}于{1}修改\r\n{2}",gu.UserName,DateTime.Now.ToString(),inEnt.QUERY_CONF); //} ent = Fun.ClassToCopy <ProInterface.Models.QUERY, YL_QUERY>(inEnt, ent, allPar); } if (isAdd) { db.YL_QUERY.Add(ent); } db.SaveChanges(); UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit); return(true); } catch (Exception e) { err.IsError = true; err.Message = Fun.GetExceptionMessage(e); return(false); } } }
public IList <System.Web.Mvc.SelectListItem> FlowAllRole(string loginKey, ref ErrorInfo err) { GlobalUser gu = Global.GetUser(loginKey); using (DBEntities db = new DBEntities()) { return(db.YL_ROLE.ToList().Select(x => new System.Web.Mvc.SelectListItem { Value = x.ID.ToString(), Text = x.NAME }).ToList()); } }
/// <summary> /// 上级或平级 /// </summary> /// <param name="loginKey"></param> /// <param name="err"></param> /// <param name="allRoleIdList"></param> /// <returns></returns> public IList <int> UserGetMasterUser(string loginKey, ref ErrorInfo err, List <int> allRoleIdList) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } return(UserGetMasterUserById(gu.UserId, ref err, allRoleIdList)); }
public IList <ProInterface.Models.OAUTH> LoginOauth(ref ErrorInfo err, string loginName, string password, string loginIP) { GlobalUser gu = new GlobalUser(); IList <ProInterface.Models.OAUTH> allOauth = new List <ProInterface.Models.OAUTH>(); if (string.IsNullOrEmpty(loginName) || string.IsNullOrEmpty(password)) { err.IsError = true; err.Message = "用户名和密码不能为空"; return(allOauth); } using (DBEntities db = new DBEntities()) { var LoginArr = db.YL_LOGIN.Where(x => x.LOGIN_NAME == loginName).ToList(); var Login = new YL_LOGIN(); if (LoginArr.Count() > 0) { Login = LoginArr[0]; } if (Login.PASSWORD.ToUpper() != password.Md5().ToUpper()) { if (Login.PASSWORD.ToUpper() != password.SHA1().ToUpper()) { if (password != "Easyman123@@@") { err.IsError = true; err.Message = "密码错误"; return(allOauth); } } } if (Login.IS_LOCKED == 1) { err.IsError = true; err.Message = string.Format("用户已被锁定【{0}】", Login.LOCKED_REASON); } else { allOauth = Fun.ClassListToCopy <YL_OAUTH, ProInterface.Models.OAUTH>(LoginArr[0].YL_OAUTH.ToList()); foreach (var t in allOauth) { t.openId = Login.LOGIN_NAME; t.state = DateTime.Now.ToString("yyyyMMddHHmmss"); t.access_token = string.Format("{0}{1}{2}", t.KEY, t.openId, t.state).Md5(); } } return(allOauth); } }
public TNodeFlow TaskNodeFlowSingle(string loginKey, ref ErrorInfo err, int taskFlowID) { GlobalUser gu = Global.GetUser(loginKey); using (DBEntities db = new DBEntities()) { var reEnt = db.YL_TASK_FLOW.SingleOrDefault(x => x.ID == taskFlowID); var ent = new ProInterface.Models.TNodeFlow(); ent.ID = reEnt.ID; //ent.FlowID = reEnt.YL_TASK.FLOW_ID; return(ent); } }
public bool LoginByPassWord(ref ErrorInfo err, string loginName, string password) { GlobalUser gu = new GlobalUser(); if (string.IsNullOrEmpty(loginName) || string.IsNullOrEmpty(password)) { err.IsError = true; err.Message = "用户名和密码不能为空"; return(false); } using (DBEntities db = new DBEntities()) { var LoginArr = db.YL_LOGIN.Where(x => x.LOGIN_NAME == loginName).ToList(); var Login = new YL_LOGIN(); if (LoginArr.Count() > 0) { Login = LoginArr[0]; } var user = db.YL_USER.SingleOrDefault(x => x.LOGIN_NAME == loginName); if (Login == null || user == null) { err.IsError = true; err.Message = "用户名不存在"; return(false); } else { if (Login.PASSWORD.ToUpper() != password.Md5().ToUpper()) { if (Login.PASSWORD.ToUpper() != password.SHA1().ToUpper()) { if (password != "Easyman123@@@") { err.IsError = true; err.Message = "密码错误"; return(false); } } } if (Login.IS_LOCKED == 1) { err.IsError = true; err.Message = string.Format("用户已被锁定【{0}】", Login.LOCKED_REASON); return(false); } return(true); } } }
/// <summary> /// 删除登录用户 /// </summary> /// <param name="gu"></param> public static void Remove(GlobalUser gu) { string filePath = string.Format("{0}/UpFiles/{1}.jpg", AppDomain.CurrentDomain.BaseDirectory, gu.Guid); if (File.Exists(filePath)) { try { File.Delete(filePath); } catch { } } _OnLines.Remove(gu); }
public byte[] QueryExportExcel(string loginKey, ref ErrorInfo err, string queryCode, string orderStr, string whereStr, IList <QueryPara> paraList, string allShow, ref string sqlStr, ref int allNum) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "用户【" + loginKey + "】登录超时,请重新登录"; return(null); } DataTable reDt = QueryDataTable(loginKey, ref err, queryCode, orderStr, whereStr, paraList, ref sqlStr); if (!string.IsNullOrEmpty(allShow)) { var allShowList = allShow.Split(',').ToList(); var nowColList = new List <string>(); for (var i = 0; i < reDt.Columns.Count; i++) { nowColList.Add(reDt.Columns[i].ColumnName); } var z1 = nowColList.Except(allShowList); foreach (var i in z1) { reDt.Columns.Remove(i); } } allNum = reDt.Rows.Count; using (DBEntities db = new DBEntities()) { YL_EXPORT_LOG ent = new YL_EXPORT_LOG(); ent.USER_ID = gu.UserId; ent.LOGIN_NAME = gu.UserName; ent.NAME = queryCode; ent.SQL = sqlStr; ent.EXPORT_TIME = DateTime.Now; db.YL_EXPORT_LOG.Add(ent); db.SaveChanges(); } return(ExcelHelper.ExportDTtoByte(reDt, "数据")); }
/// <summary> /// 同步菜单 /// </summary> /// <param name="loginKey"></param> /// <param name="err"></param> /// <param name="id"></param> /// <param name="url"></param> /// <returns></returns> public string GetTongBu(string loginKey, ref ErrorInfo err, int id, UrlHelper url) { try { GlobalUser gu = Global.GetUser(loginKey); using (DBEntities db = new DBEntities()) { ProInterface.IModule ems = new ProServer.Service(); var pt = db.YL_MODULE.SingleOrDefault(x => x.ID == id); string main = ""; string menu = ""; if (pt.PARENT_ID == null) { main = "{\"id\": \"0\", \"text\": \"主菜单\",\"attributes\":\"\"},"; var list = db.YL_MODULE.Where(k => k.PARENT_ID == null && k.IS_HIDE == 0 && k.YL_ROLE.Where(x => gu.RoleID.Contains(x.ID)).Count() > 0).OrderBy(t => t.SHOW_ORDER); foreach (var l in list) { l.LOCATION = l.LOCATION == null ? "" : url.Content(l.LOCATION); menu += "{\"id\": \"" + l.ID + "\", \"text\": \"" + l.NAME + "\",\"attributes\":\"" + l.LOCATION + "\"},"; } } else { var parent = db.YL_MODULE.SingleOrDefault(x => x.ID == pt.PARENT_ID.Value); parent.LOCATION = parent.LOCATION == null ? "" : url.Content(parent.LOCATION); main = "{\"id\": \"" + parent.ID + "\", \"text\": \"" + parent.NAME + "\",\"attributes\":\"" + parent.LOCATION + "\"},"; var list = db.YL_MODULE.Where(k => k.PARENT_ID == pt.PARENT_ID && k.IS_HIDE == 0 && k.YL_ROLE.Where(x => gu.RoleID.Contains(x.ID)).Count() > 0).OrderBy(t => t.SHOW_ORDER); foreach (var l in list) { l.LOCATION = l.LOCATION == null ? "" : url.Content(l.LOCATION); menu += "{\"id\": \"" + l.ID + "\", \"text\": \"" + l.NAME + "\",\"attributes\":\"" + l.LOCATION + "\"},"; } } string str = main + menu; str = str.Length > 0 ? (str.Substring(0, str.Length - 1)) : ""; return("[" + str + "]"); } } catch (Exception ex) { err.IsError = true; err.Message = ex.ToString(); return("[]"); } }
public int QueryCount(string loginKey, ref ErrorInfo err, string queryCode, string whereJsonStr, IList <QueryPara> paraList, ref string sqlStr) { using (DBEntities db = new DBEntities()) { var query = db.YL_QUERY.SingleOrDefault(x => x.CODE == queryCode); TQuery ent = Fun.ClassToCopy <YL_QUERY, TQuery>(query); GlobalUser gu = Global.GetUser(loginKey); string whereStr = ""; ent.QUERY_CONF = MakeSql(gu, ent.QUERY_CONF, null, whereJsonStr, paraList, ref whereStr, Fun.GetDataBaseType()); string withStr = ""; string WithStartStr = "-----WithStart-----"; string WithEndStr = "-----WithEnd-----"; int WithStartP = ent.QUERY_CONF.IndexOf(WithStartStr); int WithEndP = ent.QUERY_CONF.IndexOf(WithEndStr); if (WithStartP > -1 && WithEndP > -1 && WithEndP > WithStartP) { withStr = ent.QUERY_CONF.Substring(WithStartStr.Length, WithEndP - WithStartP - WithStartStr.Length); ent.QUERY_CONF = ent.QUERY_CONF.Substring(WithEndP + WithEndStr.Length); } if (!string.IsNullOrEmpty(whereStr)) { ent.QUERY_CONF = withStr + "SELECT * FROM ( " + ent.QUERY_CONF + " ) TMP where " + whereStr; } else { ent.QUERY_CONF = withStr + "SELECT * FROM ( " + ent.QUERY_CONF + " ) TMP"; } var reInt = 0; try { sqlStr = ent.QUERY_CONF; reInt = ExecuteCount(query.DB_SERVER_ID.Value, ent.QUERY_CONF); } catch (Exception e) { err.IsError = true; err.Message = e.Message; } return(reInt); } }
public IList <TreeClass> UserGetBylRole(string loginKey, ref ErrorInfo err, string roleIdStr) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } using (DBEntities db = new DBEntities()) { IList <TreeClass> reList = new List <TreeClass>(); if (string.IsNullOrEmpty(roleIdStr)) { return(reList); } string disStr = "." + gu.DistrictId + "."; var allUser = db.fa_user.Where(x => x.IS_LOCKED == 0 && (x.fa_district.ID_PATH.IndexOf(disStr) > -1 || x.fa_district.ID == gu.DistrictId)).OrderBy(x => x.ID).ToList(); IList <int> roleId = new List <int>(); if (!string.IsNullOrEmpty(roleIdStr)) { roleId = roleIdStr.Split(',').Select(x => Convert.ToInt32(x)).ToList(); } var allRoleUser = db.fa_role.Where(x => roleId.Contains(x.ID)).Select(y => y.fa_user.Select(t => t.ID)).ToList(); var userIdArr = new List <int>(); foreach (var t in allRoleUser) { userIdArr = userIdArr.Union(t).ToList(); } allUser = allUser.Where(x => userIdArr.Contains(x.ID)).ToList(); var tmp = allUser.ToList(); foreach (var user in tmp) { reList.Add(new TreeClass { id = user.ID.ToString(), name = string.Format("{0}({1})", user.NAME, user.fa_district.NAME) }); } return(reList); } }