Esempio n. 1
0
        /// <summary>
        /// Main function that retrieves the list from API, including paging
        /// </summary>
        /// <param name="url">URL of API request</param>
        /// <param name="haveSoFar">Number of pages already retrieved, for upper limit control</param>
        /// <returns>List of pages</returns>
        public List <Article> ApiMakeList(string url, int haveSoFar)
        {
            // TODO: error handling
            List <Article> list    = new List <Article>();
            string         postfix = "";

            string newUrl = url;

            ApiEdit editor = Variables.MainForm.TheSession.Editor.SynchronousEditor;

            while (list.Count + haveSoFar < Limit)
            {
                string text = editor.QueryApi(newUrl + postfix); //Hacky hack hack

                XmlTextReader xml = new XmlTextReader(new StringReader(text));
                xml.MoveToContent();
                postfix = "";

                while (xml.Read())
                {
                    if (xml.Name == "query-continue")
                    {
                        XmlReader r = xml.ReadSubtree();

                        r.Read();

                        while (r.Read())
                        {
                            if (!r.IsStartElement())
                            {
                                continue;
                            }
                            if (!r.MoveToFirstAttribute())
                            {
                                throw new FormatException("Malformed element '" + r.Name + "' in <query-continue>");
                            }
                            postfix += "&" + r.Name + "=" + HttpUtility.UrlEncode(r.Value);
                        }
                    }
                    else if (PageElements.Contains(xml.Name) && xml.IsStartElement())
                    {
                        if (!EvaluateXmlElement(xml))
                        {
                            continue;
                        }

                        int ns;
                        int.TryParse(xml.GetAttribute("ns"), out ns);
                        string name = xml.GetAttribute("title");

                        if (string.IsNullOrEmpty(name))
                        {
                            System.Windows.Forms.MessageBox.Show(xml.ReadInnerXml());
                            break;
                        }

                        list.Add(ns >= 0 ? new Article(name, ns) : new Article(name));
                    }
                }
                if (string.IsNullOrEmpty(postfix))
                {
                    break;
                }
            }

            return(list);
        }
Esempio n. 2
0
        /// <summary>
        /// Main function that retrieves the list from API, including paging
        /// </summary>
        /// <param name="url">URL of API request</param>
        /// <param name="haveSoFar">Number of pages already retrieved, for upper limit control</param>
        /// <returns>List of pages</returns>
        public List <Article> ApiMakeList(string url, int haveSoFar)
        {
            // TODO: error handling
            List <Article> list    = new List <Article>();
            string         postfix = "";

            string newUrl = url;

            if (Hack1_12)
            {
                newUrl = RemoveCmcategory.Replace(newUrl, "");
            }

            while (list.Count + haveSoFar < Limit)
            {
                string text = Tools.GetHTML(newUrl + postfix);
                if (text.Contains("code=\"cmtitleandcategory\""))
                {
                    if (Hack1_12)
                    {
                        throw new ListProviderException("cmtitleandcategory persists.");
                    }

                    Hack1_12 = true;
                    newUrl   = RemoveCmcategory.Replace(url, "");
                    text     = Tools.GetHTML(newUrl + postfix);
                }

                XmlTextReader xml = new XmlTextReader(new StringReader(text));
                xml.MoveToContent();
                postfix = "";

                while (xml.Read())
                {
                    if (xml.Name == "query-continue")
                    {
                        XmlReader r = xml.ReadSubtree();

                        r.Read();

                        while (r.Read())
                        {
                            if (!r.IsStartElement())
                            {
                                continue;
                            }
                            if (!r.MoveToFirstAttribute())
                            {
                                throw new FormatException("Malformed element '" + r.Name + "' in <query-continue>");
                            }
                            postfix += "&" + r.Name + "=" + HttpUtility.UrlEncode(r.Value);
                        }
                    }
                    else if (PageElements.Contains(xml.Name) && xml.IsStartElement())
                    {
                        if (!EvaluateXmlElement(xml))
                        {
                            continue;
                        }

                        //int ns = -1;
                        //int.TryParse(xml.GetAttribute("ns"), out ns);
                        string name = xml.GetAttribute("title");

                        if (string.IsNullOrEmpty(name))
                        {
                            System.Windows.Forms.MessageBox.Show(xml.ReadInnerXml());
                            break;
                        }

                        // HACK: commented out until we make AWB always load namespaces from the wiki,
                        // to avoid problems with unknown namespace
                        //if (ns >= 0) list.Add(new Article(name, ns));
                        //else
                        list.Add(new Article(name));
                    }
                }
                if (string.IsNullOrEmpty(postfix))
                {
                    break;
                }
            }

            return(list);
        }
