public void PreviewMessage(dtoManagerTemplateMail template, String fakeName, String fakeSurname, String fakeTaxCode, String fakeMail, lm.Comol.Core.MailCommons.Domain.Configurations.SmtpServiceConfig smtpConfig, String websiteUrl, Dictionary <SubmissionTranslations, string> translations)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         Language   dLanguage   = CurrentManager.GetDefaultLanguage();
         litePerson currentUser = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
         litePerson fakeUser    = new litePerson();
         fakeUser.TypeID     = (int)UserTypeStandard.Student;
         fakeUser.Name       = fakeName;
         fakeUser.Surname    = fakeSurname;
         fakeUser.Mail       = fakeMail;
         fakeUser.TaxCode    = fakeTaxCode;
         fakeUser.LanguageID = currentUser.LanguageID;
         lm.Comol.Core.Mail.dtoMailMessage message = CallService.GetMailPreview(View.IdCall, template, currentUser, smtpConfig, websiteUrl, translations);
         String recipients = template.NotifyTo;
         if (String.IsNullOrEmpty(recipients))
         {
             recipients = currentUser.Mail;
         }
         else if (recipients.Contains(","))
         {
             recipients = recipients.Replace(",", ";");
         }
         View.DisplayMessagePreview(new lm.Comol.Core.Mail.dtoMailMessagePreview(currentUser.LanguageID, dLanguage, message, template.MailSettings, smtpConfig), recipients);
     }
 }
        private void SendMailToProfiles(List <ProfileImportAction> actions, List <dtoImportedProfile> profiles, lm.Comol.Core.Mail.dtoMailContent mailContent, List <ProfileAttributeType> attributes, List <dtoImportedProfile> notSentMail)
        {
            Int32   index       = 1;
            Boolean mailSent    = false;
            Int32   actionIndex = actions.Count() - ((actions.Contains(ProfileImportAction.AddToOtherOrganizations) || actions.Contains(ProfileImportAction.AddToCommunities)) ? 1 : 0);
            Person  currentUser = CurrentManager.GetPerson(UserContext.CurrentUserID);

            lm.Comol.Core.Mail.MailService mailService = new lm.Comol.Core.Mail.MailService(View.CurrentSmtpConfig, mailContent.Settings);
            Language dLanguage = CurrentManager.GetDefaultLanguage();

            foreach (dtoImportedProfile profile in profiles)
            {
                if (currentUser != null)
                {
                    lm.Comol.Core.Mail.dtoMailMessage message = new lm.Comol.Core.Mail.dtoMailMessage(mailContent.Subject, AnalyzeBody(mailContent.Body, profile, attributes));
                    message.FromUser = new System.Net.Mail.MailAddress(currentUser.Mail, currentUser.SurnameAndName);
                    message.To.Add(new System.Net.Mail.MailAddress(profile.Profile.Mail, profile.Profile.DisplayName));
                    //'dtoMessage.To.Add()
                    mailSent = (mailService.SendMail(currentUser.LanguageID, dLanguage, message) == Mail.MailException.MailSent);
                }
                else
                {
                    View.UpdateSendMailToProfile(actionIndex, profiles.Count, index, mailSent, profile.Profile.DisplayName);
                }

                if (!mailSent)
                {
                    notSentMail.Add(profile);
                }
                index++;
            }
        }
Example #3
0
        private void SetSkinDetails(Int32 idUser, long idCall)
        {
            Language   language = CurrentManager.GetDefaultLanguage();
            litePerson person   = GetCurrentUser(ref idUser);

            View.IdUserSubmitter = idUser;
            if (language != null)
            {
                View.DefaultLanguageCode = language.Code;
            }
            if (idUser == UserContext.CurrentUserID || person == null || UserContext.CurrentUserID == 0)
            {
                View.UserLanguageCode = UserContext.Language.Code;
            }
            else if (person != null)
            {
                language = CurrentManager.GetLanguage(person.LanguageID);
                if (language != null)
                {
                    View.UserLanguageCode = language.Code;
                }
                else
                {
                    View.UserLanguageCode = UserContext.Language.Code;
                }
            }
            else
            {
                View.UserLanguageCode = UserContext.Language.Code;
            }

            View.SkinDetails = ServiceCall.GetUserExternalContext(idCall, GetCurrentUser(ref idUser));
        }
