Пример #1
0
        private AuroraXmlDocument GetXML(string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters)
        {
            IWebInterfacePage page = GetPage(filename);

            if (page != null)
            {
                ITranslator translator = null;
                if (httpRequest.Query.ContainsKey("language"))
                {
                    translator = _translators.FirstOrDefault(t => t.LanguageName == httpRequest.Query["language"].ToString());
                }
                if (translator == null)
                {
                    translator = _defaultTranslator;
                }

                if (page.RequiresAuthentication)
                {
                    if (!Authenticator.CheckAuthentication(httpRequest))
                    {
                        return(null);
                    }
                    if (page.RequiresAdminAuthentication)
                    {
                        if (!Authenticator.CheckAdminAuthentication(httpRequest))
                        {
                            return(null);
                        }
                    }
                }
                return((AuroraXmlDocument)page.Fill(this, filename, httpRequest, httpResponse, requestParameters, translator)["xml"]);
            }
            return(null);
        }
Пример #2
0
        protected Dictionary <string, object> AddVarsForPage(string filename, string parentFileName,
                                                             OSHttpRequest httpRequest, OSHttpResponse httpResponse,
                                                             Dictionary <string, object> requestParameters,
                                                             out string response)
        {
            response = null;
            Dictionary <string, object> vars = new Dictionary <string, object>();
            IWebInterfacePage           page = GetPage(filename);

            if (page != null)
            {
                ITranslator translator = null;
                if (httpRequest.Query.ContainsKey("language"))
                {
                    translator =
                        _translators.FirstOrDefault(t => t.LanguageName == httpRequest.Query["language"].ToString());
                    httpResponse.AddCookie(new System.Web.HttpCookie("language",
                                                                     httpRequest.Query["language"].ToString()));
                }
                else if (httpRequest.Cookies.Get("language") != null)
                {
                    var cookie = httpRequest.Cookies.Get("language");
                    translator = _translators.FirstOrDefault(t => t.LanguageName == cookie.Value);
                }
                if (translator == null)
                {
                    translator = _defaultTranslator;
                }

                if (page.RequiresAuthentication)
                {
                    if (!Authenticator.CheckAuthentication(httpRequest))
                    {
                        return(null);
                    }
                }
                if (page.RequiresAdminAuthentication)
                {
                    if (!Authenticator.CheckAdminAuthentication(httpRequest))
                    {
                        return(null);
                    }
                }
                vars = page.Fill(this, parentFileName, httpRequest, httpResponse, requestParameters, translator,
                                 out response);
                return(vars);
            }
            return(null);
        }