Пример #1
0
        public IEnumerable <TaskWrapper> GetTaskByFilter(int projectid, bool myProjects, int?milestone,
                                                         bool myMilestones, bool nomilestone, int tag,
                                                         TaskStatus?status, int?substatus, bool follow, Guid departament, Guid?participant, Guid creator,
                                                         ApiDateTime deadlineStart, ApiDateTime deadlineStop, int lastId)
        {
            var filter = CreateFilter(EntityType.Task);

            filter.DepartmentId  = departament;
            filter.ParticipantId = participant;
            filter.UserId        = creator;
            filter.Milestone     = nomilestone ? 0 : milestone;
            filter.FromDate      = deadlineStart;
            filter.ToDate        = deadlineStop;
            filter.TagId         = tag;
            filter.LastId        = lastId;
            filter.MyProjects    = myProjects;
            filter.MyMilestones  = myMilestones;
            filter.Follow        = follow;
            filter.Substatus     = substatus;

            if (projectid != 0)
            {
                filter.ProjectIds.Add(projectid);
            }

            if (status != null)
            {
                filter.TaskStatuses.Add((TaskStatus)status);
            }

            var filterResult = EngineFactory.TaskEngine.GetByFilter(filter).NotFoundIfNull();

            SetTotalCount(filterResult.FilterCount.TasksTotal);

            ProjectSecurity.GetTaskSecurityInfo(filterResult.FilterResult);

            return(filterResult.FilterResult.Select(TaskWrapperSelector).ToList());
        }
Пример #2
0
        public TaskWrapper(ProjectApiBase projectApiBase, Task task)
        {
            Id          = task.ID;
            Title       = task.Title;
            Description = task.Description;
            Status      = (int)task.Status;

            if (Status > 2)
            {
                Status = 1;
            }


            Deadline     = (task.Deadline == DateTime.MinValue ? null : new ApiDateTime(task.Deadline, TimeZoneInfo.Local));
            Priority     = task.Priority;
            ProjectOwner = new SimpleProjectWrapper(task.Project);
            MilestoneId  = task.Milestone;
            Created      = (ApiDateTime)task.CreateOn;
            Updated      = (ApiDateTime)task.LastModifiedOn;
            StartDate    = task.StartDate.Equals(DateTime.MinValue) ? null : (ApiDateTime)task.StartDate;

            if (task.SubTasks != null)
            {
                Subtasks = task.SubTasks.Select(x => new SubtaskWrapper(projectApiBase, x, task)).ToList();
            }

            Progress = task.Progress;

            if (task.Milestone != 0 && task.MilestoneDesc != null)
            {
                Milestone = new SimpleMilestoneWrapper(task.MilestoneDesc);
            }

            if (task.Links.Any())
            {
                Links = task.Links.Select(r => new TaskLinkWrapper(r));
            }

            if (task.Security == null)
            {
                ProjectSecurity.GetTaskSecurityInfo(task);
            }

            if (projectApiBase.Context.GetRequestValue("simple") != null)
            {
                CreatedById = task.CreateBy;
                UpdatedById = task.LastModifiedBy;
                if (task.Responsibles != null)
                {
                    ResponsibleIds = task.Responsibles;
                }
            }
            else
            {
                CreatedBy = projectApiBase.GetEmployeeWraper(task.CreateBy);
                if (task.CreateBy != task.LastModifiedBy)
                {
                    UpdatedBy = projectApiBase.GetEmployeeWraper(task.LastModifiedBy);
                }
                if (task.Responsibles != null)
                {
                    Responsibles = task.Responsibles.Select(projectApiBase.GetEmployeeWraper).OrderBy(r => r.DisplayName).ToList();
                }
            }

            CanEdit            = task.Security.CanEdit;
            CanCreateSubtask   = task.Security.CanCreateSubtask;
            CanCreateTimeSpend = task.Security.CanCreateTimeSpend;
            CanDelete          = task.Security.CanDelete;
            CanReadFiles       = task.Security.CanReadFiles;
        }