private SQuery _SQ_GetInGroupResources(params int[] pgidS) { if (pgidS.Length == 0) { throw new BCFException("GetInGroupResources(pgdiS)::@pgidS长度必须大于0"); } Resource_LinkedM rl = new Resource_LinkedM(); rl.IncludeAll(false); rl.LK_OBJT.IsInc = true; rl.P_Express.IsInc = true; ResourceExView rv = new ResourceExView(false); SQuery SQ = NewSQ(); SQ.From(rv) .InnerJoin(rl) .On(rv.RSID == rl.RSID) .Where(rl.LK_OBJT == Group.LK_OBJT) .And(rl.LK_OBJT_ID.In(pgidS)) .And(rv.Is_Disabled == false) .And(rv.PKG_Is_Disabled == false); this._Sort(SQ, rv); return(SQ); }
/// <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> /// <param name="rsid"></param> /// <param name="puid"></param> /// <param name="exp"></param> /// <param name="tran"></param> /// <returns></returns> public static bool JoinToUser(int rsid, int puid, PExpress exp, QDbTran tran) { if (rsid == 0 || rsid == 0) { return(false); } Resource_LinkedM rl = new Resource_LinkedM(); rl.RSID.Value = rsid; rl.LK_OBJT.Value = User.LK_OBJT; rl.LK_OBJT_ID.Value = puid; rl.LK_Operate.Value = "+"; rl.P_Express.Value = (byte)exp; if (rl.Where(rl.RSID == rsid) .And(rl.LK_OBJT == User.LK_OBJT) .And(rl.LK_OBJT_ID == puid).NoLock().Exists()) { return(false); } else { return(rl.Insert(tran)); } }
public DataTable GetInLinked(int rsid) { if (rsid < 1) { return(null); } Resource_LinkedM rl = new Resource_LinkedM(); GroupM g = new GroupM(); UserM u = new UserM(); g.IncludeAll(false); g.CN_Name.As("LK_OBJT_Name").IsInc = true; u.IncludeAll(false); u.CN_Name.As("LK_OBJT_Name").IsInc = true; DataTable dt1 = rl.InnerJoin(u).On(rl.LK_OBJT_ID == u.PUID) .And(rl.RSID == rsid).And(rl.LK_OBJT == User.LK_OBJT) .Select(); rl = new Resource_LinkedM(); DataTable dt2 = rl.InnerJoin(g).On(rl.LK_OBJT_ID == g.PGID) .And(rl.RSID == rsid) .And(rl.LK_OBJT == Group.LK_OBJT) .And(g.R_PGID != Package.DEFINE) .Select(); foreach (DataRow row in dt2.Rows) { dt1.Rows.Add(row.ItemArray); } return(dt1); }
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); }
public bool RemoveLink(QDbTran tran, string rsid, int lk_objt, int lk_objt_id) { Resource_LinkedM rl = new Resource_LinkedM(); return(rl.Where(rl.RSID == rsid) .And(rl.LK_OBJT == lk_objt) .And(rl.LK_OBJT_ID == lk_objt_id).Delete(tran)); }
/// <summary> /// 是否存有关联的资源 /// </summary> /// <param name="pgid">组PGID</param> /// <returns></returns> public bool ExistsResources(int pgid) { Resource_LinkedM rl = new Resource_LinkedM(); return(rl.NoLock() .Where(rl.LK_OBJT == Group.LK_OBJT) .And(rl.LK_OBJT_ID == pgid) .Exists()); }
/// <summary> /// /// </summary> /// <param name="rsid"></param> /// <param name="puid"></param> /// <returns></returns> public static PExpress ExpressOfUser(int rsid, int puid) { if (rsid < 1 || puid < 1) { return(PExpress.Null); } SQuery SQ = BCF_PARAMS.NewSQ(); ResourceExView rv = new ResourceExView(true); Resource_LinkedM rl = new Resource_LinkedM(); //------>>找出属于用户所在组(部门,角色) QView tempView = GroupService.G.GetInGroupsSQ(puid, false, true).SubSelect().As("A"); //-------<< //------>>找出属于用户个人所有的RSID tempView = SQ.From(rl) .Where(rl.RSID == rsid) .BeginAnd() .Begin(rl.LK_OBJT == User.LK_OBJT) .And(rl.LK_OBJT_ID == puid) .End() .BeginOr(rl.LK_OBJT == Group.LK_OBJT) .And(rl.LK_OBJT_ID.In(tempView)) .End() .End() .SubSelect(rl.RSID, rl.P_Express).As(rl.AsName); //------<< int pex = SQ.From(rv) .Join(tempView, JoinType.Inner) .On(rv.RSID == rl.RSID) .Where(rv.Is_Disabled != 1).And(rv.PKG_Is_Disabled != true) .SelectValue <int>(rl.P_Express.Max(), 0); //------<< //-------------------------------------------------------------------------- switch (pex) { case 1: return(PExpress.ReadOnly); case 2: return(PExpress.Write); case 4: return(PExpress.Control); default: return(PExpress.Null); } }
/// <summary> /// 获取与Group[@pgid]之间的连接关系 /// </summary> public List <Resource_Linked> GetInGroupLinked(int pgid, QDbTran tran) { if (pgid < 1) { return(null); } Resource_LinkedM rl = new Resource_LinkedM(); return(rl.Where(rl.LK_OBJT == Group.LK_OBJT) .And(rl.LK_OBJT_ID == pgid) .Select <Resource_Linked>()); }
/// <summary> /// 清除与User[@puid]之间的连接关系 /// </summary> public bool ClearInUserLinked(string puid, QDbTran tran) { if (puid == null || puid.Length == 0) { return(false); } Resource_LinkedM rl = new Resource_LinkedM(); return(rl.Where(rl.LK_OBJT == User.LK_OBJT) .And(rl.LK_OBJT_ID == puid) .Delete(tran)); }
/// <summary> /// 清除与Group[@pgid]之间的连接关系 /// </summary> public bool ClearInGroupLinked(string pgid, QDbTran tran) { if (pgid == null || pgid.Length < 1) { return(false); } Resource_LinkedM rl = new Resource_LinkedM(); return(rl.Where(rl.LK_OBJT == Group.LK_OBJT) .And(rl.LK_OBJT_ID == pgid) .Delete(tran)); }
/// <summary> /// /// </summary> /// <param name="rsid"></param> /// <param name="pgid"></param> /// <param name="tran"></param> /// <returns></returns> public static bool LeaveGroup(int rsid, int pgid, QDbTran tran) { if (pgid == 0 || rsid == 0) { return(false); } Resource_LinkedM rl = new Resource_LinkedM(); return (rl.Where(rl.LK_OBJT == Group.LK_OBJT) .And(rl.LK_OBJT_ID == pgid) .And(rl.RSID == rsid).Delete(tran)); }
/// <summary> /// 移除与资源之间的关联 /// </summary> /// <param name="tran">事务对象</param> /// <param name="rsidS">资源RSID组</param> /// <returns></returns> public bool RemoveResourceLink(QDbTran tran, params int[] rsidS) { if (this.PGID == 0 || rsidS.Length == 0) { return(false); } Resource_LinkedM rl = new Resource_LinkedM(); return(rl.Where(rl.LK_OBJT == Group.LK_OBJT) .And(rl.LK_OBJT_ID == this.PGID) .And(rl.RSID.In(rsidS)) .Delete(tran)); }
/// <summary> /// /// </summary> /// <param name="rsid"></param> /// <param name="puid"></param> /// <param name="tran"></param> /// <returns></returns> public static bool LeaveUser(int rsid, int puid, QDbTran tran) { if (rsid == 0 || puid == 0) { return(false); } Resource_LinkedM rl = new Resource_LinkedM(); return (rl.Where(rl.LK_OBJT == User.LK_OBJT) .And(rl.LK_OBJT_ID == puid) .And(rl.RSID == rsid) .Delete(tran)); }
/// <summary> /// 移除资源,同时移除资源与其它对象的关联信息 /// </summary> /// <param name="rsids">资源ID组</param> /// <param name="tran">事务</param> public bool RemoveResource(QDbTran tran, params int[] rsids) { Resource_LinkedM rl = new Resource_LinkedM(); ResourceM r = new ResourceM(); //删除关联表数据 // bool temp = true; temp = temp && rl.Where(rl.RSID.In(rsids)).Delete(tran); //删除资源表数据 temp = temp && r.Where(r.RSID.In(rsids)).Delete(tran); return(temp); }
/// <summary> /// 获取指定包里的资源 /// </summary> /// <param name="packageIds">包ID组</param> /// <param name="incDisabled">是否包括忆禁用的部分</param> /// <returns>资源列表</returns> public List <Resource> GetResources(bool incDisabled, params int[] packageIds) { ResourceM r = new ResourceM(); Resource_LinkedM rl = new Resource_LinkedM(); rl.IncludeAll(false); SQuery SQ = NewSQ(); SQ.From(r) .InnerJoin(rl) .On(rl.RSID == r.RSID) .Where(r.RSID != "0") .And(rl.LK_OBJT == Package.LK_OBJT) .And(rl.LK_OBJT_ID.In(packageIds)); if (incDisabled == false) { SQ.And(r.Is_Disabled == false); } if (_OrderColumnName == null) { SQ.OrderBy(r.Order_Index); } else { if (r.Contains(_OrderColumnName)) { SQ.OrderBy(r[_OrderColumnName]); } else if (rl.Contains(_OrderColumnName)) { SQ.OrderBy(r[_OrderColumnName]); } else if (_OrderColumnName.IndexOf(",") > 0) { SQ.OrderBy(r.CN_Name.Exp(_OrderColumnName)); } else { SQ.OrderBy(r.Order_Index); } } return(SQ.Select <Resource>()); }
private SQuery _SQ_GetInUserResources(int puid, params int[] packageIds) { if (puid <= 0) { throw new BCFException("GetInUserResources(puid)::@puid 必须大于0"); } ResourceExView rv = new ResourceExView(false); Resource_LinkedM rl = new Resource_LinkedM(); SQuery SQ = NewSQ(); //------>>找出属于用户所在组(部门,角色) QView tempView = GroupService.G.GetInGroupsSQ(puid, false, true).SubSelect(); //-------<< //------>>找出属于用户个人所有的RSID tempView = SQ.From(rl) .BeginWhere(rl.LK_OBJT == User.LK_OBJT) .And(rl.LK_OBJT_ID == puid) .End() .BeginOr(rl.LK_OBJT == Group.LK_OBJT) .And(rl.LK_OBJT_ID.In(tempView)) .End() .SubSelect(rl.RSID, rl.LK_OBJT, rl.P_Express).As("RL"); //------<< SQ.From(rv) .Join(tempView, JoinType.Inner) .On(rv.RSID == tempView.Column(rl.RSID)) .Where(rv.Is_Disabled != 1) .And(rv.PKG_Is_Disabled == false); if (packageIds.Length > 0) { SQ.And(rv.PGID.In(packageIds)); } SQ.Distinct(); this._Sort(SQ, rv); return(SQ); }
/// <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)); }
internal bool RemoveLink(QView lkidView, QDbTran tran) { Resource_LinkedM rl = new Resource_LinkedM(); return(rl.Where(rl.LK_OBJT_ID.In(lkidView)).Delete(tran)); }
/// <summary> /// 移除与"Group"或"User"的关联 /// </summary> /// <param name="lkidS">关联对象的ID组(组ID或用户ID)</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public bool RemoveLink(QDbTran tran, params int[] lkidS) { Resource_LinkedM rl = new Resource_LinkedM(); return(rl.Where(rl.LK_OBJT_ID.In(lkidS)).Delete(tran)); }