sitemap
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Net;
namespace FusionChartTest
{
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
string filename = Path.GetFileName(Request.Path);
System.Diagnostics.Debug.WriteLine("filename: " + filename);
string ClassWill = null;
string divClose = null;
//string inputString
string[] lines = System.IO.File.ReadAllLines(Server.MapPath("~") + @"\sitemap.ini").Where(s => s.Trim() != string.Empty).ToArray();
if (filename == "default.aspx" || filename == "Default.aspx")
{
foreach (string linetext in lines)
{
string[] Content = linetext.Split('|');
string tag = Content[0].Substring(0, 2);
//index will get increase if the first position will not start with the - sign
if (Content[0].IndexOf('-') == -1)
{
string str = " ";
Label99.Text += str + "";
}
}
}
//for the other case
else {
if (filename.IndexOf('-') == -1)
{
string root = "";
foreach (string linetext in lines)
{
string[] Content = linetext.Split('|');
string tag = Content[0].Substring(0, 2);
if(filename.Equals(Content[1])){
root = Content[1];
Response.Write("The url is : " + root);
}
//index will get increase if the first position will not start with the - sign
if (Content[0].IndexOf('-') == -1)
{
//for maintaining the div
// if (Content[1] == filename) ClassWill = "
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Net;
namespace FusionChartTest
{
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
string filename = Path.GetFileName(Request.Path);
System.Diagnostics.Debug.WriteLine("filename: " + filename);
string ClassWill = null;
string divClose = null;
//string inputString
string[] lines = System.IO.File.ReadAllLines(Server.MapPath("~") + @"\sitemap.ini").Where(s => s.Trim() != string.Empty).ToArray();
if (filename == "default.aspx" || filename == "Default.aspx")
{
foreach (string linetext in lines)
{
string[] Content = linetext.Split('|');
string tag = Content[0].Substring(0, 2);
//index will get increase if the first position will not start with the - sign
if (Content[0].IndexOf('-') == -1)
{
string str = " ";
Label99.Text += str + "";
}
}
}
//for the other case
else {
if (filename.IndexOf('-') == -1)
{
string root = "";
foreach (string linetext in lines)
{
string[] Content = linetext.Split('|');
string tag = Content[0].Substring(0, 2);
if(filename.Equals(Content[1])){
root = Content[1];
Response.Write("The url is : " + root);
}
//index will get increase if the first position will not start with the - sign
if (Content[0].IndexOf('-') == -1)
{
//for maintaining the div
// if (Content[1] == filename) ClassWill = "
"; divClose = "
";
//if (Content[0].IndexOf('-') == -1) { string root = Content[0]; }
string str = "
Label99.Text += str + "";
}
if (filename.Equals(root))
{
//printing only the second level filena,e is the root name ==
//for 1 (-)
if (tag.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(1, 1), "^[a-zA-Z'.]$"))
{
string str = " ";
Label99.Text += str;
//System.Diagnostics.Debug.WriteLine("Item: " + str);
}
if (Content[0].IndexOf('-') == -1 && !(filename.Equals(Content[1])))
{
root = "";
}
}
}
}
else if (filename.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(filename.Substring(1, 1), "^[a-zA-Z'.]$"))
{
string root = "";
foreach (string linetext in lines)
{
string[] Content = linetext.Split('|');
string tag = Content[0].Substring(0, 2);
if (filename.Equals(Content[1]))
{
root = Content[1];
Response.Write("The url is : " + root);
}
//index will get increase if the first position will not start with the - sign
if (Content[0].IndexOf('-') == -1)
{
//for maintaining the div
// if (Content[1] == filename) ClassWill = "
//if (Content[0].IndexOf('-') == -1) { string root = Content[0]; }
string str = "
" + ClassWill + "" + "" + Content[0].Substring(Content[0].IndexOf('-') + 1) + "" + divClose + "
";Label99.Text += str + "";
}
if (filename.Equals(root))
{
//printing only the second level filena,e is the root name ==
//for 1 (-)
if (tag.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(1, 1), "^[a-zA-Z'.]$"))
{
string str = " ";
Label99.Text += str;
//System.Diagnostics.Debug.WriteLine("Item: " + str);
}
if (Content[0].IndexOf('-') == -1 && !(filename.Equals(Content[1])))
{
root = "";
}
}
}
}
else if (filename.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(filename.Substring(1, 1), "^[a-zA-Z'.]$"))
{
string root = "";
foreach (string linetext in lines)
{
string[] Content = linetext.Split('|');
string tag = Content[0].Substring(0, 2);
if (filename.Equals(Content[1]))
{
root = Content[1];
Response.Write("The url is : " + root);
}
//index will get increase if the first position will not start with the - sign
if (Content[0].IndexOf('-') == -1)
{
//for maintaining the div
// if (Content[1] == filename) ClassWill = "
"; divClose = "
";
//if (Content[0].IndexOf('-') == -1) { string root = Content[0]; }
string str = "
Label99.Text += str + "";
}
if (filename.Equals(root))
{
//printing only the second level filena,e is the root name ==
//for 1 (-)
if (tag.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(1, 1), "^[a-zA-Z'.]$"))
{
string str = " ";
Label99.Text += str;
//System.Diagnostics.Debug.WriteLine("Item: " + str);
}
if (Content[0].IndexOf('-') == -1 && !(filename.Equals(Content[1])))
{
root = "";
}
}
if (tag == "--")
{
string str = " ";
Label99.Text += str;
//System.Diagnostics.Debug.WriteLine("Item: " + str);
}
}
}
//for other case finish
}
}
public string getIndex(string url)
{
int index = 0;
int node = 0;
int label = 1;
string str = "";
string[] lines = System.IO.File.ReadAllLines(Server.MapPath("~") + @"\sitemap.ini").Where(s => s.Trim() != string.Empty).ToArray();
foreach (string linetext in lines)
{
string[] Content = linetext.Split('|');
string tag = Content[0].Substring(0, 2);
System.Diagnostics.Debug.WriteLine("tag :" + tag);
if (tag.IndexOf('-') != 0) index++;
/*
{
if (tag.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(1, 1), "^[a-zA-Z'.]$")) index++;
node++;
}
*/
if (Content[1] == url)
{
//string tag = Content[0].Substring(0, 2);
//for the first lavel
if (System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(0, 1), "^[a-zA-Z'.]$"))
{
str = node.ToString() + "_" + label.ToString() + "_" + index.ToString();
}
//for the 2nd lavel
else if (tag.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(1, 1), "^[a-zA-Z'.]$"))
{
//node+label then position
label = 2;
str = node.ToString() + "_" + label.ToString() + "_" + index.ToString();
}
//for the 3rd lavel
else if (tag == "--")
{
label = 3;
str = node.ToString() + "_" + label.ToString() + "_" + index.ToString();
}
//str = node.ToString() + index.ToString();
return str;
}
/*
else
{
index++;
}
*/
}
//System.Diagnostics.Debug.WriteLine("node and lebel :" +str);
//Array.IndexOf(Content[1], url);
return str;
}
}
}
//if (Content[0].IndexOf('-') == -1) { string root = Content[0]; }
string str = "
" + ClassWill + "" + "" + Content[0].Substring(Content[0].IndexOf('-') + 1) + "" + divClose + "
";Label99.Text += str + "";
}
if (filename.Equals(root))
{
//printing only the second level filena,e is the root name ==
//for 1 (-)
if (tag.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(1, 1), "^[a-zA-Z'.]$"))
{
string str = " ";
Label99.Text += str;
//System.Diagnostics.Debug.WriteLine("Item: " + str);
}
if (Content[0].IndexOf('-') == -1 && !(filename.Equals(Content[1])))
{
root = "";
}
}
if (tag == "--")
{
string str = " ";
Label99.Text += str;
//System.Diagnostics.Debug.WriteLine("Item: " + str);
}
}
}
//for other case finish
}
}
public string getIndex(string url)
{
int index = 0;
int node = 0;
int label = 1;
string str = "";
string[] lines = System.IO.File.ReadAllLines(Server.MapPath("~") + @"\sitemap.ini").Where(s => s.Trim() != string.Empty).ToArray();
foreach (string linetext in lines)
{
string[] Content = linetext.Split('|');
string tag = Content[0].Substring(0, 2);
System.Diagnostics.Debug.WriteLine("tag :" + tag);
if (tag.IndexOf('-') != 0) index++;
/*
{
if (tag.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(1, 1), "^[a-zA-Z'.]$")) index++;
node++;
}
*/
if (Content[1] == url)
{
//string tag = Content[0].Substring(0, 2);
//for the first lavel
if (System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(0, 1), "^[a-zA-Z'.]$"))
{
str = node.ToString() + "_" + label.ToString() + "_" + index.ToString();
}
//for the 2nd lavel
else if (tag.Substring(0, 1) == "-" && System.Text.RegularExpressions.Regex.IsMatch(tag.Substring(1, 1), "^[a-zA-Z'.]$"))
{
//node+label then position
label = 2;
str = node.ToString() + "_" + label.ToString() + "_" + index.ToString();
}
//for the 3rd lavel
else if (tag == "--")
{
label = 3;
str = node.ToString() + "_" + label.ToString() + "_" + index.ToString();
}
//str = node.ToString() + index.ToString();
return str;
}
/*
else
{
index++;
}
*/
}
//System.Diagnostics.Debug.WriteLine("node and lebel :" +str);
//Array.IndexOf(Content[1], url);
return str;
}
}
}
Comments
Post a Comment