Example #4
0
        public void InitView(PreviewMode pMode, String languageCode, lm.Comol.Core.DomainModel.Languages.ItemObjectTranslation content, SmtpServiceConfig smtpConfig, String recipients = "", List <String> modules = null, MessageSettings settings = null, Int32 idCommunity = -1, ModuleObject obj = null)
        {
            View.DisplayOptions = (pMode == PreviewMode.MailSent);
            Person person = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (!UserContext.isAnonymous && person != null)
            {
                View.isInitialized = true;
                switch (pMode)
                {
                case PreviewMode.TemplateDisplay:
                case PreviewMode.MailToSend:
                    if (String.IsNullOrEmpty("recipients"))
                    {
                        recipients = person.Mail;
                    }
                    View.AllowSendMail = settings != null && View.AllowSendMail && (View.EditAddressTo || !String.IsNullOrEmpty(recipients));
                    Language dLanguage = CurrentManager.GetDefaultLanguage();
                    Language language  = CurrentManager.GetLanguageByCodeOrDefault(languageCode, true);
                    if (modules != null)
                    {
                        String    organizationName = "";
                        Community community        = null;
                        if (idCommunity > 0)
                        {
                            community = CurrentManager.GetCommunity(idCommunity);
                            if (community != null)
                            {
                                organizationName = CurrentManager.GetOrganizationName(community.Id);
                            }
                        }
                        if (community != null && idCommunity > 0)
                        {
                            content = View.ParseContent((language == null) ? 0 : language.Id, languageCode, content, modules, community, person, organizationName, obj);
                        }
                        else
                        {
                            content = View.ParseContent((language == null) ? 0 : language.Id, languageCode, content, modules, idCommunity, (community == null || idCommunity < 1) ? View.GetPortalName((language != null) ? language.Id : 0) : community.Name, person, organizationName, obj);
                        }
                    }
                    if (settings != null)
                    {
                        dtoMailMessagePreview dtoContent = new dtoMailMessagePreview((language != null) ? language.Id : 0, dLanguage, new dtoMailMessage()
                        {
                            UserSubject = content.Subject, Body = content.Body
                        }, settings, smtpConfig);
                        View.LoadPreviewTemplateMessage(pMode, dtoContent, recipients);
                    }
                    else
                    {
                        View.LoadPreviewTemplateMessage(pMode, content);
                    }
                    break;
                }
            }
            else
            {
                View.HideContent();
            }
        }
Example #5
0
        public void ChangeType(TileType type)
        {
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                View.CurrentType = type;
                switch (type)
                {
                case TileType.CombinedTags:
                    Language dLanguage = CurrentManager.GetDefaultLanguage();
                    List <lm.Comol.Core.Tag.Domain.liteTagItem>             items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available).ToList();
                    List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags  = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>()
                    {
                        Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id)
                    }).ToList();
                    View.ReloadTags(tags);
                    break;

                default:
                    break;
                }
                //View.ReloadType(type);
            }
        }
Example #6
0
        private void LoadMiniTags(List <dtoLiteTile> tiles, Int32 miniTileDisplayItems, GroupItemsBy groupBy, OrderItemsBy orderBy, ref long preloadIdTag)
        {
            long    idTag = preloadIdTag;
            Boolean displayLessCommand = View.DisplayLessCommand;

            if (!tiles.Where(t => t.HasOnlyThisIdTag(idTag)).Any())
            {
                idTag = tiles.Where(t => t.HasOnlyOneTag()).Select(t => t.Tile.GetFirstIdTag()).FirstOrDefault();
            }
            View.IdCurrentTag = idTag;
            Language l = CurrentManager.GetDefaultLanguage();

            displayLessCommand = (displayLessCommand) && tiles.Where(t => !t.HasOnlyThisIdTag(idTag)).Count() > miniTileDisplayItems;
            Boolean forPreview          = View.IsPreview;
            List <dtoTileDisplay> items = tiles.Where(t => !t.HasOnlyThisIdTag(idTag)).Select(t => new dtoTileDisplay(t, UserContext.Language.Id, l.Id, forPreview)
            {
                CommandUrl = RootObject.LoadPortalView(UserContext.CurrentUserID, DashboardViewType.Combined, groupBy, orderBy, DisplayNoticeboard.OnRight, t.Tile.Id, -1, true, displayLessCommand, false)
            }).ToList();

            if (displayLessCommand)
            {
                View.LoadMiniTiles(items);
                View.DisplayMoreCommand = false;
                View.DisplayLessCommand = true;
            }
            {
                View.LoadMiniTiles(items.Skip(0).Take(miniTileDisplayItems).ToList());
                View.DisplayMoreCommand = (tiles.Where(t => !t.HasOnlyThisIdTag(idTag)).Count() > miniTileDisplayItems);
            }
            preloadIdTag = idTag;
        }
