Beispiel #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);
            }
        }
Beispiel #2
0
        private void goToPreviosPage()
        {
            //var page = Page as BasePage;

            var currentPageContext = RecentPages.Last();
            var index = RecentPages.FindIndex(item => item.AbsoluteUri == currentPageContext.AbsoluteUri);

            if (index > 0)
            {
                var previosPage = RecentPages[index - 1];
                Response.Redirect(previosPage.AbsoluteUri);
            }


            //var parameters = string.Empty;

            //if (previosPage.UrlParamaters.Count > 0)
            //{
            //    parameters = previosPage.UrlParamaters.Aggregate((ready, next) => ready + "&" + next);

            //    if (!string.IsNullOrEmpty(parameters))
            //        parameters = "?" + parameters;


            //    var goAweyPath = AppRelativeVirtualPath.Replace(@"~", "");
            //    if (!previosPage.AbsoluteUri.Contains(goAweyPath))
            //        ReturnControl(previosPage.AbsoluteUri);
            //    else
            //    {
            //        var previosPath = string.Concat(previosPage.Path, parameters);
            //        if (!string.IsNullOrEmpty(previosPath))
            //            Server.Transfer(previosPath);

            //    }

            //}
        }
Beispiel #3
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;
                }
            }
        }