private void setDtoSettings(PmActivity task, PmActivityPermission permissions, ProjectResource resource = null) { Id = task.Id; ProjectInfo = new dtoProjectGroupInfo(task.Project, permissions, resource); Name = task.Name; Description = task.Description; Notes = task.Notes; Completeness = task.Completeness; IsCompleted = task.IsCompleted; Deleted = task.Deleted; Status = task.Status; StartDate = task.EarlyStartDate; EndDate = task.EarlyFinishDate; Deadline = task.Deadline; Duration = task.Duration; IsDurationEstimated = task.IsDurationEstimated; IdResources = task.CurrentAssignments.Select(a => a.Resource.Id).ToList(); Assignments = task.CurrentAssignments.Select(a => new dtoActivityCompletion() { Id = a.Id, IdResource = a.Resource.Id, Completeness = a.Completeness, IsApproved = a.IsApproved }).ToList(); }
public static dtoPlainProject CreateForResource(Project project, ProjectResource resource, Dictionary <ActivityRole, String> roleTranslations, PmActivityPermission pPermissions) { dtoPlainProject result = new dtoPlainProject(); result.Id = project.Id; result.IsCompleted = project.IsCompleted; result.IdCommunity = (project.Community == null) ? (project.isPortal ? 0 : -1) : project.Community.Id; result.Name = project.Name; result.Completeness = project.Completeness; result.Status = project.Status; result.CommunityName = (project.Community != null) ? project.Community.Name : ""; result.Deleted = project.Deleted; result.isPersonal = project.isPersonal; result.isPortal = project.isPortal; result.Deleted = project.Deleted; result.Visibility = resource.Visibility; result.Roles = new List <dtoProjectRole>(); result.Roles.Add(new dtoProjectRole() { ProjectRole = resource.ProjectRole, LongName = roleTranslations[resource.ProjectRole], ShortName = roleTranslations[resource.ProjectRole].ToCharArray()[0].ToString() }); if (resource.ProjectRole == ActivityRole.ProjectOwner) { result.Roles.Add(new dtoProjectRole() { ProjectRole = ActivityRole.Manager, LongName = roleTranslations[ActivityRole.Manager], ShortName = roleTranslations[ActivityRole.Manager].ToCharArray()[0].ToString() }); } if (resource.ProjectRole != ActivityRole.Visitor) { result.Roles.Add(new dtoProjectRole() { ProjectRole = ActivityRole.Resource, LongName = roleTranslations[ActivityRole.Resource], ShortName = roleTranslations[ActivityRole.Resource].ToCharArray()[0].ToString() }); } result.StartDate = project.StartDate; result.EndDate = project.EndDate; result.Deadline = project.Deadline; result.Availability = project.Availability; result.Permissions.ViewMap = ((pPermissions & PmActivityPermission.ViewProjectMap) == PmActivityPermission.ViewProjectMap); result.Permissions.ViewMyCompletion = (result.GetMajorRole(PageListType.ListResource) == ActivityRole.Resource); result.Permissions.ViewAttachments = result.Permissions.ViewMap; result.Permissions.EditAttachments = ((pPermissions & PmActivityPermission.ManageProject) == PmActivityPermission.ManageProject); //Permissions.ViewAttachments = ((modulePermission.Administration && !project.isPersonal) || modulePermission.Edit) && project.Deleted == BaseStatusDeleted.None; //Permissions.EditAttachments = (modulePermission.Administration || modulePermission.Edit) && project.Deleted == BaseStatusDeleted.None; //Boolean allowSave = (mPermission.Administration && !isPersonal) || ((pPermissions & PmActivityPermission.ManageProject) == PmActivityPermission.ManageProject); long notStarted = resource.AssignedActivities; result.UserCompletion[ResourceActivityStatus.completed] = resource.CompletedActivities; notStarted -= resource.CompletedActivities; if (project.ConfirmCompletion) { result.UserCompletion[ResourceActivityStatus.confirmed] = resource.ConfirmedActivities; notStarted -= resource.ConfirmedActivities; } notStarted = notStarted - resource.LateActivities - resource.StartedActivities; if (notStarted < 0) { notStarted = 0; } result.UserCompletion[ResourceActivityStatus.late] = resource.LateActivities; result.UserCompletion[ResourceActivityStatus.started] = resource.StartedActivities; result.UserCompletion[ResourceActivityStatus.notstarted] = notStarted; result.UserCompletion[ResourceActivityStatus.all] = resource.AssignedActivities; result.ProjectAttachmentsCount = (project.Attachments != null ? project.Attachments.Where(a => a.Deleted == BaseStatusDeleted.None && a.IsForProject).LongCount() : 0); result.HasProjectAttachments = !(result.ProjectAttachmentsCount == 0); result.HasActivitiesAttachments = (project.AttachmentLinks != null && project.AttachmentLinks.Where(a => a.Deleted == BaseStatusDeleted.None && !a.IsForProject).Any()); return(result); }