Example #7
0
        private void LoadTags(DashboardViewType tileRedirectOn, DisplayNoticeboard noticeboard, long idDashboard, List <dtoLiteTile> tiles, Int32 tileDisplayItems, GroupItemsBy groupBy)
        {
            OrderItemsBy orderby            = View.CurrentOrderItemsBy;
            Boolean      displayLessCommand = View.DisplayLessCommand;
            Language     l = CurrentManager.GetDefaultLanguage();

            displayLessCommand = displayLessCommand = (displayLessCommand) && tiles.Count() + ((noticeboard == DisplayNoticeboard.Hide) ? 0 : 1) > tileDisplayItems;
            List <dtoTileDisplay> items = null;

            if (View.IsPreview)
            {
                items = tiles.Select(t => new dtoTileDisplay(t, UserContext.Language.Id, l.Id, true)
                {
                    CommandUrl = RootObject.DashboardPreview(idDashboard, tileRedirectOn, groupBy, orderby, t.Tile.Id, t.Tile.GetAvailableIdTags().FirstOrDefault())
                }).ToList();
            }
            else
            {
                items = tiles.Select(t => new dtoTileDisplay(t, UserContext.Language.Id, l.Id)
                {
                    CommandUrl = RootObject.LoadPortalView(UserContext.CurrentUserID, tileRedirectOn, groupBy, orderby, noticeboard, t.Tile.Id, t.Tile.GetAvailableIdTags().FirstOrDefault(), true, displayLessCommand)
                }).ToList();
            }
            if (displayLessCommand)
            {
                View.LoadTiles(noticeboard, items);
                View.DisplayMoreCommand = false;
                View.DisplayLessCommand = true;
            }
            {
                View.LoadTiles(noticeboard, items.Skip(0).Take(tileDisplayItems - ((noticeboard == DisplayNoticeboard.Hide) ? 0 : 1)).ToList());
                View.DisplayMoreCommand = tiles.Count() + ((noticeboard == DisplayNoticeboard.Hide) ? 0 : 1) > tileDisplayItems;
            }
        }
        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();
                }
            }
        }
Example #9
0
        public void LoadCommunities(Int32 idProfile, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters, List <Int32> unloadIdCommunities, Int32 pageIndex, Int32 pageSize, Boolean useCache = true)
        {
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                List <Int32> selectedItems = View.SelectedIdCommunities;
                Dictionary <Boolean, List <Int32> > selections = View.GetCurrentSelection();
                selectedItems = selectedItems.Except(selections[false]).ToList();
                selectedItems.AddRange(selections[true]);

                View.SelectedIdCommunities = selectedItems.Distinct().ToList();
                View.SearchFilters         = filters;
                List <dtoCommunityPlainItem> items = ServiceCommunities.GetPlainCommunities(idProfile, filters, unloadIdCommunities, useCache);
                if (items == null)
                {
                    View.LoadNothing();
                }
                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;


                    items = ServiceCommunities.GetCommunities(items, pageIndex, pageSize, Core.Dashboard.Domain.OrderItemsBy.Name, true);

                    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 (dtoCommunityPlainItem item in items.Where(i => tags.ContainsKey(i.Community.Id)))
                            {
                                item.Community.Tags = tags[item.Community.Id];
                            }
                        }
                        View.LoadItems(items);
                    }
                    else
                    {
                        View.LoadItems(new List <dtoCommunityPlainItem>());
                    }
                }
            }
        }
Example #10
0
        private void InitializeLanguage(Person person)
        {
            Language language = null;

            if (person != null)
            {
                language = CurrentManager.GetLanguage(person.LanguageID);
            }
            if (language == null)
            {
                language = CurrentManager.GetDefaultLanguage();
            }

            View.LoadLanguage(language);
        }
