示例#1
0
        protected override void OnPreLoad(EventArgs e)
        {
            //base.OnPreLoad(e);

            if (RecentPages == null)
            {
                RecentPages = new List <PageContext>();
            }


            var currentPageContext = new PageContext();

            currentPageContext.Path = AppRelativeVirtualPath;

            if (string.IsNullOrEmpty(CurrentPageTitle))
            {
                currentPageContext.Title = this.Title;
            }
            else
            {
                currentPageContext.Title = CurrentPageTitle;
            }
            currentPageContext.AbsoluteUri = Request.Url.AbsoluteUri;

            var currentPageName = System.IO.Path.GetFileNameWithoutExtension(VirtualPathUtility.GetFileName(Request.Path));

            currentPageContext.Name = currentPageName;

            var currentPageUrlParameters = new List <string>();

            foreach (string key in Request.QueryString.Keys)
            {
                currentPageUrlParameters.Add(key + "=" + Request.QueryString[key]);
            }

            currentPageContext.UrlParamaters = currentPageUrlParameters;

            var index = RecentPages.FindIndex(recPageContext => MatchesContext(recPageContext, currentPageName, currentPageUrlParameters));

            if (index == -1)
            {
                //Костылек
                var recentPageContext = RecentPages.FirstOrDefault(item => item.Name == "EntityListAttributeView");
                if (recentPageContext != null && currentPageName == "EntityListAttributeView")
                {
                    RecentPages.Remove(recentPageContext);
                    RecentPages.Add(currentPageContext);
                }
                else
                {
                    RecentPages.Add(currentPageContext);
                }
            }
            else
            {
                RecentPages.RemoveRange(index + 1);
            }
        }
示例#2
0
        protected override void OnPreLoad(EventArgs e)
        {
            base.OnPreLoad(e);

            if (RecentPages == null)
            {
                RecentPages = new List <PageContext>();
            }

            var currentPageName   = System.IO.Path.GetFileNameWithoutExtension(VirtualPathUtility.GetFileName(Request.Path));
            var pageUrlParameters = new List <string>();

            foreach (string key in Request.QueryString.Keys)
            {
                pageUrlParameters.Add(key + "=" + Request.QueryString[key]);
            }

            string target = string.Empty;

            bool me = false;


            if (RecentPages.Count == 0 && currentPageName != "environment")
            {
                RecentPages.Add(new PageContext
                {
                    Path          = "~/environment.aspx",
                    Title         = this.Title,// "Система",
                    UrlParamaters = new List <string>(),
                    Redirect      = true
                });
            }

            if (PreviousPage != null && PreviousPage is BasePage)
            {
                var previousPage = PreviousPage as BasePage;
                var recentPages  = previousPage.RecentPages;


                RecentPages = GetPageHistory(recentPages, currentPageName, pageUrlParameters, out me);

                if (!string.IsNullOrEmpty(previousPage.ObjectName))
                {
                    target = previousPage.ObjectName;
                }
                else if (Request["target"] != null)
                {
                    target = Request["target"];
                }

                ObjectName = string.Empty;
            }

            if (!me)
            {
                if (!IsPostBack)
                {
                    var context = new PageContext();
                    context.Name          = currentPageName;
                    context.Path          = AppRelativeVirtualPath;
                    context.TargetName    = target;
                    context.UrlParamaters = pageUrlParameters;
                    context.AbsoluteUri   = Request.Url.AbsoluteUri;


                    //Костыль
                    if (context.Path == "~/environment.aspx")
                    {
                        context.Redirect = true;
                    }


                    if (string.IsNullOrEmpty(PageTitle))
                    {
                        if (!string.IsNullOrEmpty(Title))
                        {
                            context.Title = Title + " " + target;
                        }
                        else
                        {
                            context.Title = currentPageName;
                        }
                    }
                    else
                    {
                        context.Title = PageTitle;
                    }


                    var AbsPuth = RecentPages.FirstOrDefault(ap => ap.AbsoluteUri == context.AbsoluteUri);

                    if (AbsPuth == null)
                    {
                        RecentPages.Add(context);
                    }
                }

                else if (!IsCrossPagePostBack)
                {
                    var index = RecentPages.FindIndex(item => MatchesContext(item, currentPageName, pageUrlParameters));

                    if (index == -1)
                    {
                        var context = new PageContext();
                        context.Name          = currentPageName;
                        context.Path          = AppRelativeVirtualPath;
                        context.UrlParamaters = pageUrlParameters;
                        context.Title         = PageTitle;

                        RecentPages.Add(context);

                        context.AbsoluteUri = Request.Url.AbsoluteUri;
                    }
                    else
                    {
                        RecentPages.RemoveRange(index + 1);
                    }
                    ObjectName = string.Empty;
                }
            }
        }