Esempio n. 3
0
        public PaymentDetails(IWebDriver driver)
        {
            Wait_Suffix(driver, "lblPricingHeader", 10);

            elements = new PageElements(driver, xpaths);
        }
 public ContactDetailsModal(IWebDriver driver)
 {
     elements = new PageElements(driver, xpaths);
 }
Esempio n. 5
0
 public ThankYou(IWebDriver driver)
 {
     this.driver = driver;
     WaitUtils.WaitXpe(driver, xpaths["thankYou"], 120);
     elements = new PageElements(driver, xpaths);
 }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Begin recording the time for the request to be processed
        Stopwatch timer = new Stopwatch();

        timer.Start();
        // Check the core is operational
        switch (Core.state)
        {
        case Core.State.NotInstalled:
            Response.Redirect("/install", true);
            break;

        case Core.State.CriticalFailure:
            Response.Write("<html><head><title>Uber CMS - Critical Failure</title></head><body>");
            Response.Write("<h1>Core Failure - Critical Error</h1>");
            Response.Write("<h2>Error</h2><p>" + Core.criticalFailureError.Message + "</p><h2>Stack-trace</h2><p>" + Core.criticalFailureError.StackTrace + "</p>");
            Response.Write("<h2>Base Error</h2><p>" + Core.criticalFailureError.GetBaseException().Message + "</p><h2>Base Stack-trace</h2><p>" + Core.criticalFailureError.GetBaseException().StackTrace + "</p>");
            Response.Write("</body></html>");
            Response.End();
            break;

        case Core.State.Stopped:
            Core.cmsStart();
            break;
        }
        // Setup the request
        conn            = Core.connectorCreate(true);
        elements        = new PageElements();
        elements["URL"] = ResolveUrl("");
        // If debugging, reload cached templates
#if DEBUG
        Core.templates.reloadDb(conn);
