示例#1
0
            public void execute()
            {
                String strUrl = "";

                if (m_nCommand == scDispatch)
                {
                    strUrl = m_Parent.processDispatch(m_route, m_method, m_uri, m_query, m_body);
                }
                else if (m_nCommand == scIndex)
                {
                    strUrl = m_Parent.processIndex(m_route, m_method, m_uri, m_query, m_body);
                }

                RHODESAPP().processWebNavigate(strUrl, -1);
            }
示例#2
0
            public void execute()
            {
                String      strUrl = "";
                IDictionary result = null;

                if (m_nCommand == scDispatch)
                {
                    result = m_Parent.processDispatch(m_route, m_method, m_uri, m_headers, m_query, m_body);
                    strUrl = result[RESPONSE_BODY_FILEPATH].ToString();

                    if (isAjaxRequest() && result[RESPONSE_STATUS].ToString().equals(HTTP_REDIRECT_CODE))
                    {
                        IDictionary headers = new Dictionary <String, String>();
                        headers["X-Requested-With"] = "XMLHttpRequest";
                        if (!RHODESAPP().HttpServer.processBrowserRequest(
                                "GET",
                                new Uri(strUrl, UriKind.Relative),
                                headers,
                                new Dictionary <String, String>(),
                                m_strAjaxContext,
                                m_iTabIndex
                                ))
                        {
                            LOG.ERROR("Ajax request redirection failed.");
                        }
                        return;
                    }
                }
                else if (m_nCommand == scIndex)
                {
                    result = m_Parent.processIndex(m_route, m_method, m_uri, m_headers, m_query, m_body);
                    strUrl = result[RESPONSE_BODY_FILEPATH].ToString();
                }

                if (!isAjaxRequest())
                {
                    RHODESAPP().processWebNavigate(strUrl, -1);
                }
                else
                {
                    String res = CRhoFile.isResourceFileExist(strUrl) ? CRhoFile.readStringFromResourceFile(strUrl) : CRhoFile.readFileToString(strUrl);


                    IDictionary   headers     = new Dictionary <String, String>();
                    StringBuilder jsonHeaders = new StringBuilder();
                    foreach (object key in result.Keys)
                    {
                        if (
                            key.ToString().startsWith(PARAM_PREFIX_REQ) ||
                            key.ToString().startsWith(PARAM_PREFIX_RESP) ||
                            key.ToString().equals(RESPONSE_STATUS_MESSAGE) ||
                            key.ToString().equals(RESPONSE_STATUS)
                            )
                        {
                            continue;
                        }
                        headers[key.ToString()] = result[key].ToString();
                        jsonHeaders.AppendFormat("{0}\"{1}\": \"{2}\"",
                                                 (0 < jsonHeaders.Length) ? ", " : "",
                                                 key.ToString(), result[key].ToString());
                    }

                    String[] args = new String[5];
                    args[0] = m_strAjaxContext;
                    args[1] = res;
                    args[2] = "{" + jsonHeaders + "}";
                    args[3] = result[RESPONSE_STATUS_MESSAGE] != null ? result[RESPONSE_STATUS_MESSAGE].ToString() : "";
                    args[4] = result[RESPONSE_STATUS] != null ? result[RESPONSE_STATUS].ToString() : "";

                    RHODESAPP().processInvokeScriptArgs(AJAX_CALLBACK_FUNCNAME, args, m_iTabIndex);
                }
            }