Пример #1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            DynamicContent.Controls.Add(this.ParseControl(MediaDetailsMapper.ParseWithTemplate(CurrentMediaDetail)));

            if (WebsitesMapper.GetWebsite().IsSiteOnline())
            {
                Response.Redirect("~/");
            }
        }
Пример #2
0
    public void LoadByVirtualPath(string virtualPath)
    {
        if ((!virtualPath.StartsWith("http")) && System.IO.File.Exists(HttpContext.Current.Server.MapPath(virtualPath)))
        {
            return;
        }

        currentVirtualPath = virtualPath;

        if (currentLanguage == null)
        {
            throw new Exception("Error loading default language");
        }

        if ((currentVirtualPath == "~/") || currentVirtualPath == URIHelper.ConvertAbsUrlToTilda(URIHelper.ConvertToAbsUrl(currentLanguage.UriSegment)))
        {
            long version = 0;
            long.TryParse(HttpContext.Current.Request["version"], out version);

            currentMediaDetail = WebsitesMapper.GetWebsite(version);
        }
        else
        {
            currentMediaDetail = MediaDetailsMapper.GetByVirtualPath(currentVirtualPath);
        }

        if (currentMediaDetail == null)
        {
            return;
        }

        currentLanguage = currentMediaDetail.Language;
        FrameworkSettings.SetCurrentLanguage(currentMediaDetail.Language);

        //rootMedia = FrameworkSettings.RootMedia;
        //rootMediaDetail = FrameworkSettings.RootMediaDetail;

        currentMedia = currentMediaDetail.Media;
    }
        private void BindRootMedia(Media rootMedia)
        {
            /*var cache = FileCacheHelper.GetGenerateNavCache();
             *
             * if (!cache.IsError)
             * {
             *  var cacheData = cache.GetRawData<string>();
             *
             *  if (cacheData != "")
             *  {
             *      return;
             *  }
             * }*/

            var items = new List <IMediaDetail>();

            if (!IsBreadCrumbMenu)
            {
                /*var itemsCacheKey = $"{rootMedia.ID}_Items";
                 * var itemsCacheData = (List<IMediaDetail>)ContextHelper.GetFromCache(itemsCacheKey);
                 *
                 * if (itemsCacheData != null)
                 * {
                 *  return;
                 * }
                 * else
                 * {*/
                /*var items = MediaDetailsMapper.GetDataModel().MediaDetails.AsNoTracking().Where(i => i.Media.ParentMediaID == rootMedia.ID && i.HistoryVersionNumber == 0 && i.LanguageID == currentLanguage.ID && !i.IsDeleted && i.PublishDate <= DateTime.Now && (i.ExpiryDate == null || i.ExpiryDate > DateTime.Now)).OrderBy(i => i.Media.OrderIndex); //rootMedia.ChildMedias.SelectMany(m => m.MediaDetails.Where(i => i.HistoryVersionNumber == 0 && (i.ShowInMenu || i.RenderInFooter) && !i.IsDeleted && i.PostPublishDate <= DateTime.Now && (i.PostExpiryDate == null || i.PostExpiryDate > DateTime.Now))).OrderBy(i => i.Media.OrderIndex);
                 * Bind(items);*/

                //var mediaDetail = BaseMapper.GetDataModel().MediaDetails.FirstOrDefault(i => i.MediaID == rootMedia.ID && i.LanguageID == BasePage.CurrentLanguage.ID);

                var mediaDetail = rootMedia.GetLiveMediaDetail();

                if (mediaDetail == null || mediaDetail.MediaType == null)
                {
                    return;
                }

                if (mediaDetail.MediaType.Name == MediaTypeEnum.RootPage.ToString())
                {
                    rootMedia = WebsitesMapper.GetWebsite().Media;
                }

                var children = MediaDetailsMapper.GetDataModel().MediaDetails.Where(i => i.ShowInMenu && i.Media.ParentMediaID == rootMedia.ID && i.HistoryVersionNumber == 0 && i.LanguageID == currentLanguage.ID && !i.IsDeleted && i.PublishDate <= DateTime.Now && (i.ExpiryDate == null || i.ExpiryDate > DateTime.Now)).OrderBy(i => i.Media.OrderIndex).ToList();     //rootMedia.ChildMedias.SelectMany(m => m.MediaDetails.Where(i => i.HistoryVersionNumber == 0 && (i.ShowInMenu || i.RenderInFooter) && !i.IsDeleted && i.PostPublishDate <= DateTime.Now && (i.PostExpiryDate == null || i.PostExpiryDate > DateTime.Now))).OrderBy(i => i.Media.OrderIndex);
                items.AddRange(children);
                //items = mediaDetail.ChildMediaDetails.Where(i=>i.ShowInMenu).ToList();

                if (!items.Any() && RenderParentNavIfNoChildren)
                {
                    items = mediaDetail.Media.ParentMedia.GetLiveMediaDetail(mediaDetail.Language).ChildMediaDetails.Where(i => i.ShowInMenu).ToList();
                }

                //ContextHelper.SaveToCache(itemsCacheKey, itemsCacheData);
                // }
            }
            else
            {
                items = MediaDetailsMapper.GetAllParentMediaDetails(this.BasePage.CurrentMediaDetail, this.BasePage.CurrentLanguage).ToList();
            }

            Bind(items);
        }