public void BulkInsert(dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize, List <Dictionary <Int32, String> > toInsert) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { ModuleTags.ActionType action = ModuleTags.ActionType.GenericError; List <Dictionary <Int32, String> > notInserted = new List <Dictionary <int, string> >(); List <TagItem> tags = ServiceTags.BulkInsert(TagType.Community, (idCommunity == 0), idCommunity, toInsert, notInserted); if (tags.Any()) { if (notInserted.Any()) { action = (filters.ForOrganization) ? ModuleTags.ActionType.AddedBulkTagsToOrganizationWithDuplicates : ModuleTags.ActionType.AddedBulkTagsToPortalWithDuplicates; View.DisplayMessage(action, notInserted.Select(i => i[0]).ToList()); } else { action = (filters.ForOrganization) ? ModuleTags.ActionType.AddedBulkTagsToOrganization : ModuleTags.ActionType.AddedBulkTagsToPortal; View.DisplayMessage(action); } } else { action = (filters.ForOrganization) ? ModuleTags.ActionType.UnableToAddBulkTagsToOrganization : ModuleTags.ActionType.UnableToAddBulkTagsToPortal; View.DisplayMessage(action); } View.SendUserAction((filters.ForOrganization) ? idCommunity : 0, CurrentIdModule, action); LoadTags(filters, idCommunity, 0, pageSize); } }
private void SetTagsInfo(dtoFilters filters, Int32 idCommunity) { Int32 idOrganization = 0; Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); lm.Comol.Core.DomainModel.Domain.ModuleCommunityManagement permissions = null; if (filters.ForOrganization) { if (idCommunity == 0) { idCommunity = UserContext.CurrentCommunityID; idOrganization = CurrentManager.GetIdOrganizationFromCommunity(idCommunity); } if (idOrganization == 0) { idOrganization = CurrentManager.GetUserDefaultIdOrganization(UserContext.CurrentUserID); idCommunity = CurrentManager.GetIdCommunityFromOrganization(idOrganization); } permissions = new DomainModel.Domain.ModuleCommunityManagement(CurrentManager.GetModulePermission(UserContext.CurrentUserID, idCommunity, lm.Comol.Core.DomainModel.Domain.ModuleCommunityManagement.UniqueID)); } else { permissions = DomainModel.Domain.ModuleCommunityManagement.CreatePortalmodule((p == null) ? (Int32)UserTypeStandard.Guest : p.TypeID); } Int32 noTags = ServiceTags.GetCommunitiesWithNoTags(); String url = ""; if (permissions.Administration || permissions.Manage) { url = RootObject.BulkTagsAssignment(idOrganization, !filters.ForOrganization, true); } View.LoadTagsInfo(noTags, ServiceTags.GetUntranslatedTagsCount(filters.IdSelectedLanguage, false), 0, url); }
public void RenewPassword(int IdUser) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { dtoFilters filters = View.GetCurrentFilters; String newPassword = ""; Person person = CurrentManager.GetPerson(IdUser); if (person != null) { InternalLoginInfo internalLogin = Service.RenewPassword(IdUser, ref newPassword); if (!String.IsNullOrEmpty(newPassword) && internalLogin != null) { if (View.SendMail(internalLogin, newPassword)) { View.DisplayPasswordChanged(person.SurnameAndName); } else { View.DisplayUnableToSendPassword(person.SurnameAndName); } } else { View.DisplayUnableToChangePassword(person.SurnameAndName); } } SearchProfiles(filters.PageIndex, filters.PageSize); } }
public void ApplyFilters(dtoFilters filters, Int32 idCommunity, Int32 pageSize) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { LoadTags(filters, idCommunity, 0, pageSize); } }
private void InitializeView(dtoFilters filters, Int32 idCommunity) { View.IdSelectedTagLanguage = -1; List <lm.Comol.Core.Dashboard.Domain.dtoItemFilter <lm.Comol.Core.DomainModel.Languages.dtoLanguageItem> > languages = ServiceTags.GetLanguageSelectorItems(View.GetDefaultLanguageName(), View.GetDefaultLanguageCode()); View.LoadLanguages(languages); View.FirstLoad = true; View.FirstLoadForLanguages = languages.ToDictionary(l => l.Value.IdLanguage, l => true); View.CurrentFilters = filters; LoadTags(filters, idCommunity, 0, View.CurrentPageSize); }
public void InitView(ModuleTags permissions, Int32 idCommunity, Boolean fromRecycleBin = false, Boolean fromOrganization = false) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { View.IdTagsCommunity = idCommunity; dtoFilters filters = new dtoFilters(fromOrganization); filters.FromRecycleBin = fromRecycleBin; InitializeView(filters, idCommunity); } }
public void ActivateProfile(int IdUser) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { dtoFilters filters = View.GetCurrentFilters; Person person = CurrentManager.GetPerson(IdUser); if (person != null) { View.DisplayProfileActivated(Service.ActivateProfile(IdUser), person.SurnameAndName); } SearchProfiles(filters.PageIndex, filters.PageSize); } }
public void LoadTiles(dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); if (filters.DashboardType == DashboardType.Community && idCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idCommunity); } LoadTiles(permissions, filters, idCommunity, pageIndex, pageSize); } }
public void VirtualDelete(long idTile, Boolean delete, dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { ModuleDashboard.ActionType action = (delete) ? ModuleDashboard.ActionType.TileVirtualDelete : ModuleDashboard.ActionType.TileVirtualUndelete; Tile item = Service.TileVirtualDelete(idTile, delete); if (item == null) { action = (delete) ? ModuleDashboard.ActionType.TileUnableToVirtualDelete : ModuleDashboard.ActionType.TileUnableToUndelete; } View.DisplayMessage(action); View.SendUserAction((filters.DashboardType == DashboardType.Community) ? idCommunity : 0, CurrentIdModule, idTile, action); LoadTiles(filters, idCommunity, 0, pageSize); } }
public void SetStatus(long idTile, AvailableStatus status, dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { ModuleDashboard.ActionType action = (status == AvailableStatus.Available) ? ModuleDashboard.ActionType.TileEnable : ModuleDashboard.ActionType.TileDisable; Tile item = Service.TileSetStatus(idTile, status); if (item == null || item.Status != status) { action = (status == AvailableStatus.Available) ? ModuleDashboard.ActionType.TileUnableToEnable : ModuleDashboard.ActionType.TileUnableToDisable; } View.DisplayMessage(action); View.SendUserAction((filters.DashboardType == DashboardType.Community) ? idCommunity : 0, CurrentIdModule, idTile, action); LoadTiles(filters, idCommunity, 0, pageSize); } }
public void VirtualDelete(long idTag, Boolean delete, dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { ModuleTags.ActionType action = (delete) ? ModuleTags.ActionType.VirtualDelete : ModuleTags.ActionType.VirtualUndelete; TagItem item = ServiceTags.VirtualDelete(idTag, delete); if (item == null) { action = (delete) ? ModuleTags.ActionType.UnableToDelete : ModuleTags.ActionType.UnableToUndelete; } View.DisplayMessage(action); View.SendUserAction((filters.ForOrganization) ? idCommunity : 0, CurrentIdModule, idTag, action); LoadTags(filters, idCommunity, 0, pageSize); } }
private Boolean HasEmployeeUsers(UserSelectionType mode) { switch (mode) { case UserSelectionType.CommunityUsers: dtoUserFilters filter = (dtoUserFilters)View.GetCurrentUserFilters.Clone(); filter.IdProfileType = (int)UserTypeStandard.Employee; filter.IdRole = -1; filter.IdAgency = -1; return((int)Service.CommunitySubscriptionsCount(filter, View.UnavailableIdUsers) > 0); case UserSelectionType.SystemUsers: dtoFilters pFilter = (dtoFilters)View.GetCurrentProfileFilters.Clone(); pFilter.IdProfileType = (int)UserTypeStandard.Employee; pFilter.IdAgency = -1; return(Service.ProfilesCount(pFilter, View.UnavailableIdUsers) > 0); default: return(false); } }
private void InitializeProfileFilters(ModuleProfileManagement module) { View.OrderAscending = true; View.OrderProfilesBy = OrderProfilesBy.SurnameAndName; Int32 idDefaultProfileType = 0; long idDefaultAgency = 0; long idDefaultProvider = 0; Int32 idDefaultOrganization = 0; StatusProfile defaultStatus = StatusProfile.Active; SearchProfilesBy defaultSearch = SearchProfilesBy.Contains; List <Organization> organizations = Service.GetAvailableOrganizations(UserContext.CurrentUserID, (module.ViewProfiles || module.Administration) ? SearchCommunityFor.SystemManagement : SearchCommunityFor.CommunityManagement); if (organizations.Any() || module.Administration || module.ViewProfiles) { View.LoadAvailableOrganizations(organizations, idDefaultOrganization); View.LoadProfileTypes(Service.GetAvailableProfileTypes(View.SelectedIdOrganization), idDefaultProfileType); List <dtoBaseProvider> providers = Service.GetAuthenticationProviders(UserContext.Language.Id, true).Where(p => p.isEnabled).ToList(); View.LoadAuthenticationProviders(providers, idDefaultProvider); View.LoadAvailableStatus(Service.GetAvailableStatus(View.SelectedIdOrganization, View.SelectedIdProfileType), defaultStatus); View.LoadSearchProfilesBy(GetSearchByItems(module), defaultSearch, UserSelectionType.SystemUsers); if (idDefaultProfileType == (int)UserTypeStandard.Employee) { View.LoadAgencies(Service.GetAvailableAgencies(View.SelectedIdOrganization), idDefaultAgency, UserSelectionType.SystemUsers); } dtoFilters filter = View.GetCurrentProfileFilters; View.SearchProfileFilters = filter; View.InitializeWordSelector(Service.GetAvailableStartLetter(filter, View.UnavailableIdUsers)); SetDefaultColumns(filter.IdProfileType, module.Administration || module.ViewProfiles, filter.Status); View.LoadProfiles(new List <dtoProfileItem <dtoBaseProfile> >()); } else { View.NoPermission(); } }
public void LoadTags(dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { SetTagsInfo(filters, idCommunity); List <dtoTagItem> items = ServiceTags.GetTags(UserContext.CurrentUserID, TagType.Community, filters, idCommunity, View.GetUnknownUserName()); if (items == null) { View.DisplayErrorLoadingFromDB(); } else { Int32 itemsCount = items.Count(); PagerBase pager = new PagerBase(); pager.PageSize = pageSize; pager.Count = (itemsCount > 0) ? itemsCount - 1 : 0; pager.PageIndex = pageIndex; View.Pager = pager; String dCode = View.GetDefaultLanguageCode(); String dLanguage = View.GetDefaultLanguageName(); items = items.Skip(pager.PageIndex * pageSize).Take(pageSize).ToList(); View.AllowApplyFilters(!(View.FirstLoad && !items.Any())); items.ForEach(i => i.Translations.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem() { IdLanguage = -1, IsMultiLanguage = true, LanguageCode = dCode, LanguageName = dLanguage })); View.LoadTags(items, filters.IdSelectedLanguage); View.SendUserAction((filters.ForOrganization) ? idCommunity : 0, CurrentIdModule, (filters.IdOrganization > -3) ? ModuleTags.ActionType.OrganizationListTags : ModuleTags.ActionType.PortalListTags); View.FirstLoad = false; View.FirstLoadForLanguages[filters.IdSelectedLanguage] = false; } } }
public void SetStatus(long idTag, lm.Comol.Core.Dashboard.Domain.AvailableStatus status, dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { ModuleTags.ActionType action = (status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available) ? ModuleTags.ActionType.EnableTag : ModuleTags.ActionType.DisableTag; TagItem item = ServiceTags.SetStatus(idTag, status); if (item == null || item.Status != status) { action = (status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available) ? ModuleTags.ActionType.UnableToEnableTag : ModuleTags.ActionType.UnableToDisableTag; } View.DisplayMessage(action); View.SendUserAction((filters.ForOrganization) ? idCommunity : 0, CurrentIdModule, idTag, action); LoadTags(filters, idCommunity, 0, pageSize); } }
public void LoadProfiles(int currentPageIndex, int currentPageSize, Boolean updateSelection) { List <Int32> idRemoveUsers = View.UnavailableIdUsers; dtoFilters filters = View.SearchProfileFilters; PagerBase pager = new PagerBase(); //if (filters.StartWith != View.CurrentStartWith) // filters.StartWith = View.CurrentStartWith; pager.PageSize = currentPageSize; //Me.View.CurrentPageSize pager.Count = (int)Service.ProfilesCount(filters, idRemoveUsers) - 1; pager.PageIndex = currentPageIndex; // Me.View.CurrentPageIndex View.Pager = pager; View.IsFirstLoad = false; //List<lm.Comol.Core.DomainModel.Helpers.AlphabetItem> aItems = ; //if (aItems.Where(i => i.Value == View.CurrentStartWith && i.isEnabled).Any()) // aItems.Where(i => i.Value == View.CurrentStartWith && i.isEnabled).FirstOrDefault().isSelected = true; //else if (aItems.Where(i => i.Value == View.CurrentStartWith && !i.isEnabled).Any()) //{ // aItems.Where(i => i.Type == DomainModel.Helpers.AlphabetItemType.all).FirstOrDefault().isSelected = true; // View.CurrentStartWith= ""; // filters.StartWith = ""; //} if (updateSelection) { View.SelectedIdUsers = UpdateItemsSelection(); } View.InitializeWordSelector(Service.GetAvailableStartLetter(filters, idRemoveUsers), filters.StartWith); filters.StartWith = View.CurrentStartWith; ModuleProfileManagement module = ModuleProfileManagement.CreatePortalmodule(UserContext.UserTypeID); List <dtoBaseProvider> providers = Service.GetAuthenticationProviders(UserContext.Language.Id, true); List <ProfileColumn> columns = SetDefaultColumns(filters.IdProfileType, module.Administration || module.ViewProfiles, filters.Status); if (View.SelectedIdProfileType != (int)UserTypeStandard.Employee) { View.UnLoadAgencies(); } switch (filters.IdProfileType) { case (int)UserTypeStandard.Company: List <dtoProfileItem <dtoCompany> > companyUsers = Service.GetCompanyUserProfiles(filters, pager.PageIndex, currentPageSize, View.GetTranslatedProfileTypes, providers, idRemoveUsers); if (companyUsers.Where(i => i.Id == UserContext.CurrentUserID).Any()) { companyUsers.Where(i => i.Id == UserContext.CurrentUserID).ToList().ForEach(i => i.Permission.LogonAs = false); } View.LoadProfiles(companyUsers); break; case (int)UserTypeStandard.Employee: List <dtoProfileItem <dtoEmployee> > employeeUsers = Service.GetEmployeeProfiles(filters, pager.PageIndex, currentPageSize, View.GetTranslatedProfileTypes, providers, idRemoveUsers); if (employeeUsers.Where(i => i.Id == UserContext.CurrentUserID).Any()) { employeeUsers.Where(i => i.Id == UserContext.CurrentUserID).ToList().ForEach(i => i.Permission.LogonAs = false); } View.LoadProfiles(employeeUsers); break; //case (int)UserTypeStandard.ExternalUser: // List<dtoProfileItem<dtoExternal>> externalUsers = Service.GetEmployeeProfiles(filters, pager.PageIndex, currentPageSize, View.GetTranslatedProfileTypes, providers); // if (!columns.Contains(ProfileColumn.login)) // View.AvailableLogins = Service.GetProfilesLogin(externalUsers.Select(i => i.Profile.Id).ToList()); // if (externalUsers.Where(i => i.Id == UserContext.CurrentUserID).Any()) // externalUsers.Where(i => i.Id == UserContext.CurrentUserID).ToList().ForEach(i => i.Permission.LogonAs = false); // View.LoadProfiles(externalUsers); // break; //case (int)UserTypeStandard.Undergraduate: default: List <dtoProfileItem <dtoBaseProfile> > items = Service.GetProfiles(filters, pager.PageIndex, currentPageSize, View.GetTranslatedProfileTypes, providers, idRemoveUsers); View.LoadProfiles(items); break; } }
private void InitializeFilters() { View.OrderAscending = true; View.OrderBy = OrderProfilesBy.SurnameAndName; Boolean loadFilters = View.PreloadedReloadFilters; dtoFilters filters = null; if (loadFilters) { filters = View.GetSavedFilters; } Int32 idDefaultProfileType = 0; long idDefaultProvider = 0; long idDefaultAgency = 0; Int32 idDefaultOrganization = 0; StatusProfile defaultStatus = StatusProfile.Active; SearchProfilesBy defaultSearch = SearchProfilesBy.Contains; View.CurrentModuleView = View.PreLoadedView; View.CurrentModuleCode = View.PreLoadedModuleCode; int pageIndex = 0; if (loadFilters && filters != null) { idDefaultOrganization = filters.IdOrganization; idDefaultProfileType = filters.IdProfileType; idDefaultProvider = filters.idProvider; if (idDefaultProfileType == (int)UserTypeStandard.Employee) { idDefaultAgency = filters.IdAgency; } defaultStatus = filters.Status; defaultSearch = filters.SearchBy; if (!String.IsNullOrEmpty(filters.StartWith) && !Service.DefaultChars().Contains(filters.StartWith)) { filters.StartWith = "#"; } View.CurrentStartWith = filters.StartWith; View.CurrentValue = filters.Value; View.OrderAscending = filters.Ascending; View.OrderBy = filters.OrderBy; pageIndex = filters.PageIndex; View.CurrentPageSize = filters.PageSize; } else { View.CurrentPageSize = View.PreLoadedPageSize; } List <Organization> organizations = Service.GetAvailableOrganizations(UserContext.CurrentUserID, (View.CurrentModuleIdCommunity < 1) ? SearchCommunityFor.SystemManagement : SearchCommunityFor.CommunityManagement); if (organizations != null && organizations.Any()) { View.LoadAvailableOrganizations(organizations, idDefaultOrganization); View.LoadProfileTypes(Service.GetAvailableProfileTypes(View.SelectedIdOrganization), idDefaultProfileType); List <dtoBaseProvider> providers = Service.GetAuthenticationProviders(UserContext.Language.Id, true).Where(p => p.isEnabled).ToList(); View.LoadAvailableStatus(Service.GetAvailableStatus(View.SelectedIdOrganization, View.SelectedIdProfileType), defaultStatus); View.LoadSearchProfilesBy(GetSearchByItems(), defaultSearch); if (idDefaultProfileType == (int)UserTypeStandard.Employee) { View.LoadAgencies(Service.GetAvailableAgencies(View.SelectedIdOrganization), idDefaultAgency); } View.SearchFilters = View.GetCurrentFilters; if (loadFilters && filters != null) { LoadProfiles(filters.PageIndex, filters.PageSize); } else if (filters == null) { View.InitializeWordSelector(Service.GetAvailableStartLetter(View.GetCurrentFilters)); } } else { View.NoPermissionToAdmin(); } }
public void LoadProfiles(int currentPageIndex, int currentPageSize) { dtoFilters filters = View.SearchFilters; List <String> availableLetters = Service.GetAvailableStartLetter(filters); PagerBase pager = new PagerBase(); if (filters.StartWith != View.CurrentStartWith) { filters.StartWith = View.CurrentStartWith; } if (filters.StartWith != "" && !availableLetters.Contains(filters.StartWith)) { filters.StartWith = (availableLetters.Count > 0) ? availableLetters.FirstOrDefault() : ""; } pager.PageSize = currentPageSize; //Me.View.CurrentPageSize pager.Count = (int)Service.ProfilesCount(filters) - 1; pager.PageIndex = currentPageIndex; // Me.View.CurrentPageIndex View.Pager = pager; View.InitializeWordSelector(Service.GetAvailableStartLetter(filters), filters.StartWith); //if (view == UserCallForPaperStatus.Evaluated || view == UserCallForPaperStatus.ToEvaluate) // View.LoadCallForPapersForEvaluation(Service.CallForPaperForEvaluation(CommunityId, UserContext.CurrentUserID, view, currentPageIndex, currentPageSize)); //else // View.LoadCallForPapers(Service.UserCallForPapers(CommunityId, UserContext.CurrentUserID, view, currentPageIndex, currentPageSize)); //View.ActionListView(CommunityId, ModuleID); List <dtoBaseProvider> providers = Service.GetAuthenticationProviders(UserContext.Language.Id, true); List <ProfileColumn> columns = SetDefaultColumns(filters.IdProfileType, (from p in providers where p.IdProvider == filters.idProvider select p.Type).FirstOrDefault()); if (filters.IdProfileType != (int)UserTypeStandard.Employee) { View.UnLoadAgencies(); } switch (filters.IdProfileType) { case (int)UserTypeStandard.Company: List <dtoProfileItem <dtoCompany> > companyUsers = Service.GetCompanyUserProfiles(filters, pager.PageIndex, currentPageSize, View.GetTranslatedProfileTypes, providers); if (companyUsers.Where(i => i.Id == UserContext.CurrentUserID).Any()) { companyUsers.Where(i => i.Id == UserContext.CurrentUserID).ToList().ForEach(i => i.Permission.LogonAs = false); } View.LoadProfiles(companyUsers); break; case (int)UserTypeStandard.Employee: List <dtoProfileItem <dtoEmployee> > employeeUsers = Service.GetEmployeeProfiles(filters, pager.PageIndex, currentPageSize, View.GetTranslatedProfileTypes, providers); if (employeeUsers.Where(i => i.Id == UserContext.CurrentUserID).Any()) { employeeUsers.Where(i => i.Id == UserContext.CurrentUserID).ToList().ForEach(i => i.Permission.LogonAs = false); } View.LoadProfiles(employeeUsers); break; //case (int)UserTypeStandard.ExternalUser: // List<dtoProfileItem<dtoExternal>> externalUsers = Service.GetEmployeeProfiles(filters, pager.PageIndex, currentPageSize, View.GetTranslatedProfileTypes, providers); // if (!columns.Contains(ProfileColumn.login)) // View.AvailableLogins = Service.GetProfilesLogin(externalUsers.Select(i => i.Profile.Id).ToList()); // if (externalUsers.Where(i => i.Id == UserContext.CurrentUserID).Any()) // externalUsers.Where(i => i.Id == UserContext.CurrentUserID).ToList().ForEach(i => i.Permission.LogonAs = false); // View.LoadProfiles(externalUsers); // break; //case (int)UserTypeStandard.Undergraduate: default: List <dtoProfileItem <dtoBaseProfile> > items = Service.GetProfiles(filters, pager.PageIndex, currentPageSize, View.GetTranslatedProfileTypes, providers); if (items.Where(i => i.Id == UserContext.CurrentUserID).Any()) { items.Where(i => i.Id == UserContext.CurrentUserID).ToList().ForEach(i => i.Permission.LogonAs = false); } View.LoadProfiles(items); break; } }
public void LoadTiles(ModuleDashboard permissions, dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize, long idTile = 0) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { if (filters.DashboardType == DashboardType.Portal) { View.LoadTilesInfo(Service.GetCommunityTypesWithoutTilesCount(), Service.GetUntranslatedTilesCount(filters)); } else { View.LoadTilesInfo(Service.GetUntranslatedTilesCount(filters)); } List <dtoTileItem> items = Service.GetTiles(UserContext.CurrentUserID, permissions, filters, View.GetUnknownUserName(), View.GetTranslatedTileTypes()); if (items == null) { View.DisplayErrorLoadingFromDB(); } else { Int32 itemsCount = items.Count(); PagerBase pager = new PagerBase(); pager.PageSize = pageSize; pager.Count = (itemsCount > 0) ? itemsCount - 1 : 0; if (pageIndex == 0 && idTile > 0 && items.Where(i => i.Id == idTile).Any()) { while (items.Skip(pageIndex * pageSize).Take(pageSize).Any() && !items.Skip(pageIndex * pageSize).Take(pageSize).Where(i => i.Id == idTile).Any()) { pageIndex++; } if (pageIndex > pager.LastPage - 1) { pageIndex = 0; } else if (pageIndex == pager.LastPage - 1 && !items.Skip(pageIndex * pageSize).Take(pageSize).Where(i => i.Id == idTile).Any()) { pageIndex = 0; } } pager.PageIndex = pageIndex; View.Pager = pager; String dCode = View.GetDefaultLanguageCode(); String dLanguage = View.GetDefaultLanguageName(); if (pageIndex == 0 && idTile > 0) { items = items.Skip(pager.PageIndex * pageSize).Take(pageSize).ToList(); } else { items = items.Skip(pager.PageIndex * pageSize).Take(pageSize).ToList(); } View.AllowApplyFilters(!(View.FirstLoad && !items.Any())); items.ForEach(i => i.Translations.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem() { IdLanguage = -1, IsMultiLanguage = true, LanguageCode = dCode, LanguageName = dLanguage })); ModuleDashboard.ActionType action = ModuleDashboard.ActionType.TilesPortalDashboardList; switch (filters.DashboardType) { case DashboardType.AllCommunities: action = ModuleDashboard.ActionType.TilesAllCommunitiesList; break; case DashboardType.Community: action = ModuleDashboard.ActionType.TilesCommunityList; break; } View.LoadTiles(items, filters.IdSelectedLanguage); View.SendUserAction((filters.DashboardType == DashboardType.Community) ? idCommunity : 0, CurrentIdModule, action); View.FirstLoad = false; View.FirstLoadForLanguages[filters.IdSelectedLanguage] = false; } } }
public void GenerateCommunityTypeTiles(dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { ModuleDashboard.ActionType action = ModuleDashboard.ActionType.TileAutoGenerateForCommunityTypes; Int32 count = Service.GetCommunityTypesWithoutTilesCount(); if (count == 0) { action = ModuleDashboard.ActionType.TileAlreadyGeneratedForCommunityTypes; } else { List <Tile> tiles = Service.GenerateCommunityTypesTile(); if (tiles == null || tiles.Count != count) { action = ModuleDashboard.ActionType.TileUnableAutoGenerateForCommunityTypes; } else { View.HideCommunityTypesTileAutoGenerate(Service.GetCommunityTypesWithoutTilesCount() == 0); } } View.DisplayMessage(action); View.SendUserAction((filters.DashboardType == DashboardType.Community) ? idCommunity : 0, CurrentIdModule, action); Dictionary <searchFilterType, long> defaultValues = (from searchFilterType n in Enum.GetValues(typeof(searchFilterType)).AsQueryable() where n != searchFilterType.none select n).ToDictionary(t => t, t => (long)-1); if (filters.IdTileType != (long)TileType.CommunityType && filters.IdTileType != -1) { filters.IdTileType = (long)TileType.CommunityType; filters.StartWith = ""; filters.IdModifiedBy = UserContext.CurrentUserID; filters.Status = AvailableStatus.Available; } defaultValues[searchFilterType.type] = filters.IdTileType; defaultValues[searchFilterType.status] = (long)filters.Status; defaultValues[searchFilterType.modifiedby] = (long)filters.IdModifiedBy; long letter = -1; switch (filters.StartWith) { case "#": letter = -9; break; case "": break; default: letter = (long)filters.StartWith[0]; break; } defaultValues[searchFilterType.letters] = letter; List <lm.Comol.Core.DomainModel.Filters.Filter> nfilters = Service.GetDefaultFilters(DashboardType.Portal, UserContext.CurrentUserID, idCommunity, -1, idCommunity, false, defaultValues).OrderBy(f => f.DisplayOrder).ToList(); View.LoadDefaultFilters(nfilters); LoadTiles(filters, idCommunity, 0, pageSize); } }