Exemple #1
0
        public ActivityRole GetUserRoleByPage(ActivityRole role, PageContainerType container, PageListType currentPage)
        {
            switch (container)
            {
            case PageContainerType.Dashboard:
                if (currentPage == PageListType.DashboardResource)
                {
                    return((role == ActivityRole.ProjectOwner || role == ActivityRole.Manager) ? ActivityRole.Resource : role);
                }
                else
                {
                    return(role);
                }

            case PageContainerType.ProjectDashboard:
                if (currentPage == PageListType.ProjectDashboardResource)
                {
                    return((role == ActivityRole.ProjectOwner || role == ActivityRole.Manager) ? ActivityRole.Resource : role);
                }
                else
                {
                    return(role);
                }
            }
            return(role);
        }
        private PageListType GetDashboardPageByContainer(PageContainerType container, PageListType page)
        {
            switch (container)
            {
            case PageContainerType.ProjectDashboard:
                return((page == PageListType.DashboardResource) ? PageListType.ProjectDashboardResource : PageListType.ProjectDashboardManager);

            default:
                return(page);
            }
        }
 public void LoadTasks(dtoProjectContext context, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, Int32 pageIndex, Int32 pageSize, String unknownUser)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplayPager(false);
         View.LoadedNoTasks();
     }
     else
     {
         LoadTasks(Service.GetTasks(UserContext.CurrentUserID, filter, context.IdCommunity, container, fromPage, currentPage), context, filter, container, fromPage, currentPage, pageIndex, pageSize, unknownUser);
     }
 }
 public dtoDisplayTimelineContext(dtoProjectContext context, Int32 idContainerCommunity, PageContainerType container, PageListType currentPage, PageListType fromPage, SummaryTimeLine timeline, SummaryDisplay display, ProjectFilterBy filterBy = ProjectFilterBy.All, ItemsGroupBy groupBy = ItemsGroupBy.None, ItemListStatus status = ItemListStatus.All)
 {
     FromPage             = fromPage;
     ProjectContext       = context;
     FromPage             = fromPage;
     CurrentPage          = currentPage;
     IdContainerCommunity = idContainerCommunity;
     Display           = display;
     FilterBy          = filterBy;
     ContainerTimeline = timeline;
     Container         = container;
     GroupBy           = groupBy;
     Status            = status;
 }
 public dtoDisplayTimelineContext(dtoProjectContext context, Int32 idContainerCommunity, PageContainerType container, PageListType currentPage, PageListType fromPage, dtoItemsFilter filters, ItemsGroupBy groupBy = ItemsGroupBy.None)
 {
     FromPage             = fromPage;
     ProjectContext       = context;
     FromPage             = fromPage;
     CurrentPage          = currentPage;
     IdContainerCommunity = idContainerCommunity;
     Display           = filters.Display;
     FilterBy          = filters.FilterBy;
     ContainerTimeline = filters.TimeLine;
     Container         = container;
     IdProject         = filters.IdProject;
     if (groupBy != ItemsGroupBy.None)
     {
         GroupBy = groupBy;
     }
     else
     {
         GroupBy = filters.GroupBy;
     }
 }
        public void Applyfilters(dtoItemsFilter filter, dtoProjectContext context, PageContainerType containerType, PageListType currentPageType, PageListType fromPage, Boolean summaryUpdate)
        {
            Person user = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (UserContext.isAnonymous || user == null)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                long  idProject   = View.CurrendIdProject;
                Int32 idCommunity = View.IdContainerCommunity;
                if (summaryUpdate)
                {
                    LoadSummary(context, idCommunity, currentPageType, fromPage, user, idProject, filter, filter.TimeLine, View.CurrentDisplayMode, (idCommunity > 0 ? idCommunity : -100));
                }

                LoadFilters(user, context, filter, containerType, currentPageType, fromPage, filter.TimeLine, idProject);
                View.SaveCurrentFilters(filter);
            }
        }
        //public void AddDeletedStatus(ref dtoItemsFilter filter, dtoProjectContext context, PageContainerType itemsView, PageListType currentView, Boolean moveToStatus)
        //{
        //    if (moveToStatus) {
        //        filter.Status = ItemListStatus.Deleted;
        //        filter.PageIndex = 0;
        //        switch (filter.GroupBy) {
        //            case ItemsGroupBy.Plain:
        //                filter.OrderBy = ProjectOrderBy.Name;
        //                filter.Ascending = true;
        //                break;
        //            case ItemsGroupBy.EndDate:
        //                filter.OrderBy = ProjectOrderBy.EndDate;
        //                filter.Ascending = true;
        //                break;
        //            case ItemsGroupBy.Community:
        //                filter.OrderBy = ProjectOrderBy.CommunityName;
        //                filter.Ascending = true;
        //                break;
        //        }
        //    }
        //    ItemListStatus status = filter.Status;
        //    List<ItemListStatus> sItems = Service.GetAvailableFilterStatus(CurrentManager.GetPerson(UserContext.CurrentUserID), context, filter, currentView);
        //    sItems.Add(ItemListStatus.Deleted);

        //    Int32 idCommunity = View.IdCurrentCommunityForList;

        //    View.InitializeSummary(UserContext.CurrentUserID, filter.TimeLine, filter.Display, filter.FilterBy, filter.Status, (idCommunity > 0 ? idCommunity : -100));
        //    View.LoadStatus(GetStatusItems(sItems, context, filter, currentView));
        //    View.LoadGroupBy(GetGroupByItems(filter, context, itemsView, currentView));

        //    View.SaveCurrentFilters(filter);
        //}
        public void RemoveDeletedStatus(ref dtoItemsFilter filter, dtoProjectContext context, PageContainerType containerType, PageListType currentPageType, PageListType fromPage)
        {
            Person user = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (UserContext.isAnonymous || user == null)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                long idProject = View.CurrendIdProject;
                List <ItemListStatus> avalableStatus = Service.GetAvailableFilterStatus(user, context, filter, containerType, currentPageType, filter.TimeLine, idProject);
                View.LoadStatusFilters(GetStatusItems(avalableStatus, context, filter, currentPageType, fromPage));
                if (!avalableStatus.Contains(ItemListStatus.Deleted))
                {
                    filter = dtoItemsFilter.GenerateForGroup(containerType, filter.GroupBy);
                    Int32 idCommunity = View.IdContainerCommunity;
                    LoadAvailableGroupBy(context, filter, currentPageType, fromPage);
                    LoadSummary(context, idCommunity, currentPageType, fromPage, user, idProject, filter, filter.TimeLine, View.CurrentDisplayMode, (idCommunity > 0 ? idCommunity : -100));
                    View.SaveCurrentFilters(filter);
                }
            }
        }
        public void ReloadAvailableStatus(dtoItemsFilter filter, dtoProjectContext context, PageContainerType containerType, PageListType currentPageType, PageListType fromPage)
        {
            Person user = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (UserContext.isAnonymous || user == null)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                LoadAvailableStatus(user, context, filter, containerType, currentPageType, fromPage, filter.TimeLine);
            }
        }
 private void LoadAvailableStatus(Person user, dtoProjectContext context, dtoItemsFilter filter, PageContainerType containerType, PageListType currentPageType, PageListType fromPage, SummaryTimeLine timeline, long idProject = 0)
 {
     View.LoadStatusFilters(GetStatusItems(Service.GetAvailableFilterStatus(user, context, filter, containerType, currentPageType, timeline, idProject), context, filter, currentPageType, fromPage));
 }
        public void InitView(dtoProjectContext context, Int32 idContainerCommunity, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, String unknownUser)
        {
            Person p = CurrentManager.GetPerson(UserContext.CurrentUserID);

            View.PageContainer        = container;
            View.PageType             = currentPage;
            View.CurrentFromPage      = fromPage;
            View.IdContainerCommunity = idContainerCommunity;
            View.PageContext          = context;
            if (UserContext.isAnonymous || p == null)
            {
                View.DisplayPager(false);
                View.LoadedNoTasks();
            }
            else
            {
                if (!View.IsInitialized && filter.GroupBy == ItemsGroupBy.EndDate)
                {
                    filter.PageIndex = -1;
                }
                View.IsInitialized = true;
                if (filter.PageSize == 0)
                {
                    filter.PageSize = View.CurrentPageSize;
                }
                switch (filter.GroupBy)
                {
                case ItemsGroupBy.Community:
                    View.CurrentOrderBy   = ProjectOrderBy.CommunityName;
                    View.CurrentAscending = true;
                    filter.OrderBy        = ProjectOrderBy.CommunityName;
                    filter.Ascending      = true;
                    break;

                case ItemsGroupBy.EndDate:
                    View.CurrentOrderBy   = ProjectOrderBy.EndDate;
                    View.CurrentAscending = false;
                    filter.OrderBy        = ProjectOrderBy.EndDate;
                    filter.Ascending      = false;
                    break;

                case ItemsGroupBy.Project:
                    View.CurrentOrderBy   = ProjectOrderBy.Name;
                    View.CurrentAscending = true;
                    filter.OrderBy        = ProjectOrderBy.Name;
                    filter.Ascending      = true;
                    break;
                }
                View.CurrentGroupBy = filter.GroupBy;
                LoadTasks(unknownUser, context, idContainerCommunity, filter, container, fromPage, currentPage, filter.GroupBy, filter.PageIndex, filter.PageSize);
            }
        }
 private void LoadFilters(Person user, dtoProjectContext context, dtoItemsFilter filter, PageContainerType containerType, PageListType currentPageType, PageListType fromPage, SummaryTimeLine timeline, long idProject = 0)
 {
     LoadAvailableStatus(user, context, filter, containerType, currentPageType, fromPage, timeline, idProject);
     LoadAvailableGroupBy(context, filter, currentPageType, fromPage);
     if (containerType != PageContainerType.ProjectDashboard)
     {
         LoadAvailableFiltersBy(user, context, filter, currentPageType);
     }
 }
