public void LoadCommunities(DashboardViewType view, UserCurrentSettings userSettings, Int32 pageIndex, Int32 pageSize, OrderItemsBy orderBy, Boolean ascending, Int32 idCommunityType = -1, Int32 idRemoveCommunityType = -1, long idTile = -1, long idTag = -1, dtoTileDisplay tile = null)
        {
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                if (View.DisplayLessCommand)
                {
                    Int32     itemsCount = Service.GetSubscribedCommunitiesCount(UserContext.CurrentUserID, view, idCommunityType, idRemoveCommunityType, idTile, idTag, tile);
                    PagerBase pager      = new PagerBase();
                    pager.PageSize  = pageSize;  //Me.View.CurrentPageSize
                    pager.Count     = (itemsCount > 0) ? itemsCount - 1 : 0;
                    pager.PageIndex = pageIndex; // Me.View.CurrentPageIndex
                    View.Pager      = pager;
                }
                List <dtoSubscriptionItem> items = Service.GetSubscribedCommunities(UserContext.CurrentUserID, view, pageIndex, pageSize, orderBy, ascending, idCommunityType, idRemoveCommunityType, idTile, idTag, tile);
                if (items != null)
                {
                    List <Int32> withNews = View.GetIdcommunitiesWithNews(items.Where(i => i.Status != SubscriptionStatus.communityblocked && i.Status != SubscriptionStatus.blocked && i.Status != SubscriptionStatus.waiting).Select(i => i.Community.Id).ToList(), UserContext.CurrentUserID);
                    if (withNews.Any())
                    {
                        items.Where(i => withNews.Contains(i.Community.Id)).ToList().ForEach(i => i.HasNews = true);
                    }
                    switch (view)
                    {
                    case DashboardViewType.List:
                    case DashboardViewType.Combined:
                        Language l = CurrentManager.GetDefaultLanguage();
                        Dictionary <Int32, List <String> > tags = ServiceTags.GetCommunityAssociationToString(items.Select(i => i.Community.Id).ToList(), UserContext.Language.Id, l.Id, true);
                        if (tags.Any())
                        {
                            foreach (dtoSubscriptionItem item in items.Where(i => tags.ContainsKey(i.Community.Id)))
                            {
                                item.Community.Tags = tags[item.Community.Id];
                            }
                        }
                        break;
                    }

                    View.LoadItems(items, orderBy, ascending);
                    if (userSettings != null)
                    {
                        userSettings.Ascending = ascending;
                        userSettings.OrderBy   = orderBy;
                        userSettings.View      = view;
                        View.UpdateUserSettings(userSettings);
                    }
                    //View.SendUserAction(0, CurrentIdModule, ModuleDashboard.ActionType.ListDashboardLoadSubscribedCommunities);
                }
                else
                {
                    View.DisplayErrorFromDB();
                }
            }
        }
