Example #1
0
        /// <summary>
        /// 使用工号扫描
        /// </summary>
        /// <param name="UserCode"></param>
        /// <returns></returns>
        public AdminEntity Scan(string UserCode)
        {
            AdminEntity entity = new AdminEntity();

            entity.IncludeAll();
            entity.Exclude(a => a.PassWord);
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And <AdminEntity>(a => a.CompanyID == CompanyID)
            .And(item => item.UserCode == UserCode)
            ;
            entity = this.Admin.GetSingle(entity);
            if (entity != null)
            {
                SysRoleProvider RoleProvider   = new SysRoleProvider(this.CompanyID);
                DepartProvider  DepartProvider = new DepartProvider(this.CompanyID);

                if (entity.RoleNum.IsNotEmpty())
                {
                    SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(entity.RoleNum);
                    entity.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty;
                }
                if (entity.DepartNum.IsNotEmpty())
                {
                    SysDepartEntity DepartEntity = DepartProvider.GetSingle(entity.DepartNum);
                    entity.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty;
                }
            }
            return(entity);
        }
Example #2
0
        /// <summary>
        /// 查询用户管理员分页
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <AdminEntity> GetList(AdminEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            entity.Exclude(a => a.PassWord);
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
            entity.And(a => a.CompanyID == entity.CompanyID);
            entity.And(item => item.UserCode != "DA_0000");

            if (!entity.UserName.IsEmpty())
            {
                entity.And("UserName", ECondition.Like, "%" + entity.UserName + "%");
            }
            if (!entity.UserCode.IsEmpty())
            {
                entity.And("UserCode", ECondition.Like, "%" + entity.UserCode + "%");
            }

            if (!entity.RoleNum.IsEmpty())
            {
                entity.And(a => a.RoleNum == entity.RoleNum);
            }

            if (!entity.DepartNum.IsEmpty())
            {
                DepartProvider         provider   = new DepartProvider(this.CompanyID);
                List <SysDepartEntity> listDepart = provider.GetChildList(entity.DepartNum);
                string[] items = null;
                if (!listDepart.IsNullOrEmpty())
                {
                    items = listDepart.Select(item => item.SnNum).ToArray();
                    entity.And("DepartNum", ECondition.In, items);
                }
            }

            int rowCount = 0;
            List <AdminEntity> listResult = this.Admin.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;

            if (!listResult.IsNullOrEmpty())
            {
                SysRoleProvider RoleProvider   = new SysRoleProvider(this.CompanyID);
                DepartProvider  DepartProvider = new DepartProvider(this.CompanyID);
                foreach (AdminEntity item in listResult)
                {
                    if (item.RoleNum.IsNotEmpty())
                    {
                        SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(item.RoleNum);
                        item.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty;
                    }
                    if (item.DepartNum.IsNotEmpty())
                    {
                        SysDepartEntity DepartEntity = DepartProvider.GetSingle(item.DepartNum);
                        item.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty;
                    }
                }
            }
            return(listResult);
        }
Example #3
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        /// <returns></returns>
        public AdminEntity Login(string userName, string passWord)
        {
            AdminEntity entity = new AdminEntity();

            entity.IncludeAll();
            entity.Exclude(a => a.ParentName);
            entity.Where(a => a.UserName == userName)
            .And(a => a.PassWord == passWord)
            .And <AdminEntity>(a => a.CompanyID == CompanyID)
            .And(a => a.IsDelete == (int)EIsDelete.NotDelete)
            ;

            entity = this.Admin.GetSingle(entity);
            if (entity != null)
            {
                SysRoleProvider RoleProvider   = new SysRoleProvider(this.CompanyID);
                DepartProvider  DepartProvider = new DepartProvider(this.CompanyID);

                if (entity.RoleNum.IsNotEmpty())
                {
                    SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(entity.RoleNum);
                    entity.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty;
                }
                if (entity.DepartNum.IsNotEmpty())
                {
                    SysDepartEntity DepartEntity = DepartProvider.GetSingle(entity.DepartNum);
                    entity.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty;
                }
                Task.Factory.StartNew(() =>
                {
                    AdminEntity admin = new AdminEntity();
                    admin.LoginCount  = entity.LoginCount + 1;
                    admin.IncludeLoginCount(true);
                    admin.Where(a => a.UserNum == entity.UserNum).And(item => item.CompanyID == this.CompanyID);
                    this.Admin.Update(admin);
                });
            }
            return(entity);
        }