Exemple #12
0
 //public static dtoItemsFilter GenerateForGroup(ItemsGroupBy groupBy, Int32 idCommunity = -1, long idProject =0) {
 public static dtoItemsFilter GenerateForGroup(PageContainerType pageContainer, ItemsGroupBy groupBy)
 {
     return(GenerateForGroup(pageContainer, groupBy, -1, 0));
 }
Exemple #13
0
        private void GroupTasks(List <dtoPlainTask> tasks, String unknownUser, dtoProjectContext context, Int32 idContainerCommunity, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, SummaryTimeLine timeline, Int32 pageIndex, Int32 pageSize, PagerBase pager = null)
        {
            if (tasks.Skip((pageIndex < 0 ? 0 : pageIndex) * pageSize).Take(pageSize).Any())
            {
                Dictionary <long, List <dtoResource> > resources = tasks.Select(t => t.ProjectInfo.Id).Distinct().ToDictionary(t => t, t => Service.GetAvailableResources(t, unknownUser));


                String pName = View.GetPortalName();
                String cName = View.GetUnknownCommunityName();
                tasks.Where(p => p.ProjectInfo.IdCommunity == 0).ToList().ForEach(p => p.ProjectInfo.CommunityName = pName);
                tasks.Where(p => p.ProjectInfo.IdCommunity < 0).ToList().ForEach(p => p.ProjectInfo.CommunityName  = cName);
                tasks.ForEach(t => t.ProjectResources = (resources.ContainsKey(t.ProjectInfo.Id) ? resources[t.ProjectInfo.Id] : new List <dtoResource>()));

                View.LoadTasks(GenerateCommunityProjectTree(tasks, context, idContainerCommunity, filter, container, fromPage, currentPage, timeline, pageIndex, pageSize));
            }
            else
            {
                View.LoadedNoTasks();
            }
        }
