public bool RemoveUser(QDbTran tran, params int[] puidS) { if (puidS == null || puidS.Length < 1) { throw new BCFException("参数异常:(puidS == null || puidS.Length < 1)"); } //删除User // UserM u = new UserM(); u.Where(u.PUID.In(puidS)).Delete(tran); //删除User关联信息 // User_LinkedM ul = new User_LinkedM(); ul.Where(ul.PUID.In(puidS)).Delete(tran); //删除User与Resource // ResourceService.G.RemoveLink(tran, puidS); return(true); }
/// <summary> /// /// </summary> /// <param name="pgCode">代码模式:3301|33%|33__01%</param> /// <param name="incDisabled"></param> /// <param name="incUnVisible"></param> /// <returns></returns> private SQuery GetUsersQuery(string pgCode, bool incDisabled, bool incUnVisible) { UserM u = new UserM(); User_LinkedM ul = new User_LinkedM(); GroupM g = new GroupM(); ul.IncludeAll(false); ul.LK_OBJT_ID.IsInc = true; ul.LK_OBJT_ID.AsName = "PGID"; SQuery SQ = NewSQ(); SQ.From(u) .InnerJoin(ul) .On(u.PUID == ul.PUID).And(ul.LK_OBJT == Group.LK_OBJT) .InnerJoin(g) .On(ul.LK_OBJT_ID == g.PGID) .Where(g.PG_Code.Like(pgCode)); if (incDisabled == false) { SQ.And(u.Is_Disabled != true); } if (incUnVisible == false) { SQ.And(u.Is_Visibled != false); } return(SQ); }
private SQuery GetUsersQuery(bool incDisabled, bool incUnVisible, params int[] pgids) { UserM u = new UserM(); User_LinkedM ul = new User_LinkedM(); ul.IncludeAll(false); ul.LK_OBJT_ID.IsInc = true; ul.LK_OBJT_ID.AsName = "PGID"; SQuery SQ = NewSQ(); SQ.From(u) .InnerJoin(ul) .On(u.PUID == ul.PUID) .Where(ul.LK_OBJT_ID.In(pgids)) .And(ul.LK_OBJT == Group.LK_OBJT); if (incDisabled == false) { SQ.And(u.Is_Disabled != true); } if (incUnVisible == false) { SQ.And(u.Is_Visibled != false); } SQ.OrderBy(u.CN_Name); return(SQ); }
public bool ClearUsers() { string[] unClearPUIDs = new string[] { "0", "1" }; //清理,与功能间的关联 // Resource_LinkedM rl = new Resource_LinkedM(); rl.Where(rl.LK_OBJT == User.LK_OBJT) .And(rl.LK_OBJT_ID.Unin(unClearPUIDs)) .Delete(); //清理,与组之音的关联 // User_LinkedM ul = new User_LinkedM(); ul.Where(ul.PUID.Unin(unClearPUIDs)).Delete(); //清理用户数据 // UserM u = new UserM(); u.Where(u.PUID.Unin(unClearPUIDs)).Delete(); return(true); }
/// <summary> /// 获取用户相关的组 /// </summary> /// <param name="puid">用户PUID</param> /// <param name="p_pgids">目标组的P_PGID组</param> /// <returns></returns> protected List <Group> DoGetGroupsInUser(int puid, params int[] p_pgids) { GroupM g = new GroupM(); SQuery SQ = new SQuery(); User_LinkedM ul = new User_LinkedM(); ul.IncludeAll(false); SQ.From(g) .InnerJoin(ul).On(g.PGID == ul.LK_OBJT_ID).And(ul.LK_OBJT == Group.LK_OBJT); SQ.Where(QCondition.TRUE); if (p_pgids.Length > 0) { SQ.And(g.P_PGID.In(p_pgids)); } return (SQ.And(ul.PUID == puid) .And(g.Is_Disabled != true) .And(g.Is_Visibled != false) .OrderBy(g.Order_Index, OrderType.ASC) .Select <Group>()); }
/// <summary> /// /// </summary> /// <param name="defines"></param> /// <returns></returns> protected bool DoClearGroups(params int[] defines) { if (defines.Length < 1) { throw new BCFException("defines 参数不能为空"); } GroupM g = new GroupM(); Resource_LinkedM rl = new Resource_LinkedM(); User_LinkedM ul = new User_LinkedM(); QView pgidS = g.Where(g.R_PGID.In(defines)).SubSelect(g.PGID); bool temp = true; //清理,与功能间的关联 // temp = rl.Where(rl.LK_OBJT_ID.In(pgidS)) .And(rl.LK_OBJT == Group.LK_OBJT) .Delete() && temp; //清理,与用户之间的关联 // temp = ul.Where(ul.LK_OBJT_ID.In(pgidS)) .And(ul.LK_OBJT == Group.LK_OBJT) .Delete() && temp; //清空组 // temp = g.Where(g.R_PGID.In(defines)).Delete() && temp; return(temp); }
/// <summary> /// 删除组与用户的关联 /// </summary> public bool RemoveLink(QDbTran tran, params int[] pgidS) { User_LinkedM ul = new User_LinkedM(); return(ul.Where(ul.LK_OBJT == Group.LK_OBJT) .And(ul.LK_OBJT_ID.In(pgidS)) .Delete(tran)); }
public bool RemoveLink(QView lkidView, QDbTran tran) { User_LinkedM ul = new User_LinkedM(); return(ul.Where(ul.LK_OBJT == Group.LK_OBJT) .And(ul.LK_OBJT_ID.In(lkidView)) .Delete(tran)); }
/// <summary> /// 是否在一个组里 /// </summary> /// <param name="puid">用户ID</param> /// <param name="pgid">组ID</param> /// <returns>是否有加入</returns> public static bool IsInGroup(int puid, int pgid) { User_LinkedM ul = new User_LinkedM(); return (ul.NoLock() .Where(ul.PUID == puid) .And(ul.LK_OBJT == Group.LK_OBJT) .And(ul.LK_OBJT_ID == pgid) .Exists()); }
/// <summary> /// 是否存有组内用户 /// </summary> /// <param name="pgid">组PGID</param> /// <param name="incDisabled">是否包括禁用的</param> /// <returns></returns> public bool ExistsUsers(int pgid, bool incDisabled) { User_LinkedM ul = new User_LinkedM(); UserM u = new UserM(); SQuery SQ = new SQuery(); return(SQ.From(ul.NoLock()) .InnerJoin(u.NoLock()) .On(ul.PUID == u.PUID) .Where(ul.LK_OBJT == Group.LK_OBJT) .And(ul.LK_OBJT_ID == pgid) .Exists()); }
/// <summary> /// 清除与某一类组之间的关联 /// </summary> /// <param name="puid">用户ID</param> /// <param name="groupDefine">组定义</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public static bool ClearGroupLinked(int puid, int groupDefine, QDbTran tran) { GroupM g = new GroupM(); QView pgidS = g.Where(g.R_PGID == groupDefine).SubSelect(g.PGID); User_LinkedM ul = new User_LinkedM(); //清理,与用户之间的关联 // return(ul.Where(ul.LK_OBJT_ID.In(pgidS)) .And(ul.LK_OBJT == Group.LK_OBJT) .And(ul.PUID == puid) .Delete(tran)); }
/// <summary> /// 脱离与一个组的关联 /// </summary> /// <param name="puid">用户ID</param> /// <param name="pgid">组ID</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public static bool LeaveGroup(int puid, int pgid, QDbTran tran) { if (pgid == 0 || puid == 0) { return(false); } User_LinkedM ul = new User_LinkedM(); return(ul.Where(ul.LK_OBJT == Group.LK_OBJT) .And(ul.LK_OBJT_ID == pgid) .And(ul.PUID == puid) .Delete(tran)); }
/// <summary> /// 移除与用户之间的关联 /// </summary> /// <param name="tran">事务对象</param> /// <param name="puidS">用户PUID组</param> /// <returns></returns> public bool RemoveUserLink(QDbTran tran, params string[] puidS) { if (this.PGID == 0 || puidS.Length == 0) { return(false); } User_LinkedM ul = new User_LinkedM(); return(ul.Where(ul.LK_OBJT == Group.LK_OBJT) .And(ul.LK_OBJT_ID == this.PGID) .And(ul.PUID.In(puidS)) .Delete(tran)); }
/// <summary> /// 获取用户所在组的连接 /// </summary> /// <param name="puid"></param> /// <param name="tran"></param> /// <returns></returns> public List <Resource_Linked> GetInGroupOfUserLinked(int puid, QDbTran tran) { if (puid < 1) { return(null); } Resource_LinkedM rl = new Resource_LinkedM(); User_LinkedM ul = new User_LinkedM(); QView ulv = ul.Where(ul.PUID == puid).And(ul.LK_OBJT == Group.LK_OBJT).SubSelect().As("T0"); SQuery sq = new SQuery(); return (sq.From(ulv) .InnerJoin(rl).On(ul.LK_OBJT_ID == rl.LK_OBJT_ID) .And(rl.LK_OBJT == Group.LK_OBJT) .Select <Resource_Linked>(rl.RSID, rl.LK_OBJT_ID, rl.LK_OBJT, rl.LK_Operate, rl.P_Express)); }
/// <summary> /// 加入一个组 /// </summary> /// <param name="puid">用户ID</param> /// <param name="pgid">组ID</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public static bool JoinToGroup(int puid, int pgid, QDbTran tran) { if (pgid == 0 || puid == 0) { return(false); } User_LinkedM ul = new User_LinkedM(); ul.PUID.Value = puid; ul.LK_OBJT.Value = Group.LK_OBJT; ul.LK_OBJT_ID.Value = pgid; ul.LK_Operate.Value = "+"; if (ul.Where(ul.PUID == puid).And(ul.LK_OBJT == Group.LK_OBJT).And(ul.LK_OBJT_ID == pgid).Exists(tran)) { return(false); } else { return(ul.Insert(tran)); } }
/// <summary> /// /// </summary> /// <param name="puid"></param> /// <param name="incDisabled"></param> /// <param name="forView"></param> /// <returns></returns> public SQuery GetInGroupsSQ(int puid, bool incDisabled, bool forView) { GroupM g = new GroupM(); User_LinkedM ul = new User_LinkedM(); SQuery SQ = new SQuery(); ul.IncludeAll(false); if (forView == true) { g.IncludeAll(false); g.PGID.IsInc = true; } SQ.From(g.NoLock()) .InnerJoin(ul).On(g.PGID == ul.LK_OBJT_ID) .Where(ul.PUID == puid); if (incDisabled == false) { SQ.And(g.Is_Disabled != 1); } if (DEFINE_VALUE > 0) { SQ.And(g.R_PGID == DEFINE_VALUE.ToString()); } if (forView == false) { SQ.OrderBy(g.Order_Index); } return(SQ); }
/// <summary> /// 登录 /// </summary> /// <param name="userId">用户ID</param> /// <param name="passWd">密码</param> /// <param name="groupId">限定的组ID</param> /// <returns>是否成功</returns> public bool Login(string userId, string passWd, int groupId) { if (userId == null || passWd == null) { throw new BCFException("!!!(userId == null || passWd == null)"); } if (userId.Length < 1 || passWd.Length < 1) { throw new BCFException("!!!(userId.Length < 1 || passWd.Length < 1)"); } string secretPassWd = User.EncryptPassWd(userId, passWd); //------------------------------- UserM u = new UserM(); User_LinkedM ul = new User_LinkedM(); ul.IncludeAll(false); //------------------------------------- SQuery SQ = NewSQ(); SQ.From(u); if (groupId > 0) { SQ.InnerJoin(ul) .On(ul.PUID == u.PUID) .And(ul.LK_OBJT == Group.LK_OBJT) .And(ul.LK_OBJT_ID == groupId); } SQ.Where(u.User_Id == userId) .And(u.Pass_Wd == secretPassWd) .And(u.Is_Disabled == false); User user = SQ.SelectOne <User>(); if (user.User_Id == null) { return(false); } else { if (_CurrentUser.Bind(user) == false) { return(false); } if (groupId > 0) { if (_CurrentGroup.Bind(GroupService.G.GetGroup(groupId)) == false) { return(false); } } //------------------------->>成功登录后,执行插件调用 // PluginApply.OnLogin(); //-------------------------<< return(true); } }