Init:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text.RegularExpressions;
/// <summary>
///init 的摘要说明
/// </summary>
public class init:Page
{
public init()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
protected override void OnPreInit(EventArgs e)
{
string theme="";
string language = Request.UserLanguages[0];
if (Request.Cookies["theme"] != null)
{
theme = Request.Cookies["theme"].Value.ToString();
}
else
{
// if (language == "en-us" || language == "zh-cn")
if (language == "en-us")
{
theme = "English";
}
else if (language == "fr")
{
theme = "France";
}
}
switch (theme)
{
case "English":
Page.Theme = "English";
break;
case "France":
Page.Theme = "France";
break;
//case "Germany":
// Page.Theme = "Germany";
// break;
default:
Page.Theme = "English";
break;
}
if (!IsPostBack)
{
pageCount.pageCountDo(Page);
}
}
}
********************************************************************************************
Pagecount:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
using DLL;
/// <summary>
/// pageCount 的摘要说明
/// </summary>
public abstract class pageCount
{
public static void pageCountDo(Page page)
{
Dtrack dtrack = new Dtrack();
Regex reg = new Regex("[^a-zA-Z]");
string serialno = "";
if ( HttpContext.Current.Session["hSerialNo"] != null)
{
serialno = HttpContext.Current.Session["hSerialNo"].ToString();
}
else
{
serialno = JS.DateNums();
HttpContext.Current.Session["hSerialNo"] = serialno;
}
string cururl = page.Request.Url.ToString();
string fromurl = "about:blank";
if (page.Request.UrlReferrer != null)
{
fromurl = page.Request.UrlReferrer.ToString();
}
string ip = page.Request.UserHostAddress;
string browser = page.Request.Browser.Type;
browser = reg.Replace(browser, "");
//string os = page.Request.Browser.Platform;
string os = "";
string agent = page.Request.UserAgent;
if (agent.Contains("NT 5.2"))
{
os = "Windows 2003";
}
else if (agent.Contains("NT 5.1"))
{
os = "Windows XP";
}
else if (agent.Contains("NT 5"))
{
os = "Windows 2000";
}
else if (agent.Contains("NT 4.9"))
{
os = "Windows ME";
}
else if (agent.Contains("NT 4"))
{
os = "Windows NT4";
}
else if (agent.Contains("NT 98"))
{
os = "Windows 98";
}
else if (agent.Contains("NT 95"))
{
os = "Windows 95";
}
else if (os.ToLower().Contains("Mac"))
{
os = "Mac";
}
else if (os.ToLower().Contains("unix"))
{
os = "UNIX";
}
else if (os.ToLower().Contains("linux"))
{
os = "Linux";
}
else if (os.Contains("SunOS"))
{
os = "SunOS";
}
string VisitPageDetail = "other";
if (cururl.ToLower().Contains("default"))
{
VisitPageDetail = "Index";
}
else if (cururl.ToLower().Contains("wow-gold-eu"))
{
VisitPageDetail = "euwow_g";
}
else if (cururl.ToLower().Contains("wow-gold-us"))
{
VisitPageDetail = "uswow_g";
}
else if (cururl.ToLower().Contains("war-gold-eu"))
{
VisitPageDetail = "euwar_g";
}
else if (cururl.ToLower().Contains("war-gold-us"))
{
VisitPageDetail = "uswar_g";
}
else if (cururl.ToLower().Contains("aoc-gold-eu"))
{
VisitPageDetail = "euaoc_g";
}
else if (cururl.ToLower().Contains("aoc-gold-us"))
{
VisitPageDetail = "usaoc_g";
}
else if (cururl.ToLower().Contains("lotro-gold-eu"))
{
VisitPageDetail = "eulotro_g";
}
else if (cururl.ToLower().Contains("lotro-gold-us"))
{
VisitPageDetail = "uslotro_g";
}
else if (cururl.ToLower().Contains("wow-us"))
{
VisitPageDetail = "uswow_p";
}
else if (cururl.ToLower().Contains("wow-eu"))
{
VisitPageDetail = "euwow_p";
}
else if (cururl.ToLower().Contains("war-us"))
{
VisitPageDetail = "uswar_p";
}
else if (cururl.ToLower().Contains("war-eu"))
{
VisitPageDetail = "euwar_p";
}
else if (cururl.ToLower().Contains("aoc-us"))
{
VisitPageDetail = "usaoc_p";
}
else if (cururl.ToLower().Contains("aoc-eu"))
{
VisitPageDetail = "euaoc_p";
}
else if (cururl.ToLower().Contains("lotro-us"))
{
VisitPageDetail = "uslro_p";
}
else if (cururl.ToLower().Contains("lotro-eu"))
{
VisitPageDetail = "eulro_p";
}
else if (cururl.ToLower().Contains("point"))
{
VisitPageDetail = "Point";
}
else if (cururl.ToLower().Contains("items"))
{
VisitPageDetail = "Item";
}
else if (cururl.ToLower().Contains("register"))
{
VisitPageDetail = "Register";
}
else if (cururl.ToLower().Contains("regok"))
{
VisitPageDetail = "Regok";
}
else if(cururl.ToLower().Contains("aboutus"))
{
VisitPageDetail = "Aboutus";
}
else if (cururl.ToLower().Contains("faq"))
{
VisitPageDetail = "FAQ";
}
else if (cururl.ToLower().Contains("news"))
{
VisitPageDetail = "News";
}
string language = page.Request.UserLanguages[0];
string website = SqlHelper.website;
dtrack.TwCustTract_InserTrack(serialno, ip, browser, website, cururl, fromurl, cururl, VisitPageDetail,"0", Decimal.Parse("0") ,"0","0",int.Parse("0"), "PP", "0", "0", "0", "0");
}
}