Exemple #14
0
        private List <dtoPlainTask> GetTasksAsManager(Int32 idPerson, dtoItemsFilter filter, Int32 idCommunity, PageContainerType container, PageListType fromPage, PageListType displayPage, List <dtoProjectGroupInfo> projectsInfo = null)
        {
            List <dtoPlainTask> tasks = new List <dtoPlainTask>();

            try
            {
                IEnumerable <ProjectResource> query = GetResourcesAsManager(idPerson, filter, idCommunity, false);
                DateTime today = DateTime.Now.Date;
                Dictionary <SummaryTimeLine, long> days = GetDaysOfYear(today);
                if (query.Count() < maxItemsForQuery)
                {
                    Dictionary <long, ActivityRole> projectRoles = query.ToDictionary(r => r.Project.Id, r => r.ProjectRole);
                    tasks.AddRange(GetTasks(GetTasksQuery(projectRoles.Keys.ToList()), days, filter, projectRoles, container, displayPage));
                }
                else
                {
                    Int32 pageIndex = 0;
                    var   pInfo     = query.Select(i => new { IdProject = i.Project.Id, Role = i.ProjectRole }).ToList();
                    while (pInfo.Skip(pageIndex * maxItemsForQuery).Take(maxItemsForQuery).Any())
                    {
                        tasks.AddRange(GetTasks(GetTasksQuery(pInfo.Skip(pageIndex * maxItemsForQuery).Take(maxItemsForQuery).Select(p => p.IdProject).ToList()), days, filter, pInfo.Skip(pageIndex * maxItemsForQuery).Take(maxItemsForQuery).ToDictionary(p => p.IdProject, p => p.Role), container, displayPage));
                        pageIndex++;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(tasks);
        }
Exemple #15
0
        public static dtoItemsFilter GenerateForGroup(PageContainerType pageContainer, ItemsGroupBy groupBy, Int32 idCommunity, long idProject)
        {
            dtoItemsFilter filter = new dtoItemsFilter();

            switch (idCommunity)
            {
            case 0:
                filter.FilterBy = ProjectFilterBy.FromPortal;
                break;

            case -1:
                filter.FilterBy = ProjectFilterBy.All;
                break;

            default:
                filter.FilterBy = ProjectFilterBy.CurrentCommunity;
                break;
            }
            filter.Container = pageContainer;
            filter.PageIndex = 0;
            filter.PageSize  = 25;
            if (idProject == 0)
            {
                filter.Display = SummaryDisplay.All;
            }
            else
            {
                filter.Display = SummaryDisplay.Project;
            }
            filter.IdProject = idProject;

            filter.ProjectsStatus   = (pageContainer == PageContainerType.ProjectDashboard) ? ItemListStatus.Late : ItemListStatus.All;
            filter.ActivitiesStatus = (pageContainer == PageContainerType.Dashboard) ? ItemListStatus.Late : ItemListStatus.All;
            filter.TimeLine         = SummaryTimeLine.Week;
            filter.GroupBy          = groupBy;
            switch (groupBy)
            {
            case ItemsGroupBy.Plain:
                filter.Ascending = true;
                filter.OrderBy   = ProjectOrderBy.Deadline;
                break;

            case ItemsGroupBy.Community:
                filter.Ascending = true;
                filter.OrderBy   = ProjectOrderBy.CommunityName;
                break;

            case ItemsGroupBy.EndDate:
                filter.Ascending = false;
                filter.OrderBy   = ProjectOrderBy.EndDate;
                filter.PageIndex = -1;
                break;

            case ItemsGroupBy.Project:
                filter.Ascending = true;
                filter.OrderBy   = ProjectOrderBy.Name;
                break;

            case ItemsGroupBy.CommunityProject:
                filter.Ascending = true;
                filter.OrderBy   = ProjectOrderBy.CommunityName;
                break;
            }
            return(filter);
        }
Exemple #16
0
        private void UpdateGroups(dtoTasksGroup item, dtoProjectContext context, Int32 idContainerCommunity, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, SummaryTimeLine timeline)
        {
            foreach (dtoPlainTask task in item.Tasks)
            {
                task.IdFatherRow = item.IdRow;
                if (currentPage != PageListType.ProjectDashboardManager && currentPage != PageListType.ProjectDashboardResource)
                {
                    task.ProjectInfo.ProjectDashboard = RootObject.ProjectDashboard(context, idContainerCommunity, task.ProjectInfo.Id, currentPage, currentPage, filter.TimeLine);
                }
            }

            item.ProjectInfo = item.Tasks.First().ProjectInfo;
            if (item.HasPermission(PmActivityPermission.ManageProject))
            {
                item.ProjectInfo.ProjectUrls.Edit       = RootObject.EditProject(item.ProjectInfo.Id, item.ProjectInfo.IdCommunity, item.ProjectInfo.isPortal, item.ProjectInfo.isPersonal, currentPage, idContainerCommunity);
                item.ProjectInfo.ProjectUrls.ProjectMap = RootObject.ProjectMap(item.ProjectInfo.Id, item.ProjectInfo.IdCommunity, item.ProjectInfo.isPortal, item.ProjectInfo.isPersonal, currentPage, idContainerCommunity);
            }
            else if (item.HasPermission(PmActivityPermission.ViewProjectMap))
            {
                item.ProjectInfo.ProjectUrls.ProjectMap = RootObject.ViewProjectMap(item.ProjectInfo.Id, item.ProjectInfo.IdCommunity, item.ProjectInfo.isPortal, item.ProjectInfo.isPersonal, currentPage, idContainerCommunity);
            }
        }
Exemple #17
0
        private List <dtoTasksGroup> GenerateProjectTree(List <dtoPlainTask> projectTasks, List <dtoPlainTask> availableTasks, dtoProjectContext context, Int32 idContainerCommunity, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, SummaryTimeLine timeline, Int32 pageIndex, Int32 pageSize)
        {
            List <dtoTasksGroup> items = new List <dtoTasksGroup>();
            String cssClass            = View.GetContainerCssClass(ItemsGroupBy.Project);
            Int32  cCount = View.GetCellsCount(currentPage);
            String sRow   = View.GetStartRowId(ItemsGroupBy.Project);

            projectTasks.OrderBy(p => p.ProjectInfo.VirtualProjectName).GroupBy(p => p.ProjectInfo.VirtualProjectName).OrderBy(p => p.Key).ToList().ForEach(
                p => items.Add(new dtoTasksGroup()
            {
                Id             = p.FirstOrDefault().ProjectInfo.Id,
                Name           = p.FirstOrDefault().ProjectInfo.Name,
                Tasks          = p.ToList(),
                CssClass       = cssClass,
                CellsCount     = cCount,
                IdRowFirstItem = sRow + p.First().Id.ToString(),
                IdRowLastItem  = sRow + p.Last().Id.ToString(),
                IdRow          = sRow + p.FirstOrDefault().ProjectInfo.Id.ToString()
            }));
            items.ForEach(i => UpdateGroups(i, context, idContainerCommunity, filter, container, fromPage, currentPage, timeline));
            long idFirstProject = items.First().Tasks.Select(p => p.ProjectInfo.Id).FirstOrDefault();
            long idLastProject  = items.Last().Tasks.Select(p => p.ProjectInfo.Id).FirstOrDefault();

            if (pageIndex > 0 && availableTasks.OrderBy(p => p.ProjectInfo.VirtualProjectName).Skip((pageIndex - 1) * pageSize).Where(p => p.ProjectInfo.Id == idFirstProject).Any())
            {
                items.First().PreviousPageIndex = pageIndex - 1;
            }
            if (availableTasks.OrderBy(p => p.ProjectInfo.VirtualProjectName).Skip((pageIndex + 1) * pageSize).Where(p => p.ProjectInfo.Id == idLastProject).Any())
            {
                items.Last().NextPageIndex = pageIndex + 1;
            }

            return(items);
        }
Exemple #18
0
        private List <dtoCommunityProjectTasksGroup> GenerateCommunityProjectTree(List <dtoPlainTask> tasks, dtoProjectContext context, Int32 idContainerCommunity, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, SummaryTimeLine timeline, Int32 pageIndex, Int32 pageSize)
        {
            List <dtoCommunityProjectTasksGroup> items = new List <dtoCommunityProjectTasksGroup>();
            Int32  cCount = View.GetCellsCount(currentPage);
            String sRow   = View.GetStartRowId(ItemsGroupBy.Community);

            tasks.OrderBy(p => p.ProjectInfo.CommunityName).Skip(pageIndex * pageSize).Take(pageSize).GroupBy(p => p.ProjectInfo.VirtualCommunityName).OrderBy(p => p.Key).ToList().ForEach(
                p => items.Add(new dtoCommunityProjectTasksGroup()
            {
                Id             = p.FirstOrDefault().ProjectInfo.IdCommunity,
                Name           = p.FirstOrDefault().ProjectInfo.CommunityName,
                Projects       = GenerateProjectTree(p.ToList(), tasks, context, idContainerCommunity, filter, container, fromPage, currentPage, timeline, pageIndex, pageSize),
                CellsCount     = cCount,
                IdRowFirstItem = sRow + p.First().Id.ToString(),
                IdRowLastItem  = sRow + p.Last().Id.ToString(),
                IdRow          = sRow + p.FirstOrDefault().ProjectInfo.IdCommunity.ToString()
            }));
            long idFirstCommunity = items.First().Projects.Select(p => p.ProjectInfo.IdCommunity).FirstOrDefault();
            long idLastCommunity  = items.Last().Projects.Select(p => p.ProjectInfo.IdCommunity).FirstOrDefault();

            if (pageIndex > 0 && !items.Where(i => i.Projects.Where(p => p.PreviousPageIndex != -1).Any()).Any() && tasks.OrderBy(p => p.ProjectInfo.VirtualCommunityName).Skip((pageIndex - 1) * pageSize).Where(p => p.ProjectInfo.IdCommunity == idFirstCommunity).Any())
            {
                items.First().PreviousPageIndex = pageIndex - 1;
            }
            if (!items.Where(i => i.Projects.Where(p => p.NextPageIndex != -1).Any()).Any() && tasks.OrderBy(p => p.ProjectInfo.VirtualCommunityName).Skip((pageIndex + 1) * pageSize).Where(p => p.ProjectInfo.IdCommunity == idLastCommunity).Any())
            {
                items.Last().NextPageIndex = pageIndex + 1;
            }

            return(items);
        }
        public void InitView(dtoProjectContext context, Int32 idContainerCommunity, Boolean loadFromCookies, TabListItem tab, PageContainerType container, PageListType fromPage, PageListType currentPageType, ItemsGroupBy preloadGroupBy, ProjectFilterBy pFilterBy, ItemListStatus pProjectsStatus, ItemListStatus pActivitiesStatus, SummaryTimeLine pFilterTimeLine = SummaryTimeLine.Week, SummaryDisplay pFilterDisplay = SummaryDisplay.All, long idProject = 0, UserActivityStatus pUserActivitiesStatus = UserActivityStatus.Ignore, SummaryTimeLine pUserActivitiesTimeLine = SummaryTimeLine.Week)
        {
            Person p = CurrentManager.GetPerson(UserContext.CurrentUserID);

            View.PageContext             = context;
            View.PageContainer           = container;
            View.PageType                = currentPageType;
            View.CurrentFromPage         = fromPage;
            View.CurrendIdProject        = idProject;
            View.IdContainerCommunity    = idContainerCommunity;
            View.CurrentActivityStatus   = pUserActivitiesStatus;
            View.CurrentActivityTimeLine = pUserActivitiesTimeLine;
            if (UserContext.isAnonymous || p == null)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                View.CookieName = View.CookieStartName + container.ToString() + tab.ToString();
                dtoItemsFilter filter = null;
                if (loadFromCookies)
                {
                    filter = View.GetSavedFilters;
                    View.CurrentActivityStatus   = filter.UserActivitiesStatus;
                    View.CurrentActivityTimeLine = filter.UserActivitiesTimeLine;
                    idProject             = filter.IdProject;
                    View.CurrendIdProject = idProject;
                }
                if (filter == null)
                {
                    filter = dtoItemsFilter.GenerateForGroup(container, (preloadGroupBy == ItemsGroupBy.None) ? ItemsGroupBy.Plain : preloadGroupBy);
                    if (preloadGroupBy != ItemsGroupBy.None)
                    {
                        filter.FilterBy               = pFilterBy;
                        filter.ProjectsStatus         = pProjectsStatus;
                        filter.Display                = pFilterDisplay;
                        filter.TimeLine               = pFilterTimeLine;
                        filter.ActivitiesStatus       = pActivitiesStatus;
                        filter.UserActivitiesStatus   = pUserActivitiesStatus;
                        filter.UserActivitiesTimeLine = pUserActivitiesTimeLine;
                    }
                    filter.IdProject = idProject;
                }
                LoadFilters(p, context, filter, container, currentPageType, fromPage, pFilterTimeLine, idProject);
                View.SaveCurrentFilters(filter);
                View.InitializeTabs(Service.GetAvailableTabs(p.Id, context, container), tab, filter, context);
                LoadSummary(context, idContainerCommunity, currentPageType, fromPage, p, idProject, filter, pFilterTimeLine, pFilterDisplay, (context.IdCommunity > 0 ? context.IdCommunity : -100));
            }
        }
Exemple #20
0
 public ItemListStatus GetStatus(PageContainerType pageContainer)
 {
     return((pageContainer == PageContainerType.ProjectsList) ? ProjectsStatus : ActivitiesStatus);
 }
Exemple #21
0
        private List <dtoPlainTask> GetTasks(IEnumerable <PmActivity> query, Dictionary <SummaryTimeLine, long> days, dtoItemsFilter filter, Dictionary <long, ActivityRole> projectRoles, PageContainerType container, PageListType displayPage)
        {
            List <dtoPlainTask> tasks = GetTasks(query, days, filter);
            Dictionary <ActivityRole, PmActivityPermission> permissions = projectRoles.Values.Distinct().ToDictionary(v => v, v => GetRolePermissions(GetUserRoleByPage(v, container, displayPage)));

            foreach (dtoPlainTask t in tasks)
            {
                t.SetPermissions(permissions[projectRoles[t.ProjectInfo.Id]]);
            }
            return(tasks);
        }
Exemple #22
0
        private void LoadTasks(List <dtoPlainTask> tasks, String unknownUser, dtoProjectContext context, Int32 idContainerCommunity, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, Int32 pageIndex, Int32 pageSize)
        {
            if (pageIndex < 0)
            {
                pageIndex = 0;
            }

            PagerBase pager = new PagerBase();

            pager.PageSize = pageSize;//Me.View.CurrentPageSize
            pager.Count    = (tasks.Count > 0) ? tasks.Count - 1 : 0;

            if (pageIndex > -1)
            {
                pager.PageIndex = pageIndex;// Me.View.CurrentPageIndex
                pageIndex       = (pageIndex > pager.PageIndex && pager.PageIndex >= 0) ? pager.PageIndex : pageIndex;
                View.Pager      = pager;
            }
            GroupTasks(tasks, unknownUser, context, idContainerCommunity, filter, container, fromPage, currentPage, filter.TimeLine, pageIndex, pageSize, (pageIndex > -1 ? null : pager));
        }
        public void InitView(dtoProjectContext context, Int32 idContainerCommunity, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, String unknownUser)
        {
            Person p = CurrentManager.GetPerson(UserContext.CurrentUserID);

            View.PageContainer        = container;
            View.PageType             = currentPage;
            View.CurrentFromPage      = fromPage;
            View.IdContainerCommunity = idContainerCommunity;
            View.PageContext          = context;
            if (UserContext.isAnonymous || p == null)
            {
                View.DisplayPager(false);
                View.LoadedNoTasks();
            }
            else
            {
                View.IsInitialized = true;
                if (filter.PageSize == 0)
                {
                    filter.PageSize = View.CurrentPageSize;
                }
                View.CurrentOrderBy   = filter.OrderBy;
                View.CurrentAscending = filter.Ascending;
                LoadTasks(context, filter, container, fromPage, currentPage, filter.PageIndex, filter.PageSize, unknownUser);
            }
        }
Exemple #24
0
        private List <dtoPlainTask> GetTasksAsResource(Int32 idPerson, dtoItemsFilter filter, Int32 idCommunity, PageContainerType container, PageListType fromPage, PageListType displayPage)
        {
            List <dtoPlainTask> tasks = new List <dtoPlainTask>();

            try
            {
                Dictionary <ActivityRole, PmActivityPermission> permissions = (from e in Enum.GetValues(typeof(ActivityRole)).Cast <ActivityRole>() where e != ActivityRole.Manager && e != ActivityRole.ProjectOwner select e).ToDictionary(e => e, e => GetRolePermissions(e));
                tasks = GetTasks(GetAssignmentsByUser(idPerson, filter, idCommunity), GetDaysOfYear(DateTime.Now.Date), filter, permissions);

                Dictionary <Int32, String> cNames = null;
                List <Int32> idCommunities        = tasks.Select(t => t.ProjectInfo.IdCommunity).Distinct().ToList();
                if (idCommunities.Count > maxItemsForQuery)
                {
                    cNames = (from c in Manager.GetIQ <Community>() select new { IdCommunity = c.Id, Name = c.Name }).ToList().Where(c => idCommunities.Contains(c.IdCommunity)).ToDictionary(c => c.IdCommunity, c => c.Name);
                }
                else
                {
                    cNames = (from c in Manager.GetIQ <Community>() where idCommunities.Contains(c.Id) select c).ToDictionary(c => c.Id, c => c.Name);
                }
                foreach (dtoPlainTask t in tasks.Where(t => !t.ProjectInfo.isPortal && !cNames.ContainsKey(t.ProjectInfo.IdCommunity)))
                {
                    t.ProjectInfo.IdCommunity = -1;
                }
                foreach (dtoPlainTask t in tasks.Where(t => !t.ProjectInfo.isPortal && cNames.ContainsKey(t.ProjectInfo.IdCommunity)))
                {
                    t.ProjectInfo.CommunityName = cNames[t.ProjectInfo.IdCommunity];
                }
            }
            catch (Exception ex)
            {
            }
            return(tasks);
        }
        private void LoadTasks(List <dtoPlainTask> tasks, dtoProjectContext context, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, Int32 pageIndex, Int32 pageSize, String unknownUser)
        {
            Int32     idContainerCommunity = View.IdContainerCommunity;
            PagerBase pager = new PagerBase();

            pager.PageSize  = pageSize;  //Me.View.CurrentPageSize
            pager.Count     = (tasks.Count > 0) ? tasks.Count - 1 : 0;
            pager.PageIndex = pageIndex; // Me.View.CurrentPageIndex
            View.Pager      = pager;

            pageIndex = (pageIndex > pager.PageIndex && pager.PageIndex >= 0) ? pager.PageIndex : pageIndex;
            tasks     = tasks.Skip(pageIndex * pageSize).Take(pageSize).ToList();
            if (tasks.Any())
            {
                Dictionary <long, List <dtoResource> > resources = tasks.Select(t => t.ProjectInfo.Id).Distinct().ToDictionary(t => t, t => Service.GetAvailableResources(t, unknownUser));
                if (currentPage != PageListType.ProjectDashboardManager && currentPage != PageListType.ProjectDashboardResource)
                {
                    Int32 idContainer = View.IdContainerCommunity;
                    foreach (dtoPlainTask task in tasks.Where(t => t.ProjectInfo.Id > 0))
                    {
                        task.ProjectResources             = (resources.ContainsKey(task.ProjectInfo.Id) ? resources[task.ProjectInfo.Id] : new List <dtoResource>());
                        task.ProjectInfo.ProjectDashboard = RootObject.ProjectDashboard(context, idContainer, task.ProjectInfo.Id, currentPage, currentPage, filter.TimeLine);
                    }
                }
                else
                {
                    foreach (dtoPlainTask task in tasks)
                    {
                        task.ProjectResources = (resources.ContainsKey(task.ProjectInfo.Id) ? resources[task.ProjectInfo.Id] : new List <dtoResource>());
                    }
                }
                View.LoadTasks(tasks);
            }
            else
            {
                View.LoadedNoTasks();
            }
            SendDefaultAction(currentPage, filter.IdProject, context.IdCommunity);
        }
Exemple #26
0
        public List <dtoPlainTask> GetTasks(Int32 idPerson, dtoItemsFilter filter, Int32 idCommunity, PageContainerType container, PageListType fromPage, PageListType displayPage)
        {
            List <dtoPlainTask> tasks = new List <dtoPlainTask>();

            try
            {
                Person person = Manager.GetPerson(idPerson);
                switch (container)
                {
                case PageContainerType.ProjectDashboard:
                    switch (displayPage)
                    {
                    case PageListType.ProjectDashboardManager:
                        if (IsProjectManager(filter.IdProject, idPerson))
                        {
                            tasks = GetTasksAsManager(idPerson, filter, idCommunity, container, fromPage, displayPage);
                        }
                        else if (IsProjectAdministrator(filter.IdProject, person))
                        {
                            tasks = GetProjectTasksAsAdministrator(person, filter, idCommunity);
                        }
                        break;

                    case PageListType.ProjectDashboardResource:
                        tasks = GetTasksAsResource(idPerson, filter, idCommunity, container, fromPage, displayPage);
                        break;
                    }
                    break;

                case PageContainerType.Dashboard:
                    switch (displayPage)
                    {
                    case PageListType.DashboardManager:
                        tasks = GetTasksAsManager(idPerson, filter, idCommunity, container, fromPage, displayPage);
                        break;

                    case PageListType.DashboardAdministrator:
                        tasks = GetTasksAsAdministrator(person, filter, idCommunity);
                        break;

                    case PageListType.DashboardResource:
                        tasks = GetTasksAsResource(idPerson, filter, idCommunity, container, fromPage, displayPage);
                        break;
                    }
                    break;
                }
                #region "ApplyFilters"

                switch (filter.GroupBy)
                {
                case ItemsGroupBy.Plain:
                    switch (filter.OrderBy)
                    {
                    case ProjectOrderBy.TaskName:
                        if (filter.Ascending)
                        {
                            tasks = tasks.OrderBy(p => p.Name).ThenByDescending(p => p.Deadline).ThenByDescending(p => p.EndDate).ToList();
                        }
                        else
                        {
                            tasks = tasks.OrderByDescending(p => p.Name).ThenByDescending(p => p.Deadline).ThenByDescending(p => p.EndDate).ToList();
                        }
                        break;

                    case ProjectOrderBy.Completion:
                        if (filter.Ascending)
                        {
                            tasks = tasks.OrderBy(p => p.Completeness).ThenBy(p => p.Name).ToList();
                        }
                        else
                        {
                            tasks = tasks.OrderByDescending(p => p.IsCompleted).ThenByDescending(p => p.Completeness).ThenBy(p => p.Name).ToList();
                        }
                        break;

                    case ProjectOrderBy.Deadline:
                        if (filter.Ascending)
                        {
                            tasks = tasks.OrderBy(p => p.VirtualDeadline).ThenBy(p => p.Name).ToList();
                        }
                        else
                        {
                            tasks = tasks.OrderBy(p => p.VirtualDeadline).ThenBy(p => p.Name).ToList();
                        }
                        break;

                    case ProjectOrderBy.EndDate:
                        if (filter.Ascending)
                        {
                            tasks = tasks.OrderBy(p => p.VirtualEndDate).ThenBy(p => p.Name).ToList();
                        }
                        else
                        {
                            tasks = tasks.OrderByDescending(p => p.VirtualEndDate).ThenBy(p => p.Name).ToList();
                        }
                        break;
                    }
                    break;

                case ItemsGroupBy.EndDate:
                    if (filter.Ascending)
                    {
                        tasks = tasks.OrderBy(p => p.VirtualEndDate).ThenBy(p => p.Name).ToList();
                    }
                    else
                    {
                        tasks = tasks.OrderByDescending(p => p.VirtualEndDate).ThenBy(p => p.Name).ToList();
                    }

                    break;

                case ItemsGroupBy.Community:
                    if (filter.Ascending)
                    {
                        tasks = tasks.OrderBy(p => p.ProjectInfo.VirtualCommunityName).ThenBy(p => p.VirtualDeadline).ToList();
                    }
                    else
                    {
                        tasks = tasks.OrderByDescending(p => p.ProjectInfo.VirtualCommunityName).ThenBy(p => p.VirtualDeadline).ToList();
                    }
                    break;

                case ItemsGroupBy.Project:
                    if (filter.Ascending)
                    {
                        tasks = tasks.OrderBy(p => p.ProjectInfo.VirtualProjectName).ThenBy(p => p.VirtualDeadline).ToList();
                    }
                    else
                    {
                        tasks = tasks.OrderByDescending(p => p.ProjectInfo.VirtualProjectName).ThenBy(p => p.VirtualDeadline).ToList();
                    }
                    break;
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
            return(tasks);
        }
Exemple #27
0
 public static String Dashboard(dtoProjectContext context, long idProject, Int32 idContainerCommunity, PageContainerType container, PageListType fromPage, PageListType toPage, SummaryTimeLine timeline, SummaryDisplay display, ProjectFilterBy filterBy, ItemsGroupBy groupBy, ItemListStatus status, UserActivityStatus actStatus = UserActivityStatus.Ignore, SummaryTimeLine actTimeline = SummaryTimeLine.Week)
 {
     return(Dashboard(new dtoDisplayTimelineContext(context, idContainerCommunity, container, fromPage, timeline, display, filterBy, groupBy, status), idProject, toPage, actStatus, actTimeline));
 }
        private List <dtoTasksGroup> GenerateEndDateTree(List <dtoPlainTask> tasks, String unknownUser, dtoProjectContext context, Int32 idContainerCommunity, dtoItemsFilter filter, PageContainerType container, PageListType fromPage, PageListType currentPage, SummaryTimeLine timeline, Int32 pageIndex, Int32 pageSize, PagerBase pager)
        {
            List <dtoTasksGroup> items = new List <dtoTasksGroup>();
            String cssClass            = View.GetContainerCssClass(ItemsGroupBy.EndDate);
            Int32  cCount = View.GetCellsCount(currentPage, ItemsGroupBy.EndDate);
            String sRow   = View.GetStartRowId(ItemsGroupBy.EndDate);

            Dictionary <TimeGroup, String> timeTranslations = View.GetTimeTranslations();
            List <dtoTimeGroup>            timegroups       = GetAvailableTimeGroups(tasks.Select(p => p.VirtualEndDate).ToList());

            foreach (dtoPlainTask p in tasks)
            {
                p.TimeGroup = GetTimeGroupByDate(timegroups, p.VirtualEndDate);
            }
            if (pageIndex == -1 && pager != null)
            {
                pageIndex       = GetCurrentPageIndex(pageSize, tasks);
                pager.PageIndex = pageIndex;// Me.View.CurrentPageIndex
                View.Pager      = pager;
            }
            String dateTimePattern = View.GetDateTimePattern();
            Dictionary <Int32, String> monthNames = View.GetMonthNames();

            if (tasks.Skip(pageIndex * pageSize).Take(pageSize).Any())
            {
                foreach (dtoTimeGroup t in GetAvailableTimeGroups(timegroups, tasks.Skip(pageIndex * pageSize).Take(pageSize).Select(p => p.VirtualEndDate).ToList()))
                {
                    items.Add(new dtoTasksGroup()
                    {
                        Id             = ((long)t.TimeLine),
                        Name           = GetTimeGroupDisplayName(timeTranslations[t.TimeLine], t, dateTimePattern, monthNames),
                        Tasks          = tasks.Where(p => p.VirtualEndDate.Ticks >= t.FromTicks && p.VirtualEndDate.Ticks <= t.ToTicks).ToList(),
                        CssClass       = cssClass,
                        CellsCount     = cCount,
                        IdRowFirstItem = sRow + tasks.Where(p => p.VirtualEndDate.Ticks >= t.FromTicks && p.VirtualEndDate.Ticks <= t.ToTicks).First().Id.ToString(),
                        IdRowLastItem  = sRow + tasks.Where(p => p.VirtualEndDate.Ticks >= t.FromTicks && p.VirtualEndDate.Ticks <= t.ToTicks).Last().Id.ToString(),
                        IdRow          = sRow + ((long)t.TimeLine).ToString(),
                        Time           = t
                    });
                }
                items.ForEach(i => UpdateGroups(i, ItemsGroupBy.EndDate, context, idContainerCommunity, filter, container, fromPage, currentPage, timeline));
                TimeGroup firstTimeGroup = items.First().Time.TimeLine;
                TimeGroup lastTimeGroup  = items.Last().Time.TimeLine;
                if (pageIndex > 0 && tasks.OrderBy(p => p.VirtualEndDate).Skip((pageIndex - 1) * pageSize).Where(p => p.TimeGroup.TimeLine == firstTimeGroup).Any())
                {
                    items.First().PreviousPageIndex = pageIndex - 1;
                }
                if (tasks.OrderBy(p => p.VirtualEndDate).Skip((pageIndex + 1) * pageSize).Where(p => p.TimeGroup.TimeLine == lastTimeGroup).Any())
                {
                    items.Last().NextPageIndex = pageIndex + 1;
                }
            }
            return(items);
        }