Exemple #1
0
        /// <summary>
        /// 获取项目列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public PageResponse <List <Project> > findProjects(QueryProjectOrTaskRequest request)
        {
            var total = 0;

            var sugarQueryableList = SimpleDb.AsQueryable().Where(u =>
                                                                  u.Name.Contains(request.key) && SqlFunc.Between(u.CreateTime, request.startTime, request.endTime));

            if (!string.IsNullOrEmpty(request.type))
            {
                sugarQueryableList = sugarQueryableList.Where(u => u.Type == request.type);
            }

            // 如果是管理员 才查看所有项目 否则查询自己负责或者自己提交的项目
            var roleId = Db.Queryable <UserRole>().Where(u => u.UserId == user.UserId).Select(u => u.RoleId).First();

            if (roleId != 1)
            {
                sugarQueryableList = sugarQueryableList.Where(u => u.ChargeUserId == user.UserId || u.SubmitterId == user.UserId);
            }

            var list = sugarQueryableList.OrderBy(u => request.sortColumn,
                                                  request.sortType == "asc" ? OrderByType.Asc : OrderByType.Desc)
                       .ToPageList(request.page, request.limit, ref total);

            var pageResponse = new PageResponse <List <Project> > {
                Total = total, Result = list
            };

            return(pageResponse);
        }
        public PageResponse <List <Project> > findProjects(QueryProjectOrTaskRequest request)
        {
            var result = new PageResponse <List <Project> >();

            try
            {
                result = _service.findProjects(request);
            }
            catch (Exception ex)
            {
                result.Code    = 500;
                result.Message = ex.Message;
            }

            return(result);
        }
        public PageResponse <string> getTaskList(QueryProjectOrTaskRequest request)
        {
            var result = new PageResponse <string>();

            try
            {
                result = _service.getTaskList(request);
            }
            catch (Exception ex)
            {
                result.Code    = 500;
                result.Message = ex.Message;
            }

            return(result);
        }
Exemple #4
0
        /// <summary>
        /// 获取我的任务列表
        /// </summary>
        /// <returns></returns>
        public PageResponse <string> getTaskList(QueryProjectOrTaskRequest request)
        {
            var total = 0;
            var query = Db.Queryable <Task, Project>((t, p) => new object[]
            {
                JoinType.Left, t.ProjectId == p.Id
            }).Where((t, p) => t.TaskName.Contains(request.key));

            if (SqlFunc.HasValue(request.startTime) && SqlFunc.HasValue(request.endTime))
            {
                query = query.Where((t, p) => SqlFunc.Between(t.CreateTime, request.startTime, request.endTime));
            }

            if (SqlFunc.HasValue(request.type))
            {
                query = query.Where((t, p) => t.Status == int.Parse(request.type));
            }

            // 如果是管理员 才查看所有任务 否则查询自己负责或者自己提交的
            var roleId = Db.Queryable <UserRole>().Where(u => u.UserId == user.UserId).Select(u => u.RoleId).First();

            if (roleId != 1)
            {
                query = query.Where((t, p) => t.ChargeUserId == user.UserId || t.SubmitterId == user.UserId || p.ChargeUserId == user.UserId);
            }

            var result = query.Select((t, p) => new
            {
                id            = t.Id, projectId = t.ProjectId, taskName = t.TaskName, weight = t.Weight, progress = t.Progress,
                status        = t.Status, priority = t.Priority, startTime = t.StartTime, endTime = t.EndTime,
                submitterName = t.SubmitterName, projectName = p.Name, chargeUserName = t.ChargeUserName
            });

            var json = result.ToPageList(request.page, request.limit, ref total).ToJson();

            var pageResponse = new PageResponse <string> {
                Total = total, Result = json
            };

            return(pageResponse);
        }