Example #11
0
 private void MoveToDefaultTranslation(IdentifierField fields)
 {
     if (View.isTranslationInitialized)
     {
         View.UpdateTranslationView(fields);
         View.GotoStep(ProviderWizardStep.DefaultTranslation);
     }
     else
     {
         Language language = CurrentManager.GetDefaultLanguage();
         if (language != null)
         {
             View.InitializeTranslation(0, language.Id, fields);
             View.GotoStep(ProviderWizardStep.DefaultTranslation);
         }
     }
 }
Example #12
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));
        }
Example #13
0
        private void LoadMiniTiles(long idDashboard, List <dtoLiteTile> tiles, Int32 miniTileDisplayItems, GroupItemsBy groupBy, OrderItemsBy orderBy, long preloadIdTile, out dtoTileDisplay selectedTile)
        {
            Boolean displayLessCommand = View.DisplayLessCommand;

            if (!tiles.Where(t => t.Tile.Id == preloadIdTile).Any())
            {
                preloadIdTile = tiles.Select(t => t.Tile.Id).FirstOrDefault();
            }
            View.IdCurrentTile = preloadIdTile;
            Language l = CurrentManager.GetDefaultLanguage();

            displayLessCommand = (displayLessCommand) && tiles.Where(t => t.Tile.Id != preloadIdTile).Count() > miniTileDisplayItems;
            List <dtoTileDisplay> items = null;
            Boolean forPreview          = View.IsPreview;

            if (forPreview)
            {
                items = tiles.Where(t => t.Tile.Id != preloadIdTile).Select(t => new dtoTileDisplay(t, UserContext.Language.Id, l.Id, forPreview)
                {
                    CommandUrl = RootObject.DashboardPreview(idDashboard, DashboardViewType.Combined, groupBy, orderBy, t.Tile.Id)
                }).ToList();
            }
            else
            {
                items = tiles.Where(t => t.Tile.Id != preloadIdTile).Select(t => new dtoTileDisplay(t, UserContext.Language.Id, l.Id)
                {
                    CommandUrl = RootObject.LoadPortalView(UserContext.CurrentUserID, DashboardViewType.Combined, groupBy, orderBy, DisplayNoticeboard.OnRight, t.Tile.Id, -1, true, displayLessCommand, false)
                }).ToList();
            }

            if (displayLessCommand)
            {
                View.LoadMiniTiles(items);
                View.DisplayMoreCommand = false;
                View.DisplayLessCommand = true;
            }
            else
            {
                View.LoadMiniTiles(items.Skip(0).Take(miniTileDisplayItems).ToList());
                View.DisplayMoreCommand = (tiles.Where(t => t.Tile.Id != preloadIdTile).Count() > miniTileDisplayItems);
            }
            selectedTile = tiles.Where(t => t.Tile.Id == preloadIdTile).Select(t => new dtoTileDisplay(t, UserContext.Language.Id, l.Id, forPreview)).FirstOrDefault();
        }
