Exemplo n.º 1
0
        public void Process(SorentoLib.Session Session)
        {
            // True if function returns successfully.
            bool success = false;

            // TODO: fix all this.
            string resulttemplate = string.Empty;

            // Find Addin to handle resolve.
            SorentoLib.Tools.ParseTypeName typename = new SorentoLib.Tools.ParseTypeName (Session.Request.QueryJar.Get ("cmd.function").Value);
            foreach (SorentoLib.Addins.IFunction function in AddinManager.GetExtensionObjects (typeof(SorentoLib.Addins.IFunction)))
            {
                if (function.IsProvided (typename.Namspace))
                {
                    success = function.Process (Session, typename.Fullname, typename.Method);
                    break;
                }
            }

            // If function returned successfully we need to show the success page, if it has been specified.
            if (success)
            {
                if (Session.Request.QueryJar.Exist ("cmd.onsuccess"))
                {
                    resulttemplate = Session.Request.QueryJar.Get ("cmd.onsuccess").Value;
                }
            }
            // If function returned unsuccessfull we should show the error page, if it has been specified.
            else
            {
                if (Session.Request.QueryJar.Exist ("cmd.onerror"))
                {
                    resulttemplate = Session.Request.QueryJar.Get ("cmd.onerror").Value;
                }
            }

            // If redirect has been specfied lets do that. This is good for hiding POST urls.
            if (Session.Request.QueryJar.Exist ("cmd.redirect"))
            {
                if (Session.Request.QueryJar.Get ("cmd.redirect").Value.ToLower () == "true")
                {
                    Session.Page.Clear ();
                    Session.Page.Redirect = resulttemplate;
            //					Session.Page.Lines.Add(@"<meta HTTP-EQUIV=""REFRESH"" content=""0; url="+ resulttemplate +@""">");
                    Session.Responder.Request.SendOutputText (Session.Page.Write (Session));
                    return;
                }
            }

            if (resulttemplate != string.Empty)
            {
                SorentoLib.Render.Template template = new SorentoLib.Render.Template (Session, resulttemplate);
                template.Render ();
                template = null;
            }

            Session.Responder.Request.SendOutputText (Session.Page.Write (Session));
        }
Exemplo n.º 2
0
        public void Process(SorentoLib.Session Session)
        {
            // TODO: fix all this.
            string resulttemplate = string.Empty;

            SorentoLib.Tools.ParseTypeName typename = new SorentoLib.Tools.ParseTypeName (Session.Request.QueryJar.Get ("cmd.function").Value);

            // Find Addin to handle resolve.
            foreach (SorentoLib.Addins.IFunction function in AddinManager.GetExtensionObjects (typeof(SorentoLib.Addins.IFunction)))
            {
                if (function.IsProvided (typename.Namspace))
                {
                    if (function.Process (Session, typename.Fullname, typename.Method))
                    {
                        if (Session.Request.QueryJar.Exist ("cmd.onsuccess"))
                        {
                            resulttemplate = Session.Request.QueryJar.Get ("cmd.onsuccess").Value;
                        }
                        else
                        {
                            resulttemplate = "";
                        }
                    }
                    else
                    {

                        if (Session.Request.QueryJar.Exist ("cmd.onerror"))
                        {
                            resulttemplate = Session.Request.QueryJar.Get ("cmd.onerror").Value;
                        }
                        else
                        {
                            resulttemplate = "";
                        }
                    }
                    break;
                }
            }

            if (Session.Request.QueryJar.Exist ("cmd.redirect"))
            {
                if (Session.Request.QueryJar.Get ("cmd.redirect").Value.ToLower () == "true")
                {
                    Session.Page.Clear ();
                    Session.Page.Redirect = resulttemplate;
            //					Session.Page.Lines.Add(@"<meta HTTP-EQUIV=""REFRESH"" content=""0; url="+ resulttemplate +@""">");
                    Session.Responder.Request.SendOutputText (Session.Page.Write (Session));
                    return;
                }
            }

            SorentoLib.Render.Template template = new SorentoLib.Render.Template (Session, resulttemplate);
            template.Render ();
            template = null;

            Session.Responder.Request.SendOutputText (Session.Page.Write (Session));
        }
Exemplo n.º 3
0
        public void Process(SorentoLib.Session session)
        {
            SorentoLib.Ajax.Respons respons = null;
            SorentoLib.Tools.ParseTypeName typename = new SorentoLib.Tools.ParseTypeName (session.Request.QueryJar.Get ("cmd.function").Value);

            try
            {
                // Find ajax addin that can respond to this request.
                foreach (SorentoLib.Addins.IAjax ajax in AddinManager.GetExtensionObjects (typeof (SorentoLib.Addins.IAjax)))
                {

                    if (ajax.IsProvided (typename.Namspace))
                    {
                        respons = ajax.Process (session, typename.Fullname, typename.Method);

                        Hashtable status = new Hashtable ();
                        status.Add ("success", true);
                        respons.Add (status);

                        break;
                    }
                }

                // If no addin was found, throw exception.
                if (respons == null)
                {
                    throw new Exception (string.Format ("[AJAX]: Namespace '{0}' was not found.", typename.Namspace));
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine (exception);
                // Handel exceptions, and parse the information onto the client.
                respons = new SorentoLib.Ajax.Respons ();

                Hashtable status = new Hashtable ();
                status.Add ("success", false);
                status.Add ("exception", exception.Message);

                respons.Add (status);
            }

            // Output ajax respons.
            session.Responder.Request.SendOutputText (session.Request.HttpHeader ("UTF-8", "text/xml"));
            session.Responder.Request.SendOutputText ("\n" + respons.XmlDocument.OuterXml);

            // Cleanup
            typename = null;
            respons = null;
        }