Esempio n. 1
0
        private void ContentEvents_PublishedContent(object sender, ContentEventArgs e)
        {
            PageData page = e.Content as PageData;

            if (page == null)
            {
                return;
            }

            // Page is home page
            if (page.ContentLink.ID == ContentReference.StartPage.ID)
            {
                if (page.StopPublish.HasValue)
                {
                    this._homeIsUnPublished = page.StopPublish <= DateTime.Now;
                }

                // In event "Publishing", homeIsPublished was false, now it is. Send a recrawl
                if (this._homeIsUnPublished && page.CheckPublishedStatus(PagePublishedStatus.Published))
                {
                    string url = _siteimproveHelper.GetExternalUrl(page);
                    if (url != null)
                    {
                        _siteimproveHelper.PassEvent("recrawl", url, this._settingsRepository.GetToken());
                    }
                    this._homeIsUnPublished = false;
                    return;
                }
            }

            if (!this._settingsRepository.GetSetting().NoRecheck)
            {
                if (page.CheckPublishedStatus(PagePublishedStatus.Published))
                {
                    string url = _siteimproveHelper.GetExternalUrl(page);
                    if (url != null)
                    {
                        _siteimproveHelper.PassEvent("recheck", url, this._settingsRepository.GetToken());
                    }
                }
                else
                {
                    _siteimproveHelper.PassEvent("recheck", "", this._settingsRepository.GetToken());
                }
            }
        }
Esempio n. 2
0
        public ActionResult PageUrl(string contentId, string locale)
        {
            var contentRep = ServiceLocator.Current.GetInstance <IContentRepository>();
            var page       = contentRep.Get <PageData>(
                new ContentReference(contentId),
                new LanguageSelector(locale));

            if (page != null)
            {
                if (page.CheckPublishedStatus(PagePublishedStatus.Published))
                {
                    var externalUrl = _siteimproveHelper.GetExternalUrl(page);
                    return(Json(new { url = externalUrl, isDomain = false }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var currentSiteUrl = SiteDefinition.Current.SiteUrl.ToString();
                    return(Json(new { url = currentSiteUrl, isDomain = true }, JsonRequestBehavior.AllowGet));
                }
            }

            return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest));
        }