Пример #1
0
        /// <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);
            }
        }
Пример #2
0
        /// <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>());
        }
Пример #3
0
        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);
        }
Пример #4
0
        /// <summary>
        /// 获取组
        /// </summary>
        /// <param name="joinTable"></param>
        /// <param name="incDisabled"></param>
        /// <param name="incUnVisible"></param>
        /// <param name="p_pgids"></param>
        /// <returns></returns>
        protected DataTable DoGetGroups(QTable joinTable, bool incDisabled, bool incUnVisible, params int[] p_pgids)
        {
            if (p_pgids == null || p_pgids.Length < 1)
            {
                return(null);
            }

            //-------------------------------------
            GroupM g  = new GroupM();
            SQuery SQ = new SQuery();

            SQ.From(g.NoLock());

            if (joinTable != null)
            {
                SQ.InnerJoin(joinTable.NoLock()).On(g.PGID == joinTable["PGID"]);
            }

            SQ.Where(g.P_PGID.In(p_pgids));

            if (incDisabled == false)
            {
                SQ.And(g.Is_Disabled != 1);
            }

            if (incUnVisible == false)
            {
                SQ.And(g.Is_Visibled != 0);
            }

            return(SQ.OrderBy(g.Order_Index)
                   .Select());
        }
Пример #5
0
        /// <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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        /// <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());
        }
Пример #9
0
        /// <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>());
        }
Пример #10
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="isOnlyLink">是否办需要关联信息</param>
        public ResourceExView(bool isOnlyLink)
        {
            this.IsOnlyLink = isOnlyLink;

            PKG.CN_Name.AsName     = "PG_CN_Name";
            PKG.EN_Name.AsName     = "PG_EN_Name";
            PKG.Order_Index.AsName = "PG_Order_Index";
            PKG.Is_Disabled.AsName = "PG_Is_Disabled";

            PKG.IncludeAll(false);

            PKG.PGID.IsInc        = true;
            PKG.Is_Disabled.IsInc = true;

            if (IsOnlyLink == false)
            {
                PKG.CN_Name.IsInc     = true;
                PKG.EN_Name.IsInc     = true;
                PKG.Order_Index.IsInc = true;
            }
            else //[IsOnlyLink == true]
            {
                SRC.IncludeAll(false);
                SRC.Is_Disabled.IsInc = true;
                SRC.RSID.IsInc        = true;
            }

            __link.IncludeAll(false);

            SQuery SQ = new SQuery();

            this.Code =
                SQ.From(SRC)
                .InnerJoin(__link).On(SRC.RSID == __link.RSID)
                .InnerJoin(PKG).On(PKG.PGID == __link.LK_OBJT_ID)
                .Where(PKG.R_PGID == Package.DEFINE)
                .SubSelect().Code;

            this.As("RV");

            //视图建好后,重新调整名称
            //
            InnerColumn(PKG.CN_Name, "PG_CN_Name");
            InnerColumn(PKG.EN_Name, "PG_EN_Name");
            InnerColumn(PKG.Order_Index, "PG_Order_Index");
            InnerColumn(PKG.Is_Disabled, "PG_Is_Disabled");
        }
Пример #11
0
        /// <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));
        }
Пример #12
0
        /// <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);
        }
Пример #13
0
        /// <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);
            }
        }