#endif
        // Invoke the pre-handler methods
        Result plugins = conn.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' AND handles_request_start='1' ORDER BY invoke_order ASC");
        foreach (ResultRow plugin in plugins)
        {
            Plugins.invokeMethod(plugin["classpath"], "requestStart", new object[] { plugin["pluginid"], conn, elements, Request, Response });
        }

        // Invoke the plugin responsible for handling the request
        int i;
        Plugins.Request.RequestHandler  handler;
        Plugins.Request.RequestHandlers handlers = Plugins.Request.getRequestPlugin(conn, Request);
        for (i = 0; i < handlers.count() && elements["CONTENT"] == null; i++)
        {
            handler = handlers[i];
            Plugins.invokeMethod(handler.ClassPath, "handleRequest", new object[] { handler.Pluginid, conn, elements, Request, Response });
        }
        // If no content has been set, a 404 has occurred - hence find a plugin to handle this issue
        if (elements["CONTENT"] == null)
        {
            handlers = Plugins.Request.getRequest404s(conn);
            for (i = 0; i < handlers.count() && elements["CONTENT"] == null; i++)
            {
                handler = handlers[i];
                Plugins.invokeMethod(handler.ClassPath, "handleRequestNotFound", new object[] { handler.Pluginid, conn, elements, Request, Response });
            }
        }
        // Check if any content has still not been set - if so we'll display a manual error to inform the user/developer/administrator/operator
        if (elements["CONTENT"] == null)
        {
            // 404 not found...
            elements["TITLE"]   = "Page Not Found";
            elements["CONTENT"] = "<p>The requested page could not be found and a 404 page could not be served...</p>";
        }
        // Invoke the post-handler methods
        plugins = conn.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' AND handles_request_end='1' ORDER BY invoke_order ASC");
        foreach (ResultRow plugin in plugins)
        {
            try
            {
                Plugins.invokeMethod(plugin["classpath"], "requestEnd", new object[] { plugin["pluginid"], conn, elements, Request, Response });
            }
            catch { }
        }
        // Format the site template
        StringBuilder content = new StringBuilder(Core.templates.get(elements["TEMPLATE"], "base", null) ?? string.Empty);
        // Stop the timer and set element
        timer.Stop();
        elements["BENCH_MARK"] = "Generated in " + timer.ElapsedMilliseconds + " m/s (" + ((float)timer.ElapsedMilliseconds / 1000) + " secs)";
        // Replace elements within template
        elements.replaceElements(ref content, 0, 3);
        // Output the built page to the user
        Response.Write(content.ToString());
        // Dispose connector
        conn.Disconnect();
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Begin recording the time for the request to be processed
        Stopwatch timer = new Stopwatch();
        timer.Start();
        // Check the core is operational
        switch (Core.state)
        {
            case Core.State.NotInstalled:
                Response.Redirect("/install", true);
                break;
            case Core.State.CriticalFailure:
                Response.Write("<html><head><title>Uber CMS - Critical Failure</title></head><body>");
                Response.Write("<h1>Core Failure - Critical Error</h1>");
                Response.Write("<h2>Error</h2><p>" + Core.criticalFailureError.Message + "</p><h2>Stack-trace</h2><p>" + Core.criticalFailureError.StackTrace + "</p>");
                Response.Write("<h2>Base Error</h2><p>" + Core.criticalFailureError.GetBaseException().Message + "</p><h2>Base Stack-trace</h2><p>" + Core.criticalFailureError.GetBaseException().StackTrace + "</p>");
                Response.Write("</body></html>");
                Response.End();
                break;
            case Core.State.Stopped:
                Core.cmsStart();
                break;
        }
        // Setup the request
        conn = Core.connectorCreate(true);
        elements = new PageElements();
        elements["URL"] = ResolveUrl("");
        // If debugging, reload cached templates
        #if DEBUG
        Core.templates.reloadDb(conn);
        #endif
        // Invoke the pre-handler methods
        Result plugins = conn.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' AND handles_request_start='1' ORDER BY invoke_order ASC");
        foreach (ResultRow plugin in plugins)
            Plugins.invokeMethod(plugin["classpath"], "requestStart", new object[] { plugin["pluginid"], conn, elements, Request, Response });

        // Invoke the plugin responsible for handling the request
        int i;
        Plugins.Request.RequestHandler handler;
        Plugins.Request.RequestHandlers handlers = Plugins.Request.getRequestPlugin(conn, Request);
        for (i = 0; i < handlers.count() && elements["CONTENT"] == null; i++)
        {
            handler = handlers[i];
            Plugins.invokeMethod(handler.ClassPath, "handleRequest", new object[] { handler.Pluginid, conn, elements, Request, Response });
        }
        // If no content has been set, a 404 has occurred - hence find a plugin to handle this issue
        if (elements["CONTENT"] == null)
        {
            handlers = Plugins.Request.getRequest404s(conn);
            for (i = 0; i < handlers.count() && elements["CONTENT"] == null; i++)
            {
                handler = handlers[i];
                Plugins.invokeMethod(handler.ClassPath, "handleRequestNotFound", new object[] { handler.Pluginid, conn, elements, Request, Response });
            }
        }
        // Check if any content has still not been set - if so we'll display a manual error to inform the user/developer/administrator/operator
        if(elements["CONTENT"] == null)
        {
            // 404 not found...
            elements["TITLE"] = "Page Not Found";
            elements["CONTENT"] = "<p>The requested page could not be found and a 404 page could not be served...</p>";
        }
        // Invoke the post-handler methods
        plugins = conn.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' AND handles_request_end='1' ORDER BY invoke_order ASC");
        foreach (ResultRow plugin in plugins)
            try
            {
                Plugins.invokeMethod(plugin["classpath"], "requestEnd", new object[] { plugin["pluginid"], conn, elements, Request, Response });
            }
            catch { }
        // Format the site template
        StringBuilder content = new StringBuilder(Core.templates.get(elements["TEMPLATE"], "base", null) ?? string.Empty);
        // Stop the timer and set element
        timer.Stop();
        elements["BENCH_MARK"] = "Generated in " + timer.ElapsedMilliseconds + " m/s (" + ((float)timer.ElapsedMilliseconds / 1000) + " secs)";
        // Replace elements within template
        elements.replaceElements(ref content, 0, 3);
        // Output the built page to the user
        Response.Write(content.ToString());
        // Dispose connector
        conn.Disconnect();
    }
Esempio n. 8
0
        public PayPalContinue(IWebDriver driver)
        {
            WaitUtils.WaitId(driver, "continue_abovefold", 30);

            elements = new PageElements(driver, xpaths);
        }
Esempio n. 9
0
        public PayPalLogin(IWebDriver driver)
        {
            WaitUtils.WaitId(driver, "login_email", 10);

            elements = new PageElements(driver, xpaths);
        }
Esempio n. 10
0
        public PayPalConfirm(IWebDriver driver)
        {
            Wait_Suffix(driver, "btnPayPalConfirm", 120);

            elements = new PageElements(driver, xpaths);
        }
Esempio n. 11
0
        public PayPalLogin2(IWebDriver driver)
        {
            WaitUtils.WaitId(driver, "btnLogin", 10);

            elements = new PageElements(driver, xpaths);
        }