Пример #2
0
        public void InitView(liteCommunityInfo community)
        {
            View.LoadUserInfo(Service.GetResponsible(community.Id), (community.IdCreatedBy > 0) ? CurrentManager.GetLitePerson(community.IdCreatedBy) : null);
            Int32         idLanguage = UserContext.Language.Id;
            Language      l          = CurrentManager.GetDefaultLanguage();
            List <String> tags       = ServiceTags.GetCommunityAssociationToString(community.Id, idLanguage, l.Id, true);

            if (tags != null && tags.Any())
            {
                View.LoadTags(tags, community.IdTypeOfCommunity);
            }

            List <dtoEnrollmentsDetailInfo> items = Service.GetEnrollmentsInfo(community.Id, community.IdTypeOfCommunity, UserContext.Language.Id);

            View.LoadEnrollmentsInfo(community, items, items.Select(i => i.Count).Sum(), Service.GetWaitingEnrollments(community.Id));
            View.LoadConstraints(Service.GetDtoCommunityConstraints(community.Id, UserContext.CurrentUserID));
            View.LoadDetails(community, Service.GetTranslatedCommunityType(idLanguage, community.IdTypeOfCommunity), Service.GetDescription(community.Id));
        }
        private void LoadCommunities(litePageSettings pageSettings, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters, OrderItemsBy orderBy, Boolean ascending, Boolean useCache, Int32 pageIndex = 0, Int32 pageSize = 0, ModuleDashboard.ActionType action = ModuleDashboard.ActionType.SearchDashboardApplyFilters)
        {
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                List <dtoSubscriptionItem> items = Service.GetCommunities(UserContext.CurrentUserID, filters, useCache);
                if (items == null)
                {
                    View.DisplayErrorFromDB();
                }
                else
                {
                    Int32 itemsCount = items.Count();

                    if (pageSettings != null)
                    {
                        View.DefaultPageSize = pageSettings.MaxItems;
                        InitializeColumns(filters);
                        pageSize             = InitializeSearchPageSize(pageSettings, itemsCount);
                        View.CurrentPageSize = pageSize;
                    }
                    if (pageSize == 0)
                    {
                        pageSize = View.CurrentPageSize;
                    }
                    PagerBase pager = new PagerBase();
                    pager.PageSize  = pageSize;
                    pager.Count     = (itemsCount > 0) ? itemsCount - 1 : 0;
                    pager.PageIndex = pageIndex;
                    View.Pager      = pager;


                    items = Service.GetCommunities(UserContext.Language.Id, items, pageIndex, pageSize, orderBy, ascending);

                    if (items != null)
                    {
                        List <Int32> withNews = View.GetIdcommunitiesWithNews(items.Where(i => i.Status != SubscriptionStatus.communityblocked && i.Status != SubscriptionStatus.blocked && i.Status != SubscriptionStatus.waiting).Select(i => i.Community.Id).ToList(), UserContext.CurrentUserID);
                        if (withNews.Any())
                        {
                            items.Where(i => withNews.Contains(i.Community.Id)).ToList().ForEach(i => i.HasNews = true);
                        }
                        Language l = CurrentManager.GetDefaultLanguage();
                        Dictionary <Int32, List <String> > tags = ServiceTags.GetCommunityAssociationToString(items.Select(i => i.Community.Id).ToList(), UserContext.Language.Id, l.Id, true);
                        if (tags.Any())
                        {
                            foreach (dtoSubscriptionItem item in items.Where(i => tags.ContainsKey(i.Community.Id)))
                            {
                                item.Community.Tags = tags[item.Community.Id];
                            }
                        }

                        View.LoadItems(items, orderBy, ascending);
                        //View.SendUserAction(0, CurrentIdModule, action);
                    }
                    else
                    {
                        View.LoadItems(new List <dtoSubscriptionItem>(), orderBy, ascending);
                    }
                }
            }
        }
        private void InternalLoadCommunities(Int32 itemsForPage, RangeSettings range, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters, OrderItemsToSubscribeBy orderBy, Boolean ascending, Boolean useCache, Int32 pageIndex, ModuleDashboard.ActionType action = ModuleDashboard.ActionType.EnrollPageApplyFilters, Boolean applyFilters = false)
        {
            View.CurrentFilters = filters;
            List <dtoItemFilter <OrderItemsToSubscribeBy> > orderItems = GetOrderByItems(filters.IdcommunityType, orderBy);

            View.InitializeOrderBySelector(orderItems);
            List <dtoEnrollingItem> items = Service.GetCommunitiesToEnroll(UserContext.CurrentUserID, filters, useCache);
            Int32 itemsCount = (items == null) ? 0 : items.Count;
            Int32 pageSize   = CalculatePageSize(itemsForPage, range, itemsCount);

            View.CurrentPageSize = pageSize;
            InitializeColumns(filters, items);

            if (items == null)
            {
                View.DisplayErrorFromDB();
                View.CurrentOrderBy   = orderBy;
                View.CurrentAscending = ascending;
            }
            else
            {
                if (pageSize == 0)
                {
                    pageSize = View.DefaultPageSize;
                }
                PagerBase pager = new PagerBase();
                pager.PageSize  = pageSize;
                pager.Count     = (itemsCount > 0) ? itemsCount - 1 : 0;
                pager.PageIndex = pageIndex;
                View.Pager      = pager;
                List <dtoCommunityToEnroll> cItems = null;
                if (applyFilters)
                {
                    cItems = new List <dtoCommunityToEnroll>();
                }
                else
                {
                    cItems = View.CurrentSelectedItems;
                    List <dtoCommunityToEnroll> sItems = View.GetSelectedItems();
                    if (sItems.Where(i => !i.Selected).Any())
                    {
                        cItems = cItems.Where(c => !sItems.Where(s => s.Id == c.Id).Any() || sItems.Where(s => s.Selected && s.Id == c.Id).Any()).ToList();
                    }
                    if (sItems.Where(i => i.Selected).Any())
                    {
                        List <Int32> idCommunities = cItems.Select(c => c.Id).ToList();
                        cItems.AddRange(sItems.Where(s => s.Selected && !idCommunities.Contains(s.Id)).ToList());
                    }
                }
                View.CurrentSelectedItems = cItems;
                View.KeepOpenBulkActions  = (cItems.Count > 0);
                View.InitializeBulkActions(itemsCount > pageSize, cItems);
                items = Service.GetCommunities(UserContext.CurrentUserID, items, pageIndex, pageSize, orderBy, ascending);

                if (items != null)
                {
                    Language l = CurrentManager.GetDefaultLanguage();
                    Dictionary <Int32, List <String> > tags = ServiceTags.GetCommunityAssociationToString(items.Select(i => i.Community.Id).ToList(), UserContext.Language.Id, l.Id, true);
                    if (tags.Any())
                    {
                        foreach (dtoEnrollingItem item in items.Where(i => tags.ContainsKey(i.Community.Id)))
                        {
                            item.Community.Tags = tags[item.Community.Id];
                        }
                    }

                    View.LoadItems(items, orderBy, ascending);
                    //View.SendUserAction(0, CurrentIdModule, action);
                }
                else
                {
                    View.LoadItems(new List <dtoEnrollingItem>(), orderBy, ascending);
                }
            }
        }