Esempio n. 1
0
        public List <lm.Comol.Core.DomainModel.Languages.LanguageItem> GetInUseLanguageItems(LanguageItem language, List <dtoTemplateTranslation> translations, dtoTemplateTranslation content)
        {
            List <lm.Comol.Core.DomainModel.Languages.LanguageItem> items = new List <lm.Comol.Core.DomainModel.Languages.LanguageItem>();

            try
            {
                List <Language> languages = CurrentManager.GetAllLanguages().ToList();
                items = translations.Select(t => new lm.Comol.Core.DomainModel.Languages.LanguageItem()
                {
                    Id              = t.IdLanguage,
                    Code            = t.LanguageCode,
                    IsDefault       = languages.Where(l => l.isDefault && l.Id == t.IdLanguage).Any(),
                    IsEnabled       = true,
                    IsMultiLanguage = (t.LanguageCode == "multi"),
                    Name            = (String.IsNullOrEmpty(t.LanguageName) && languages.Where(l => l.Id == t.IdLanguage).Any()) ? languages.Where(l => l.Id == t.IdLanguage).Select(l => l.Name).FirstOrDefault() : t.LanguageName,
                    ToolTip         = (String.IsNullOrEmpty(t.LanguageName) && languages.Where(l => l.Id == t.IdLanguage).Any()) ? languages.Where(l => l.Id == t.IdLanguage).Select(l => l.Name).FirstOrDefault() : t.LanguageName,
                    Status          = (t.IsValid || (content.IdLanguage == t.IdLanguage && content.IsValid)) ? lm.Comol.Core.DomainModel.Languages.ItemStatus.valid : ((content.IsEmpty) ? lm.Comol.Core.DomainModel.Languages.ItemStatus.wrong :lm.Comol.Core.DomainModel.Languages.ItemStatus.warning)
                }).ToList();
            }
            catch (Exception ex)
            {
            }

            return(items);
        }
        public void RetrievePassword(string mail)
        {
            InternalLoginInfo user = InternalService.FindUserByMail(mail);

            if (user == null || user.Person == null)
            {
                View.DisplayRetrievePasswordUnknownLogin();
            }
            else
            {
                String newPassword = InternalService.RenewPassword(user, user.Person, EditType.retrieve);
                if (String.IsNullOrEmpty(newPassword))
                {
                    View.DisplayRetrievePasswordError();
                }
                else
                {
                    View.SendMail(user, newPassword, CurrentManager.GetAllLanguages().Where(l => l.Id == user.Person.LanguageID).FirstOrDefault());
                    View.GotoInternalLogin();
                }
            }
        }
