Exemplo n.º 1
0
        public HttpResponseMessage TaskList(string Taskname="", int page=1, int pageSize=10, EnumTaskSearchOrderBy orderByAll = EnumTaskSearchOrderBy .OrderById, bool isDes = true)
        {
            //验证是否有非法字符
            Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");

            if (!string.IsNullOrEmpty(Taskname))
            {
                var m = reg.IsMatch(Taskname);
                if (!m)
                {
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "搜索输入存在非法字符!"));
                }
            }
            var taskcondition = new TaskSearchCondition
            {
                OrderBy =orderByAll,
                Taskname = Taskname,
                Page = page,
                PageCount = pageSize,
                IsDescending =isDes 

            };
            try
            {

                var taskList = _taskService.GetTasksByCondition(taskcondition).Select(p => new
                {
                    Taskname = p.Taskname,
                    Name = p.TaskType.Name,
                    Endtime = p.Endtime,
                    Adduser = p.Adduser,
                    Id = p.Id
                }).ToList().Select(p => new
                {
                    Taskname = p.Taskname,
                    Name = p.Name,
                    Endtime = p.Endtime.ToShortDateString(),
                    //  Adduser = _brokerService.GetBrokerByUserId(p.Adduser).Brokername,
                    Adduser = _userservice.GetUserById(p.Adduser) == null ? p.Adduser.ToString() : _userservice.GetUserById(p.Adduser).UserName,
                    Id = p.Id
                }).ToList();
                var taskCount = _taskService.GetTaskCount(taskcondition);
                if (taskCount > 0)
                {
                    return PageHelper.toJson(new { list = taskList, totalCount = taskCount, condition = taskcondition });
                }
                else
                {
                    return PageHelper.toJson(PageHelper.ReturnValue(true, "不存在数据!"));
                }
            }
            catch {
                return PageHelper.toJson(PageHelper.ReturnValue(false , "出现数据错误!"));
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage TaskList(string Taskname = "", int page = 1, int pageSize = 10, EnumTaskSearchOrderBy orderByAll = EnumTaskSearchOrderBy.OrderById, bool isDes = true)
        {
            //验证是否有非法字符
            Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");

            if (!string.IsNullOrEmpty(Taskname))
            {
                var m = reg.IsMatch(Taskname);
                if (!m)
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "搜索输入存在非法字符!")));
                }
            }
            var taskcondition = new TaskSearchCondition
            {
                OrderBy      = orderByAll,
                Taskname     = Taskname,
                Page         = page,
                PageCount    = pageSize,
                IsDescending = isDes
            };

            try
            {
                var taskList = _taskService.GetTasksByCondition(taskcondition).Select(p => new
                {
                    Taskname = p.Taskname,
                    Name     = p.TaskType.Name,
                    Endtime  = p.Endtime,
                    Adduser  = p.Adduser,
                    Id       = p.Id
                }).ToList().Select(p => new
                {
                    Taskname = p.Taskname,
                    Name     = p.Name,
                    Endtime  = p.Endtime.ToShortDateString(),
                    //  Adduser = _brokerService.GetBrokerByUserId(p.Adduser).Brokername,
                    Adduser = _userservice.GetUserById(p.Adduser) == null ? p.Adduser.ToString() : _userservice.GetUserById(p.Adduser).UserName,
                    Id      = p.Id
                }).ToList();
                var taskCount = _taskService.GetTaskCount(taskcondition);
                if (taskCount > 0)
                {
                    return(PageHelper.toJson(new { list = taskList, totalCount = taskCount, condition = taskcondition }));
                }
                else
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(true, "不存在数据!")));
                }
            }
            catch {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "出现数据错误!")));
            }
        }