Esempio n. 1
0
        private void Page_Unload(object sender, EventArgs e)
        {
            if (moduleSession != null)
            {
                foreach (Contract.Module module in moduleSession.GetLoadedModules())
                {
                    if (moduleSession.GetInstance(module) != null)
                    {
                        Debug.StartTimer("Module:" + module.ID + ":Deinitialize()");

                        try { moduleSession.GetInstance(module).Deinitialize(); }
                        catch { }

                        Debug.StopTimer("Module:" + module.ID + ":Deinitialize()");
                    }
                }
            }

            //System.Diagnostics.Trace.TraceInformation(Debug.Output);
        }
Esempio n. 2
0
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                #region Signing stuff
                //string CompiledKeySignature = "ACQAAASAAACUAAAABgIAAAAkAABSU0ExAAQAAAEAAQDdmZjq3STJVDfs8UsPnWlObTAO3q2S6ksjcEcNZyjndUVSBsg7Taeyl13TQIZvdcs7JotZxqFN/6Ix+A5D3luYGwfalRsPUm4MSo8tHgVg2frb8KkgxJnb8ma7d+KWdliykrAFfaCamF9xDAUxNPapzO4u2ip1m0IiL9Y9JCGFnw==";
                //string AssemblyKeySignature = Convert.ToBase64String(Assembly.GetExecutingAssembly().GetName().GetPublicKey());

                //if (CompiledKeySignature != AssemblyKeySignature)
                //throw new Exception("WebCore modification has been detected. This is a voilation of the BlazeSoft terms of service and has been reported to BlazeSoft.");
                #endregion

                Debug.StartTimer("PageLoad");
                Debug.WriteLine("Page Access Count: {0}", ++PageAccessCount);

                string httpProtocol = (Request.IsSecureConnection) ? "https://" : "http://";
                this.pageUri = new Uri(httpProtocol + Request.Url.Host + Request.RawUrl);

                #if !DEBUG
                if (SettingsManager.Session.GetSystemSetting("IsSetup", false) == false)
                {
                    if (Request.UserHostAddress != "::1")
                    {
                        Response.Write("We're sorry. This web site has not been set up yet.");
                        return;
                    }
                    else
                    {
                        pageUri = pageUri.ChangePageUriPath("/administration/setup");
                    }
                }
                #endif

                if (pageUri.AbsolutePath.ToLower().StartsWith("/themes"))
                {
                    string[] urlParts = pageUri.AbsolutePath.ToLower().Split('/');

                    if (urlParts.Length >= 4)
                    {
                        string themeKey = urlParts[2];
                        string assetKey = string.Join("/", urlParts, 3, urlParts.Length - 3);

                        Theme theme = ThemeManager.Session.GetTheme(themeKey);

                        if (theme == null)
                        {
                            throw new Exceptions.PageNotFoundException();
                        }

                        Asset asset = theme.GetAsset(assetKey);

                        if (asset == null)
                        {
                            throw new Exceptions.PageNotFoundException();
                        }

                        Response.ContentType = asset.MimeType;
                        Response.BinaryWrite(asset.Data);

                        Response.End();
                    }
                    else
                    {
                        throw new Exceptions.PageNotFoundException();
                    }
                }
                else
                {
                    moduleSession = new ModuleSession(HttpContext.Current);

                    foreach (Contract.Module module in moduleSession.GetLoadedModules())
                    {
                        if (moduleSession.GetInstance(module) != null)
                        {
                            pageUri = moduleSession.GetInstance(module).GetPageUri(pageUri);
                        }
                    }

                    Uri newPageUri = pageUri;

                    foreach (Contract.Module module in moduleSession.GetLoadedModules())
                    {
                        if (moduleSession.GetInstance(module) != null)
                        {
                            newPageUri = moduleSession.GetInstance(module).GetPageRedirect(newPageUri);
                        }
                    }

                    if (newPageUri.ToString() != pageUri.ToString())
                    {
                        Response.Redirect(newPageUri.ToString());
                    }

                    Contract.Page page = PageManager.Session.GetPageByUri(pageUri);

                    if (page == null)
                    {
                        throw new Exceptions.PageNotFoundException();
                    }

                    if (page.CompilerLanguage == "Html")
                    {
                        var htmlPageInstance = new Page();
                        htmlPageInstance.CorePage      = page;
                        htmlPageInstance.ModuleSession = moduleSession;

                        Response.Write(ThemeManager.Session.ParseTemplate(string.Join("\r\n", page.LatestReversion.Classes.Select(c => c.Data)), page, htmlPageInstance, moduleSession));
                    }
                    else
                    {
                        //PageManager.Session.CompilePages();

                        Page PageInstance = page.Instance;

                        if (PageInstance != null)
                        {
                            PageInstance.CorePage      = page;
                            PageInstance.ModuleSession = moduleSession;

                            Debug.StartTimer("Page:" + page.ID + ":Initialize()");
                            PageInstance.Initialize();
                            Debug.StopTimer("Page:" + page.ID + ":Initialize()");
                            string Output = PageInstance.Themes.GetHtmlOutput(page, PageInstance, moduleSession);
                            Debug.StartTimer("Page:" + page.ID + ":Deinitialize()");
                            PageInstance.Deinitialize();
                            Debug.StopTimer("Page:" + page.ID + ":Deinitialize()");

                            Response.Write(Output);
                        }
                    }
                }

                Debug.StopTimer("PageLoad");

                #if DEBUG
                Response.Write(Debug.Output);
                #else
                //if(SettingsCore.Instance.GetSystemSetting("InDev", false))
                Response.Write(Debug.Output);
                #endif
            }
            catch (ThreadAbortException) { this.Page_Unload(sender, e); }
        }