Esempio n. 1
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();
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uiCode">user language code from browser</param>
        public void InitializeLanguageView(String uiCode)
        {
            String lCode = uiCode;
            List <dtoMacUrlProviderIdentifier> items = UrlService.GetActiveApplicationIdentifiers();
            Language language = CurrentManager.GetLanguage(uiCode);

            if (items != null && items.Any())
            {
                dtoMacUrlProviderIdentifier identifier = View.GetUrlIdentifier(items);
                BaseUrlMacAttribute         lAttribute = UrlService.GetProviderLanguageAttribute((identifier == null) ? 0 : identifier.IdProvider);
                if (lAttribute != null)
                {
                    lCode = View.GetUrlAttributeValue(lAttribute.QueryStringName);
                }
            }
            if (lCode != "" && uiCode.Contains(lCode))
            {
                lCode = uiCode;
            }
            if (language == null || (lCode != uiCode && !String.IsNullOrEmpty(lCode)))
            {
                language = CurrentManager.GetLanguageByCodeOrDefault(lCode);
            }
            View.LoadLanguage(language);
        }