Exemplo n.º 1
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());
        }
Exemplo n.º 2
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);
            }
        }