Пример #1
0
        public static string generateNavigation_html(string strPathToAnalyze, XmlNode xnSelectedDirectory, bool showFiles, bool verticalMenu)
        {
            string strFullPathToTempNavigationFilesDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory,
                                                                                       Path.Combine(ConfigurationManager.AppSettings["StaticPagePath"],
                                                                                                    Path.Combine("SiteA", ConfigurationManager.AppSettings["tempNavigationFiles"]))));
            string strTempFileName = strPathToAnalyze.Replace("/", "_") + ".htm";
            string strFullPathToTempFileWithDirectoryStructure = Path.Combine(strFullPathToTempNavigationFilesDir, strTempFileName);

            SiteGenerator_Transformers.generateDirectoryNavigation_html(xnSelectedDirectory, strPathToAnalyze, strFullPathToTempFileWithDirectoryStructure, showFiles, verticalMenu);
            return(strFullPathToTempFileWithDirectoryStructure);
        }
Пример #2
0
        public static string generateNavigation_flash(string strPathToAnalyze, XmlNode xnSelectedDirectory)
        {
            string strDynamicFlashMenuDir              = "flash_xml_menu";
            string strDynamicFlashHtmlFile             = "cromas_xml.htm";
            string strDynamicFlashXmlFile              = "cromas_menu.xml";
            string strFullPathToTempNavigationFilesDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory,
                                                                                       Path.Combine(ConfigurationManager.AppSettings["StaticPagePath"],
                                                                                                    Path.Combine("SiteA", strDynamicFlashMenuDir))));
            string strFullPathToHtmlWithDirectoryStructure        = Path.Combine(strFullPathToTempNavigationFilesDir, strDynamicFlashHtmlFile);
            string strFullPathToTempXmlFileWithDirectoryStructure = Path.Combine(strFullPathToTempNavigationFilesDir, strDynamicFlashXmlFile);

            SiteGenerator_Transformers.generateDirectoryNavigation_flash(xnSelectedDirectory, strFullPathToTempXmlFileWithDirectoryStructure, strPathToAnalyze);
            return(strFullPathToHtmlWithDirectoryStructure);
        }
