Пример #1
0
        public IQueryable <UserEntity> GetList(Pagination pagination, string keyword)
        {
            var query = service.IQueryable();

            if (!string.IsNullOrEmpty(keyword))
            {
                query = query.Where(it =>
                                    it.UserName.Contains(keyword) || it.RealName.Contains(keyword) || it.Contract.Contains(keyword));
            }

            return(query.PaginationBy(pagination));
        }
Пример #2
0
        public List <DbBackupEntity> GetList(string queryJson)
        {
            var query = repoService.IQueryable();

            if (queryJson != null)
            {
                var queryParam = JsonConvert.DeserializeObject <QueryJson>(queryJson);
                if (!string.IsNullOrEmpty(queryParam.Keyword) && !string.IsNullOrEmpty(queryParam.Codition))
                {
                    string condition = queryParam.Codition;
                    string keyword   = queryParam.Keyword;
                    switch (condition)
                    {
                    case "DbName":
                        query = query.Where(it => it.DbName.Contains(keyword));
                        break;

                    case "FileName":
                        query = query.Where(it => it.FileName.Contains(keyword));
                        break;
                    }
                }
            }
            return(query.OrderByDescending(t => t.BackupTime).ToList());
        }
Пример #3
0
        public IActionResult Index()
        {
            var entities = repoService.IQueryable().ToList();
            var data     = entities.Select(it => new RoleModel().FromEntity(it)).ToList();

            return(Success(data));
        }