Esempio n. 3
0
        public void InitView(dtoEditTile tile, String cssFile, String imagesFolder)
        {
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                List <lm.Comol.Core.DomainModel.Languages.dtoLanguageItem> items = 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();

                items.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem()
                {
                    IdLanguage = 0, LanguageCode = View.GetDefaultLanguageCode(), LanguageName = View.GetDefaultLanguageName(), IsMultiLanguage = true
                });
                View.CurrentType = tile.Type;
                View.LoadTranslations(items, items.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                View.LoadCssAndImages(ExtractIconsCss(cssFile, tile.ImageCssClass), ExtractTileImages(imagesFolder, tile.ImageUrl), true);
            }
        }
        private void InitializeView(dtoTemplateMessageContext context)
        {
            MailMessage message = Service.GetMessage(context.IdMessageTemplate);

            if (message == null)
            {
                View.DisplayNoTemplateFound();
            }
            else
            {
                Boolean isAdministrative = Service.IsAdministrativeUser(UserContext.CurrentUserID);
                Boolean senderEdit       = isAdministrative;
                View.DisplayMessageInfo(message.CreatedBy, message.CreatedOn);
                View.InitializeMailSettings(message.MailSettings, senderEdit, isAdministrative, isAdministrative);


                List <lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation> translations = new List <lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation>();
                if (message.Template != null)
                {
                    Boolean onlyShortText = false;
                    Boolean hasShortText  = false;
                    if (message.Template.IsTemplateCompliant)
                    {
                        lm.Comol.Core.TemplateMessages.Domain.TemplateDefinitionVersion version = null;
                        if (message.Template.IdVersion > 0)
                        {
                            version = TemplatesService.GetVersion(message.Template.IdVersion);
                        }
                        if (version == null)
                        {
                            version = TemplatesService.GetLastActiveVersion(message.Template.IdTemplate);
                        }
                        if (version != null)
                        {
                            translations = (from t in version.Translations
                                            where t.Deleted == BaseStatusDeleted.None
                                            select new lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation()
                            {
                                Id = t.Id,
                                IdLanguage = t.IdLanguage,
                                LanguageCode = t.LanguageCode,
                                LanguageName = t.LanguageName,
                                Translation = t.Translation
                            }).ToList();
                            if (!translations.Where(t => t.LanguageCode == "multi" && t.IdLanguage == 0).Any())
                            {
                                translations.Add(new lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation()
                                {
                                    Id           = 0,
                                    IdLanguage   = 0,
                                    LanguageCode = "multi",
                                    Translation  = version.DefaultTranslation
                                });
                            }
                            View.ContentModules = version.GetModuleContentCodes();
                            onlyShortText       = version.OnlyShortText;
                            hasShortText        = version.HasShortText;
                        }
                    }
                    else
                    {
                        translations = (from t in message.Template.Translations
                                        where t.Deleted == BaseStatusDeleted.None
                                        select new lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation()
                        {
                            Id = t.Id,
                            IdLanguage = t.IdLanguage,
                            LanguageCode = t.LanguageCode,
                            LanguageName = t.LanguageName,
                            Translation = t.Translation
                        }).ToList();
                        View.ContentModules = new List <String>()
                        {
                            context.ModuleCode
                        };
                    }
                    List <Language> languages = CurrentManager.GetAllLanguages().ToList();
                    List <lm.Comol.Core.DomainModel.Languages.LanguageItem> inUseLanguages = translations.Select(t => new lm.Comol.Core.DomainModel.Languages.LanguageItem()
                    {
                        Id = t.IdLanguage, Code = t.LanguageCode, Name = t.LanguageName, IsMultiLanguage = (t.LanguageCode == "multi" && t.IdLanguage == 0), Status = (t.IsEmpty) ? DomainModel.Languages.ItemStatus.wrong : (t.Translation.IsValid(!onlyShortText, hasShortText, true)) ? DomainModel.Languages.ItemStatus.valid : DomainModel.Languages.ItemStatus.warning
                    }).ToList();

                    inUseLanguages.Where(l => languages.Where(ll => ll.isDefault && l.Id == ll.Id).Any()).ToList().ForEach(l => l.IsDefault = true);
                    inUseLanguages.Where(l => l.Id > 0).ToList().ForEach(l => l.Name = languages.Where(ll => ll.Id == l.Id).Select(ll => ll.Name).FirstOrDefault());

                    inUseLanguages = inUseLanguages.OrderByDescending(l => l.IsMultiLanguage).ThenBy(l => l.Name).ToList();
                    lm.Comol.Core.DomainModel.Languages.LanguageItem current = inUseLanguages.Where(l => l.Id == UserContext.Language.Id).FirstOrDefault();
                    if (current == null && languages.Any())
                    {
                        current = inUseLanguages.Where(l => l.IsDefault).FirstOrDefault();
                        if (current == null)
                        {
                            current = inUseLanguages.Where(l => l.IsMultiLanguage).FirstOrDefault();
                        }
                    }
                    if (current == null && inUseLanguages.Any())
                    {
                        current = inUseLanguages[0];
                    }
                    View.InitializeControls(translations, inUseLanguages, current);
                    String tagTranslation = View.TagTranslation;
                    if (translations.Any() && !String.IsNullOrEmpty(tagTranslation))
                    {
                        List <lm.Comol.Core.DomainModel.Helpers.TemplatePlaceHolder> placeHolders = View.GetContentPlaceHolders(View.ContentModules);
                        foreach (lm.Comol.Core.DomainModel.Helpers.TemplatePlaceHolder pHolder in placeHolders.Where(t => translations.Where(ct => !ct.Translation.IsContentEmpty() && ((!String.IsNullOrEmpty(ct.Translation.Body) && ct.Translation.Body.Contains(t.Tag)) || (!String.IsNullOrEmpty(ct.Translation.Subject) && ct.Translation.Subject.Contains(t.Tag)))).Any()))
                        {
                            translations.Where(ct => !ct.Translation.IsContentEmpty() && !String.IsNullOrEmpty(ct.Translation.Body) && ct.Translation.Body.Contains(pHolder.Tag)).ToList().ForEach(t => t.Translation.Body          = t.Translation.Body.Replace(pHolder.Tag, String.Format(tagTranslation, pHolder.Tag, pHolder.Name)));
                            translations.Where(ct => !ct.Translation.IsContentEmpty() && !String.IsNullOrEmpty(ct.Translation.Subject) && ct.Translation.Subject.Contains(pHolder.Tag)).ToList().ForEach(t => t.Translation.Subject = t.Translation.Subject.Replace(pHolder.Tag, String.Format(tagTranslation, pHolder.Tag, pHolder.Name)));
                        }
                    }
                    View.LoadMessage((current != null) ? translations.Where(t => t.IdLanguage == current.Id && t.LanguageCode == current.Code).FirstOrDefault() : (translations.Any() ? translations[0] : null));
                }


                //List<lm.Comol.Core.DomainModel.Languages.BaseLanguageItem> availableItems = Service.GetAvalableLanguage(version);
                //List<lm.Comol.Core.DomainModel.Languages.LanguageItem> items = Service.GetInUseLanguageItems(version);

                //if (version != null)
                //{
                //    View.IdSelectedVersion = version.Id;
                //    View.ContentModules = Service.GetVersionModuleContentCodes(version.Id);

                //    translations.Add(new dtoTemplateTranslation() { IdLanguage = 0, LanguageCode = "multi", Translation = version.DefaultTranslation.Copy() });
                //    translations.AddRange(version.Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Select(t => new dtoTemplateTranslation() { IdLanguage = t.IdLanguage, LanguageCode = t.LanguageCode, Translation = t.Translation.Copy() }).ToList());
                //    if (version.ChannelSettings.Where(c => c.Deleted == BaseStatusDeleted.None && c.Channel == NotificationChannel.Mail).Any())
                //        settings = version.ChannelSettings.Where(c => c.Deleted == BaseStatusDeleted.None && c.Channel == NotificationChannel.Mail).FirstOrDefault().MailSettings;

                //    senderEdit = senderEdit && version.Template.Type == TemplateType.System;
                //    View.LoadEditor(translations, "multi", version.HasShortText, version.OnlyShortText, availableItems, items, items.Where(i => i.IsMultiLanguage).FirstOrDefault());
                //}
                //else
                //{
                //    View.ContentModules = new List<String>() { currentCode };
                //    translations.Add(new dtoTemplateTranslation() { IdLanguage = 0, LanguageCode = "multi", Translation = new ItemObjectTranslation() { IsHtml = (settings == null) ? true : settings.isHtml, Body = "", Name = "" } });
                //    View.LoadEditor(translations, "multi", false, false, availableItems, items, items.Where(i => i.IsMultiLanguage).FirstOrDefault());
                //}
            }
        }