Пример #3
0
        /// <summary>
        /// This method is used for handling the incoming data and deciding what needs
        /// to be done with it.
        /// </summary>
        /// <param name="receivedData"></param>
        private string ParseReceivedData(String receivedData)
        {
            // TODO: Refactor this ParseReceivedData method
            string response             = "";
            string strPathToCurrentSite = Path.GetFullPath(@ConfigurationManager.AppSettings["StaticPagePath"] + "//");

            string[] dataSplitIntoSegments = receivedData.Split(new string[] { ",-," }, StringSplitOptions.RemoveEmptyEntries);
            XmlNode  xnSelectedDirectory   = null;

            if ((dataSplitIntoSegments.Length > 1) && DoesRequestNeedAnAnswer(dataSplitIntoSegments[0]))
            {
                bool   bMatch      = false;
                string strQuestion = dataSplitIntoSegments[1];
                string CapitializedQuestionType = dataSplitIntoSegments[0].ToUpper();
                string strPathToAnalyze         = dataSplitIntoSegments[1];
                response = strQuestion; // by default make the answer = to question

                if (CapitializedQuestionType == "[SG_HTTPHANDLER]")
                {
                    response = SiteGenerator_Transformers.resolveNameAndFolder(strQuestion, ref bMatch);
                    if (SiteGenerator_Transformers.isPathAFolder(strPathToAnalyze, ref xnSelectedDirectory))
                    {
                        if ((null != xnSelectedDirectory) &&
                            (null != xnSelectedDirectory.Attributes.GetNamedItem("defaultPage")))
                        {
                            response = xnSelectedDirectory.Attributes.GetNamedItem("defaultPage").Value;

                            // If the document has no beginning slash we need to add that so the document
                            // can be found.
                            if (response[0] != '/')
                            {
                                response = "/" + response;
                            }

                            // We see if the page specified actually needs to be parsed again to the true
                            // file location.
                            string tmpPage = SiteGenerator_Transformers.resolveNameAndFolder(response, ref bMatch);
                            if (tmpPage != response)
                            {
                                response = tmpPage;
                            }
                            bMatch = true;
                        }
                    }

                    if (bMatch)           // we had a replacement
                    {
                        if (response.ToString()[0] == '/')
                        {
                            response = ConfigurationManager.AppSettings["ContentPagesRoot"] + response.ToString();
                        }
                        else
                        {
                            response = Path.Combine(ConfigurationManager.AppSettings["ContentPagesRoot"], response.ToString());
                        }
                    }
                }
                else if (CapitializedQuestionType == "HTTPRECEIVEHTTPREQUEST")
                {
                    if (dataSplitIntoSegments[1].IndexOf(".aspx") > -1)          // only make this replacement for aspx files
                    {
                        if (strPathToAnalyze.IndexOf('?') > -1)
                        {
                            string[] strSplitedPathToAnalyze = strPathToAnalyze.Split('?');
                            if (strSplitedPathToAnalyze.Length > 2)
                            {
                                MessageBox.Show("More than 1 ? in request");
                            }
                            string strRequest     = strSplitedPathToAnalyze[0];
                            string strQueryString = strSplitedPathToAnalyze[1];
                            response  = SiteGenerator_Transformers.resolveNameAndFolder(strRequest, ref bMatch);
                            response += "?" + strQueryString;
                        }
                        else
                        {
                            response = SiteGenerator_Transformers.resolveNameAndFolder(strPathToAnalyze, ref bMatch);
                        }
                    }
                    else
                    {
                        xnSelectedDirectory = null;

                        if (strPathToAnalyze.IndexOf("_Navigation_Html_") > -1)
                        {
                            strPathToAnalyze = strPathToAnalyze.Replace("_Navigation_Html_", "");
                            if (SiteGenerator_Transformers.isPathAFolder(strPathToAnalyze, ref xnSelectedDirectory))
                            {
                                if (null != xnSelectedDirectory)
                                {
                                    response = SiteGenerator_Transformers.generateNavigation_html(strPathToAnalyze, xnSelectedDirectory, false, false);
                                }
                            }
                        }
                        if (strPathToAnalyze.IndexOf("_Navigation_Flash_") > -1)
                        {
                            strPathToAnalyze = strPathToAnalyze.Replace("_Navigation_Flash_", "");
                            if (SiteGenerator_Transformers.isPathAFolder(strPathToAnalyze, ref xnSelectedDirectory))
                            {
                                if (null != xnSelectedDirectory)
                                {
                                    response = SiteGenerator_Transformers.generateNavigation_flash(strPathToAnalyze, xnSelectedDirectory);
                                }
                            }
                        }
                        if (strPathToAnalyze.IndexOf('.') > -1)                    // don't continue if we are talking about files
                        {
                            response = dataSplitIntoSegments [1];
                        }
                        if (SiteGenerator_Transformers.isPathAFolder(strPathToAnalyze, ref xnSelectedDirectory))            // check if this is a folder
                        {
                            if (null != xnSelectedDirectory)
                            {
                                if (null != xnSelectedDirectory.Attributes.GetNamedItem("defaultPage"))               // check if there is a default page asigned
                                {
                                    string strDefaultPage = xnSelectedDirectory.Attributes.GetNamedItem("defaultPage").Value;
                                    response = strDefaultPage;
                                }
                                response = SiteGenerator_Transformers.generateNavigation_html(strPathToAnalyze, xnSelectedDirectory, true, true);
                            }
                            //  generate folder info
                        }
                        else
                        {
                            response = dataSplitIntoSegments[1];
                        }
                    }
                }
                else if ((CapitializedQuestionType == "CREATEFILEW") ||
                         (CapitializedQuestionType == "GETFULLPATHNAMEW"))
                {
                    if (dataSplitIntoSegments[1].IndexOf(ConfigurationManager.AppSettings["w3Root"]) > -1)
                    {
                        string strVirtualPathToProcess = dataSplitIntoSegments[1].Replace(ConfigurationManager.AppSettings["w3Root"], "");
                        strVirtualPathToProcess = strVirtualPathToProcess.Replace("\\\\?\\", "");
                        response = SiteGenerator_Transformers.resolveNameAndFolder(strVirtualPathToProcess, ref bMatch);  // add querystring detection
                        if (strVirtualPathToProcess != response)
                        {
                            DisplayInformationToGUI("FileTransformation,-,....,-,0000,-," + dataSplitIntoSegments[1].ToString() + ",-," + response);
                        }
                        if (response.IndexOf("~/") > -1)           // "~/" means 'use the virtual path
                        {
                            response = Path.GetFullPath(Path.Combine(strPathToCurrentSite, response.Replace("~/", "")));
                        }
                        else
                        {
                            response = Path.GetFullPath(ConfigurationManager.AppSettings["w3Root"] + response);
                        }
                    }
                    else
                    {
                        response = dataSplitIntoSegments[1];
                    }
                }

                DisplayInformationToGUI(dataSplitIntoSegments[0] + ",-," + dataSplitIntoSegments[1].ToString() + ",-," + response);
            }
            else
            {
                DisplayInformationToGUI(dataSplitIntoSegments.ToString());
            }

            return(response);
        }