Пример #4
0
        private object entityToModel(ApprovalInstanceEntity it)
        {
            var ids           = it.InfoInstances.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
            var infoInstances = infoInstanceService.IQueryable().Where(it => ids.Contains(it.Id)).ToList();

            return(new
            {
                id = it.Id,
                desc = it.Description,
                prototype = it.AppprovalTable.Name,
                values = infoInstances.Select(info =>
                {
                    var infoClass = infoClassService.FindOne(info.PrototypeId) !;
                    return new
                    {
                        id = info.Id,
                        prototypeId = infoClass.Id,
                        name = infoClass.Name,
                        type = infoClass.InputType,
                        value = info.Value,
                        status = info.Status
                    };
                }),
                creator = it.CreatorUser?.RealName,
                modifer = it.LastModifyUser?.RealName,
                state = it.State
            });
        public IActionResult Index()
        {
            var entities = repoService.IQueryable().ToList();
            var datas    = entities.Where(it => it.Parent == null).Select(it => new OrganizeModel().FromEntity(it))
                           .ToList();

            return(Success(datas));
        }
Пример #6
0
        public IActionResult CheckLogin([FromBody] LoginParam param)
        {
            try
            {
                string username     = param.Username ?? throwStringAssert("用户名不能为空");
                string password     = param.Password ?? throwStringAssert("密码不能为空");
                string code         = param.Code ?? throwStringAssert("验证码不能为空");
                var    vcodeSession = Request.Cookies["vcode-session"];
                if (string.IsNullOrEmpty(vcodeSession))
                {
                    return(Json(new { success = false, message = "验证码已失效" }));
                }

                var state = verifyCodeService.VerifyCode(vcodeSession, code);
                switch (state)
                {
                case VerifyCodeService.State.WrongCode: return(Json(new { success = false, message = "验证码错误" }));

                case VerifyCodeService.State.Expired: return(Json(new { success = false, message = "验证码已过期" }));

                case VerifyCodeService.State.Invalid: return(Json(new { success = false, message = "验证信息错误" }));
                }

                UserEntity userEntity = userService.CheckPassword(username, password);

                var orgs  = userOrganizeService.IQueryable().Where(it => it.User.Id == userEntity.Id).ToList();
                var roles = roleService
                            .IQueryable().ToList();

                var myroles = roles
                              .Where(it => orgs.Any(org =>
                                                    it.OrganizeCategoryId == org.Organize.CategoryId && it.OrganizeDutyLevel == org.DutyLevel))
                              .ToList();

                var permissions = new HashSet <string>();
                foreach (var roleEntity in myroles)
                {
                    var menus = roleEntity.AvailableMenus.Split(",", StringSplitOptions.RemoveEmptyEntries);
                    foreach (var menu in menus)
                    {
                        permissions.Add(menu);
                    }
                }

                logger.WriteDbLog(DbLogType.Login.ToString(), true, "登录成功");

                return(Json(new
                            { success = true, data = LoginExtension.CreateJwtToken(userEntity, permissions.ToArray()) }));
            }
            catch (Exception ex)
            {
                var msg = "登录失败," + ex.Message;
                logger.WriteDbLog(DbLogType.Login.ToString(), false, msg);

                return(Json(new { success = false, message = msg }));
            }
        }
 public IActionResult Index()
 {
     return(Success(repoService.IQueryable().ToList().Select(it => new UserOrganizeModel
     {
         Id = it.Id,
         UserId = it.User.Id,
         OrganizeId = it.Organize.Id,
         DutyLevel = it.DutyLevel
     })));
 }
Пример #8
0
        private List <ApprovalInstanceEntity> findAll(Expression <Func <ApprovalInstanceEntity, bool> >?predict = null)
        {
            var user = GetUserInformation();
            var data = repoService.IQueryable();

            if (predict != null)
            {
                data = data.Where(predict);
            }

            return(data.ToList());
        }
Пример #9
0
        public IActionResult ChangePasswordSuper(string username, string pwd)
        {
            UserEntity?userEntity = userService.IQueryable().FirstOrDefault(t => t.UserName == username);

            if (userEntity == null)
            {
                throw new Exception("账户不存在,请重新输入");
            }

            userEntity.Password = userService2.HashPassword(pwd);
            userService.Update(userEntity);
            return(Success());
        }
Пример #10
0
        public IActionResult Index()
        {
            var user = GetUserInformation();
            var data = repoService
                       .IQueryable()
                       .Where(it => it.User.Id == user.Id)
                       .ToList().Select(it =>
            {
                var model       = new InfoInstanceModel().FromEntity(it);
                model.InfoClass = new InfoClassModel().FromEntity(infoClassService.FindOne(it.PrototypeId) !);
                return(model);
            });

            return(Success(data));
        }
        public IActionResult Update([FromBody] ApprovalTableModel approvalTable)
        {
            using var trans = repoService.DbContext.Database.BeginTransaction();

            var orgIds = approvalTable.OwnerOrganizes ?? new List <int>();
            var orgs   = organizeService.IQueryable().Where(it => orgIds.Contains(it.Id)).ToList();

            if (orgs.Count != orgIds.Count)
            {
                throw new Exception("组织不存在!");
            }
            var infoClassIds = approvalTable.InfoClasses ?? new List <int>();
            var infoClasses  = infoClassService.IQueryable().Where(it => infoClassIds.Contains(it.Id)).ToList();

            if (infoClassIds.Count != infoClasses.Count)
            {
                throw new Exception("类型不存在!");
            }
            var entity = approvalTable.ToEntity();

            repoService.Update(entity);
            tableInfoClassService.Delete(it => it.ApprovalTable.Id == entity.Id);
            tableOrganizeService.Delete(it => it.ApprovalTable.Id == entity.Id);
            foreach (var infoClassEntity in infoClasses)
            {
                tableInfoClassService.Update(new ApprovalTableInfoClassEntity
                {
                    ApprovalTable = entity,
                    InfoClass     = infoClassEntity
                });
            }

            foreach (var organizeEntity in orgs)
            {
                tableOrganizeService.Update(new ApprovalTableOrganizeEntity
                {
                    ApprovalTable = entity,
                    Organize      = organizeEntity
                });
            }

            trans.Commit();
            return(Success());
        }
Пример #12
0
        public List <LogEntity> GetList(Pagination pagination, string queryJson)
        {
            var query = repoService.IQueryable();

            if (queryJson != null)
            {
                var queryParam = JsonConvert.DeserializeObject <QueryJson>(queryJson);
                if (!string.IsNullOrEmpty(queryParam.Keyword))
                {
                    string keyword = queryParam.Keyword;
                    query = query.Where(it => it.UserName.Contains(keyword));
                }
                if (!string.IsNullOrEmpty(queryParam.TimeType))
                {
                    string   timeType  = queryParam.TimeType;
                    DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                    DateTime endTime   = startTime.AddDays(1);
                    switch (timeType)
                    {
                    case "1":
                        break;

                    case "2":
                        startTime = DateTime.Now.AddDays(-7);
                        break;

                    case "3":
                        startTime = DateTime.Now.AddMonths(-1);
                        break;

                    case "4":
                        startTime = DateTime.Now.AddMonths(-3);
                        break;

                    default:
                        break;
                    }
                    query = query.Where(it => it.Date >= startTime && it.Date <= endTime);
                }
            }
            return(query.PaginationBy(pagination).ToList());
        }
        public IActionResult Index()
        {
            var data = repoService.IQueryable().Select(it => new InfoClassModel().FromEntity(it));

            return(Success(data));
        }
        public IActionResult Index()
        {
            var data = repoService.IQueryable().ToList().Select(it => new ApprovalTableModel().FromEntity(it));

            return(Success(data));
        }
Пример #15
0
        public IActionResult Index()
        {
            var datas = repoService.IQueryable().Select(it => new OrganizeCategoryModel().FromEntity(it)).ToList();

            return(Success(datas));
        }