Example #14
0
        public Boolean SendMail(String senderName, String senderMail, String subject, String body, String recipients, MessageSettings settings, SmtpServiceConfig smtpConfig)
        {
            Boolean result = false;

            try
            {
                //List<System.Net.Mail.MailAddress> rItems = new List<System.Net.Mail.MailAddress>();
                //if (!String.IsNullOrEmpty(recipients)){
                //    rItems.AddRange(recipients.Split(separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList().Select(m => new System.Net.Mail.MailAddress(m)).ToList());
                //}
                //string separator,
                Language dLanguage = CurrentManager.GetDefaultLanguage();
                lm.Comol.Core.Mail.MailService    mailService = new lm.Comol.Core.Mail.MailService(smtpConfig, settings);
                lm.Comol.Core.Mail.dtoMailMessage message     = new lm.Comol.Core.Mail.dtoMailMessage(subject, body);
                message.FromUser = new System.Net.Mail.MailAddress(senderMail, senderMail);
                mailService.SendMail(UserContext.Language.Id, dLanguage, message, recipients, MailCommons.Domain.RecipientType.BCC);

                result = true;
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
        private List <Person> CreateProfiles(dtoImportSettings settings, Int32 idDefaultOrganization, ProfileExternalResource selectedItems, List <dtoImportedProfile> createdProfiles, List <dtoBaseProfile> notCreatedProfiles)
        {
            List <Person>          profiles = new List <Person>();
            Language               language = CurrentManager.GetDefaultLanguage();
            AuthenticationProvider provider = Service.GetAuthenticationProvider(settings.IdProvider);

            if (provider != null && language != null)
            {
                Boolean created  = false;
                Int32   idPerson = 0;
                Int32   index    = 1;
                foreach (ProfileAttributesRow row in selectedItems.Rows)
                {
                    dtoBaseProfile baseItem = null;
                    switch (settings.IdProfileType)
                    {
                    case (int)UserTypeStandard.ExternalUser:
                        dtoExternal externalUser = CreateExternal(row);
                        baseItem = externalUser;
                        break;

                    case (int)UserTypeStandard.Company:
                        dtoCompany company = CreateCompanyUser(row);
                        baseItem = company;
                        break;

                    case (int)UserTypeStandard.Employee:
                        dtoEmployee employee = CreateEmployee(row);
                        baseItem = employee;
                        break;

                    default:
                        baseItem = new dtoBaseProfile();
                        break;
                    }
                    created = false;

                    if (baseItem != null)
                    {
                        GenerateBaseProfile(baseItem, settings, row, provider.ProviderType, GetUserLanguage(row, language));
                        if (InternalService.isUniqueMail(baseItem.Mail))
                        {
                            PersonInfo info = GeneratePersonInfo(row, baseItem);
                            idPerson = View.AddUserProfile(baseItem, info, idDefaultOrganization, provider);
                            if (idPerson > 0)
                            {
                                Person person = CurrentManager.GetPerson(idPerson);
                                if (person != null)
                                {
                                    created = AddAuthentication(person, baseItem, settings, row, provider);
                                    if (created)
                                    {
                                        Service.SetDefaultProvider(provider.Id, person.Id);
                                    }
                                    profiles.Add(person);
                                    createdProfiles.Add(new dtoImportedProfile()
                                    {
                                        Profile = baseItem, Info = info
                                    });
                                }
                            }
                        }
                        if (!created)
                        {
                            notCreatedProfiles.Add(baseItem);
                        }
                        View.UpdateProfileCreation(0, index, created, baseItem.DisplayName);
                    }
                    else
                    {
                        View.UpdateProfileCreation(0, index, created, " // ");
                    }
                    index++;
                }
            }
            return(profiles);
        }
Example #16
0
        public void InitView(long idTile, DashboardType dashboardType, Int32 idContainerCommunity)
        {
            Person p = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (UserContext.isAnonymous || p == null)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                Int32           idTileCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0;
                ModuleDashboard permissions     = ModuleDashboard.CreatePortalmodule(p.TypeID);
                dtoEditTile     tile            = Service.GetEditTile(idTile);
                idTileCommunity = (tile == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : tile.IdCommunity;
                if (dashboardType == DashboardType.Community)
                {
                    View.IdContainerCommunity = idContainerCommunity;
                    if (idTileCommunity < 0)
                    {
                        idTileCommunity = UserContext.CurrentCommunityID;
                    }
                    if (idTileCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles))
                    {
                        permissions = Service.GetPermission(idTileCommunity);
                    }
                }
                else
                {
                    idContainerCommunity      = 0;
                    View.IdContainerCommunity = 0;
                }
                if ((tile == null && (idTile > 0)) || (tile != null && tile.Deleted != BaseStatusDeleted.None && tile.Deleted != BaseStatusDeleted.Manual))
                {
                    View.DisplayUnknownTile();
                }
                if (permissions.ManageTiles)
                {
                    View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileView);
                    View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep));


                    List <lm.Comol.Core.DomainModel.Languages.dtoLanguageItem> languages = CurrentManager.GetAllLanguages().OrderByDescending(l => l.isDefault).ThenBy(l => l.Name).Select(l =>
                                                                                                                                                                                           new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem()
                    {
                        IdLanguage = l.Id, LanguageCode = l.Code, LanguageName = l.Name
                    }).ToList();

                    languages.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem()
                    {
                        IdLanguage = 0, LanguageCode = View.GetDefaultLanguageCode(), LanguageName = View.GetDefaultLanguageName(), IsMultiLanguage = true
                    });

                    switch (tile.Type)
                    {
                    case TileType.CommunityTag:
                        View.LoadTile(tile, ServiceTags.GetTagTranslation(tile.IdTags.FirstOrDefault(), UserContext.Language.Id).Title, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                        break;

                    case TileType.CombinedTags:
                        Language dLanguage = CurrentManager.GetDefaultLanguage();
                        List <lm.Comol.Core.Tag.Domain.liteTagItem>             items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available || tile.IdTags.Contains(t.Id)).ToList();
                        List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags  = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>()
                        {
                            Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id)
                        }).ToList();
                        View.LoadTile(tile, tags, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                        break;

                    case TileType.CommunityType:
                        View.LoadTile(tile, Service.GetCommunityTypeName(tile.IdCommunityTypes.FirstOrDefault(), UserContext.Language.Id), languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                        break;

                    default:
                        View.LoadTile(tile, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                        break;
                    }
                    View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileView);
                }
                else
                {
                    View.DisplayNoPermission(idContainerCommunity, CurrentIdModule);
                }
            }
        }
        public void InitView(Boolean add, long idTile, DashboardType dashboardType, Int32 idContainerCommunity)
        {
            Person p = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (UserContext.isAnonymous || p == null)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                Int32           idTileCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0;
                ModuleDashboard permissions     = ModuleDashboard.CreatePortalmodule(p.TypeID);
                List <TileType> availableTypes  = null;
                dtoEditTile     tile            = null;
                View.IdTile = idTile;
                if (add)
                {
                    availableTypes = Service.GetTileTypesAvailable(dashboardType);
                    tile           = new dtoEditTile();
                    tile.Status    = AvailableStatus.Draft;
                    tile.Type      = availableTypes.FirstOrDefault();
                }
                else
                {
                    if (View.PreloadFromAdd)
                    {
                        View.DisplayTileAdded();
                    }
                    tile            = Service.GetEditTile(idTile);
                    idTileCommunity = (tile == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : tile.IdCommunity;
                }
                View.IdTileCommunity = idTileCommunity;
                if (dashboardType == DashboardType.Community)
                {
                    View.IdContainerCommunity = idContainerCommunity;
                    if (idTileCommunity < 0)
                    {
                        idTileCommunity = UserContext.CurrentCommunityID;
                    }
                    if (idTileCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles))
                    {
                        permissions = Service.GetPermission(idTileCommunity);
                    }
                }
                else
                {
                    idContainerCommunity      = 0;
                    View.IdContainerCommunity = 0;
                }
                if ((tile == null && (idTile > 0 || !add)) || (tile != null && tile.Deleted != BaseStatusDeleted.None && tile.Deleted != BaseStatusDeleted.Manual))
                {
                    View.DisplayUnknownTile();
                    if (!permissions.ManageTiles)
                    {
                        View.DisplayNoPermission(idContainerCommunity, CurrentIdModule);
                    }
                    else
                    {
                        View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep));
                    }
                }
                else
                {
                    if (permissions.ManageTiles)
                    {
                        if (tile != null && tile.Id > 0)
                        {
                            View.AllowVirtualUndelete = (tile.Deleted == BaseStatusDeleted.Manual);
                            View.AllowVirtualDelete   = (tile.Deleted == BaseStatusDeleted.None);
                            View.AllowDisable         = (tile.Deleted == BaseStatusDeleted.None && tile.Status == AvailableStatus.Available);
                            View.AllowEnable          = (tile.Deleted == BaseStatusDeleted.None && tile.Status != AvailableStatus.Available);
                            View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), tile.Id, ModuleDashboard.ActionType.TileStartEditing);
                        }
                        else
                        {
                            View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileStartAdding);
                        }

                        View.AllowSave = (tile.Deleted == BaseStatusDeleted.None);
                        View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep));
                        switch (tile.Type)
                        {
                        case TileType.CommunityTag:
                            View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, ServiceTags.GetTagTranslation(tile.IdTags.FirstOrDefault(), UserContext.Language.Id).Title);
                            break;

                        case TileType.CombinedTags:
                            Language dLanguage = CurrentManager.GetDefaultLanguage();
                            List <lm.Comol.Core.Tag.Domain.liteTagItem>             items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available || tile.IdTags.Contains(t.Id)).ToList();
                            List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags  = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>()
                            {
                                Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id)
                            }).ToList();
                            View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, tags, availableTypes);
                            break;

                        case TileType.CommunityType:
                            View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, Service.GetCommunityTypeName(tile.IdCommunityTypes.FirstOrDefault(), UserContext.Language.Id));
                            break;

                        default:
                            View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, availableTypes);
                            break;
                        }
                    }
                    else
                    {
                        View.DisplayNoPermission(idContainerCommunity, CurrentIdModule);
                    }
                }
            }
        }
        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);
                }
            }
        }
        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);
                    }
                }
            }
        }