Esempio n. 5
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);
                }
            }
        }
Esempio n. 6
0
        private void InitializeView(long idTemplate, long idVersion, dtoSelectorContext context)
        {
            TemplateDefinitionVersion version = InternalService.GetVersion(idTemplate, idVersion);

            if (version == null)
            {
                if (idVersion > 0)
                {
                    View.DisplayNoTemplateVersionFound();
                }
                else
                {
                    View.DisplayNoTemplateFound();
                }
            }
            else
            {
                if (idVersion > 0)
                {
                    View.DisplayVersionInfo(version.Number);
                }
                else
                {
                    View.DisplayLastVersionInfo();
                }
                Boolean isAdministrative = InternalService.IsAdministrativeUser(UserContext.CurrentUserID);
                if (version.ChannelSettings != null && version.ChannelSettings.Where(c => c.Deleted == BaseStatusDeleted.None && c.Channel == lm.Comol.Core.Notification.Domain.NotificationChannel.Mail).Any())
                {
                    View.InitializeMailSettings(version.ChannelSettings.Where(c => c.Deleted == BaseStatusDeleted.None && c.Channel == lm.Comol.Core.Notification.Domain.NotificationChannel.Mail).FirstOrDefault().MailSettings, isAdministrative, isAdministrative, isAdministrative);
                }
                List <lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation> translations = new List <lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation>();
                translations = (from t in version.Translations where t.Deleted == BaseStatusDeleted.None
                                select new lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation()
                {
                    Id = t.Id,
                    IdLanguage = t.IdLanguage,
                    LanguageCode = t.LanguageCode,
                    LanguageName = t.LanguageName,
                    Translation = t.Translation
                }).ToList();
                translations.Add(new dtoTemplateTranslation()
                {
                    Id = 0, IdLanguage = 0, LanguageCode = "multi", LanguageName = "multi", IdVersion = version.Id, Translation = version.DefaultTranslation
                });
                View.ContentModules = version.GetModuleContentCodes();
                List <Language> languages = CurrentManager.GetAllLanguages().ToList();
                List <lm.Comol.Core.DomainModel.Languages.LanguageItem> inUseLanguages = translations.Select(t => new lm.Comol.Core.DomainModel.Languages.LanguageItem()
                {
                    Id = t.IdLanguage, Code = t.LanguageCode, Name = t.LanguageName, IsMultiLanguage = (t.LanguageCode == "multi" && t.IdLanguage == 0), Status = (t.IsEmpty) ? DomainModel.Languages.ItemStatus.wrong : (t.Translation.IsValid(!version.OnlyShortText, version.HasShortText, true)) ? DomainModel.Languages.ItemStatus.valid : DomainModel.Languages.ItemStatus.warning
                }).ToList();
                inUseLanguages.Where(l => languages.Where(ll => ll.isDefault && l.Id == ll.Id).Any()).ToList().ForEach(l => l.IsDefault = true);
                inUseLanguages.Where(l => l.Id > 0).ToList().ForEach(l => l.Name = languages.Where(ll => ll.Id == l.Id).Select(ll => ll.Name).FirstOrDefault());
                inUseLanguages.Add(new lm.Comol.Core.DomainModel.Languages.LanguageItem()
                {
                    Id = 0, Code = "multi", IsEnabled = true, IsMultiLanguage = true, Status = (version.DefaultTranslation.IsValid(!version.OnlyShortText, version.HasShortText, true)) ? lm.Comol.Core.DomainModel.Languages.ItemStatus.valid : lm.Comol.Core.DomainModel.Languages.ItemStatus.warning
                });

                inUseLanguages = inUseLanguages.OrderByDescending(l => l.IsMultiLanguage).ThenBy(l => l.Name).ToList();
                //if (!inUseLanguages.Any(l => l.IsMultiLanguage))
                //{
                //    inUseLanguages.Add(new DomainModel.Languages.LanguageItem(){ IsMultiLanguage=true, })
                //}
                lm.Comol.Core.DomainModel.Languages.LanguageItem current = inUseLanguages.Where(l => l.Id == UserContext.Language.Id).FirstOrDefault();
                if (current == null && inUseLanguages.Any())
                {
                    current = inUseLanguages.Where(l => l.IsDefault).FirstOrDefault();
                    if (current == null)
                    {
                        current = inUseLanguages.Where(l => l.IsMultiLanguage).FirstOrDefault();
                    }
                }
                if (current == null && inUseLanguages.Any())
                {
                    current = inUseLanguages.FirstOrDefault();
                }
                View.InitializeControls(translations, inUseLanguages, current);
                View.LoadTemplate((current != null) ? translations.Where(t => t.IdLanguage == current.Id && t.LanguageCode == current.Code).FirstOrDefault() : (translations.Any() ? translations[0] : null));
            }
            //        Boolean isAdministrative =  Service.IsAdministrativeUser(UserContext.CurrentUserID);
            //        Boolean senderEdit = isAdministrative;

            //        List<lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation> translations = new List<lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation>();
            //        if (message.Template != null) {
            //            Boolean onlyShortText = false;
            //            Boolean hasShortText = false;


            //            String tagTranslation = View.TagTranslation;
            //            if (translations.Any() && !String.IsNullOrEmpty(tagTranslation)){
            //                List<lm.Comol.Core.DomainModel.Helpers.TemplatePlaceHolder> placeHolders = View.GetContentPlaceHolders(View.ContentModules);
            //                foreach(lm.Comol.Core.DomainModel.Helpers.TemplatePlaceHolder pHolder in placeHolders.Where(t=> translations.Where(ct=> !ct.Translation.IsContentEmpty && ((!String.IsNullOrEmpty(ct.Translation.Body) && ct.Translation.Body.Contains(t.Tag)) || (!String.IsNullOrEmpty(ct.Translation.Subject) && ct.Translation.Subject.Contains(t.Tag)))).Any()) ){
            //                    translations.Where(ct => !ct.Translation.IsContentEmpty && !String.IsNullOrEmpty(ct.Translation.Body) && ct.Translation.Body.Contains(pHolder.Tag)).ToList().ForEach(t => t.Translation.Body = t.Translation.Body.Replace(pHolder.Tag, String.Format(tagTranslation, pHolder.Tag, pHolder.Name)));
            //                    translations.Where(ct => !ct.Translation.IsContentEmpty && !String.IsNullOrEmpty(ct.Translation.Subject) && ct.Translation.Subject.Contains(pHolder.Tag)).ToList().ForEach(t => t.Translation.Subject = t.Translation.Subject.Replace(pHolder.Tag, String.Format(tagTranslation, pHolder.Tag, pHolder.Name)));
            //                }
            //            }

            //        }
            //    }
        }