Beispiel #1
0
        public ArticlePreviewInfo Post([FromBody] string articleNumber)
        {
            ArticleItem article = _articleUtil.GetArticleByNumber(articleNumber);
            var         preview = article != null?_articleUtil.GetPreviewInfo(article) : new ArticlePreviewInfo();

            return(preview);
        }
Beispiel #2
0
        public List <ArticlePreviewInfo> Post([FromBody] List <Guid> guids)
        {
            var previews = new List <ArticlePreviewInfo>();

            foreach (Guid guid in guids)
            {
                ArticleItem article = _sitecoreMasterService.GetItem <ArticleItem>(guid);
                if (article != null)
                {
                    previews.Add(_articleUtil.GetPreviewInfo(article));
                }
            }
            return(previews);
        }
Beispiel #3
0
        public string CreateBody(ArticleStruct articleStruct, string emailTitle, string publication, WorkflowInfo oldWorkflow)
        {
            var    htmlEmailTemplate = HtmlEmailTemplateFactory.Create("Workflow");
            string siteRoot          = HttpContext.Current.Request.Url.Host;

            if (htmlEmailTemplate == null)
            {
                return(null);
            }

            var article = _articleUtil.GetArticleItemByNumber(articleStruct.ArticleNumber);

            var authorString = string.Empty;

            foreach (var eachAuthor in articleStruct.Authors)
            {
                authorString = eachAuthor.Name + ",";
            }
            var emailHtml    = htmlEmailTemplate.Html;
            var replacements = new Dictionary <string, string>();

            replacements["#Email_Title#"]   = emailTitle;
            replacements["#Article_Title#"] = string.IsNullOrEmpty(articleStruct.Title) ? article.Fields["Title"].Value : articleStruct.Title;
            replacements["#Publish_Date#"]  = articleStruct.WebPublicationDate.ToString();
            replacements["#word_url#"]      = GetWordURL(articleStruct);

            ArticleItem articleItem = _service.GetItem <ArticleItem>(article.ID.ToString());

            if (articleItem != null)
            {
                var preview = _articleUtil.GetPreviewInfo(articleItem);
                if (preview != null)
                {
                    replacements["#preview_url#"] = preview.PreviewUrl;
                }
            }

            replacements["#Authors#"]     = string.IsNullOrEmpty(authorString) ? "No authors selected" : authorString;
            replacements["#Publication#"] = publication;

            replacements["#show_notes#"]   = "Notes: ";
            replacements["#Body_Content#"] = articleStruct.NotificationText;
            if (articleStruct.NotificationText == "")
            {
                replacements["#show_notes#"]   = "";
                replacements["#Body_Content#"] = "";
            }

            replacements["#content_editor#"] = Sitecore.Context.User.Profile.FullName;
            replacements["#current_time#"]   = DateTime.Now.ToString();

            var oldState = _service.Database.WorkflowProvider.GetWorkflow(oldWorkflow.StateID);

            if (oldState != null)
            {
                //replacements["#old_state_image#"] = "https://" + siteRoot + oldState.Appearance.Icon;
                replacements["#old_state#"] = oldState.Appearance.DisplayName;
            }
            var newState = _service.Database.WorkflowProvider.GetWorkflow(articleStruct.CommandID.ToString());

            if (newState != null)
            {
                //replacements["#new_state_image#"] = "https://" + siteRoot + newState.Appearance.Icon;
                replacements["#new_state#"] = newState.Appearance.DisplayName;
            }


            List <WorkflowEvent> workflowHistory = GetWorkflowHistory(article);

            replacements["#history#"] = HistoryTableCreation(workflowHistory);
            var eHtml = emailHtml.ReplacePatternCaseInsensitive(replacements);

            return(eHtml);
        }