⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tj_hour.aspx.cs

📁 阿江酷站统计系统ASP.Net版,可以直接使用。和现有的网站合并就可以了。提供详细的IP分析。
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace counter
{
	/// <summary>
	/// tj_hour 的摘要说明。
	/// </summary>
	public class tj_hour : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lbhigh1;
		protected System.Web.UI.WebControls.Label lbhigh2;
		protected System.Web.UI.WebControls.Label lbhigh3;
		protected System.Web.UI.WebControls.Label lbhigh4;
		protected System.Web.UI.WebControls.Label lbhigh5;
		protected System.Web.UI.WebControls.Label lbhigh6;
		protected System.Web.UI.WebControls.Label lbhigh7;
		protected System.Web.UI.WebControls.Label lbhigh8;
		public static DataView dv;

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			DataSet myds = new DataSet();
			myds = counter.SQLConn.ExecuteSqlForDataSet("select * from CounterInfo");
			dv=myds.Tables[0].DefaultView;
			if(Session["master"]==null) Session["master"]="";
			if(Session["whatcan"]==null) Session["whatcan"]=dv[0].Row["whatcan"].ToString();
			if(Session["master"].ToString() != "master" && int.Parse(Session["whatcan"].ToString()) < 2) Response.Redirect("help.aspx?id=004&error=您没有查看24小时访问统计的权限。");

		}

		public string show_hour_data(int show_flag)
		{
			string strshow_hour_data_msg1="";
			string strshow_hour_data_msg2="";
			string strshow_hour_data_msg3="";
			string strshow_hour_data_msg4="";
			int[] intvhour=new int[24];
			int intmaxhour=0;
			int intsumhour=0;
			int intthehour;
			int lsbf;

			for(int i=0;i<24;i++)
			{
				intvhour[i]=vhourcon(i);
				if(intvhour[i]>intmaxhour) intmaxhour=intvhour[i];
				intsumhour+=intvhour[i];
			}

			//防止除数为0出错
			if(intmaxhour==0) intmaxhour=1;
			if(intsumhour==0) intsumhour=1;

			for(int i=0;i<24;i++)
			{
				intthehour=int.Parse(DateTime.Now.AddHours(int.Parse(dv[0].Row["adjtime"].ToString())).Hour.ToString())+i+1;
				if(intthehour>23) intthehour-=24;

				strshow_hour_data_msg1+="<td width=15 valign=bottom background='images/tu_back.gif' align=center><img style='BORDER-BOTTOM: #000000 1px solid;' src='images/tu.gif'	height='";
				strshow_hour_data_msg1+=(int)(float.Parse(intvhour[intthehour].ToString())/intmaxhour*100)+"' width='9' alt='"+intthehour+"时,访问"+intvhour[intthehour]+"次,";
				//计算访问量的百分数,精确到小数后1位,小于零的在前面加字母0
				lsbf=(int)(int.Parse(intvhour[intthehour].ToString())*1000/intsumhour)/10;
				strshow_hour_data_msg1+=lsbf+"%'></td>";
				
				strshow_hour_data_msg2+="<td width=15 align=center><a title='"+intthehour+"时,访问"+intvhour[intthehour]+"次,";
				strshow_hour_data_msg2+=lsbf+"%'><font face='Arial' style='letter-spacing: -1'>"+intthehour+"</font></a></td>";
			}

			DataSet myds1 = new DataSet();
			DataView dv1=new DataView();

			myds1=counter.SQLConn.ExecuteSqlForDataSet("select vhour,count(id) as allhour from CounterView group by vhour");
			dv1=myds1.Tables[0].DefaultView;
			dv1.Table.AcceptChanges();

			int[] intvallhour=new int[24];
			int intmaxallhour=0;
			int intsumallhour=0;

			for(int i=0;i<dv1.Count;i++)
			{
				intvallhour[int.Parse(dv1[i].Row["vhour"].ToString())]=int.Parse(dv1[i].Row["allhour"].ToString());
				if(intvallhour[int.Parse(dv1[i].Row["vhour"].ToString())]>intmaxallhour) intmaxallhour=intvallhour[int.Parse(dv1[i].Row["vhour"].ToString())];
				intsumallhour+=intvallhour[int.Parse(dv1[i].Row["vhour"].ToString())];
			}

			dv1.Dispose();

			//防止除数为0出错
			if(intmaxallhour==0) intmaxallhour=1;
			if(intsumallhour==0) intsumallhour=1;

			for(int i=0;i<24;i++)
			{
				strshow_hour_data_msg3+="<td width=15 valign=bottom background='images/tu_back.gif' align=center><img style='BORDER-BOTTOM: #000000 1px solid;' src='images/tu.gif'	height='";
				strshow_hour_data_msg3+=(int)(float.Parse(intvallhour[i].ToString())/intmaxallhour*100)+"' width='9' alt='"+i+"时,访问"+intvallhour[i]+"次,";
				//计算访问量的百分数,精确到小数后1位,小于零的在前面加字母0
				lsbf=(int)(int.Parse(intvallhour[i].ToString())*1000/intsumallhour)/10;
				strshow_hour_data_msg3+=lsbf+"%'></td>";
				
				strshow_hour_data_msg4+="<td width=15 align=center><a title='"+i+"时,访问"+intvallhour[i]+"次,";
				strshow_hour_data_msg4+=lsbf+"%'><font face='Arial' style='letter-spacing: -1'>"+i+"</font></a></td>";
			}

			switch(show_flag)
			{
				case 0:
					lbhigh1.Text=((int)((float)(intmaxhour)*10+0.5)/10).ToString();
					lbhigh2.Text=((float)(int)((3*(float)(intmaxhour)*10/4)+0.5)/10).ToString();
					lbhigh3.Text=((float)(int)(((float)(intmaxhour)*10/2)+0.5)/10).ToString();
					lbhigh4.Text=((float)(int)(((float)(intmaxhour)*10/4)+0.5)/10).ToString();
					return "";

				case 1:
					return strshow_hour_data_msg1+"<td width=10><img src='images/tu_back_right.gif'></td><td width=10></td></tr><tr><td align=right><p style='line-height: 100%; margin-right: 2; margin-top: 0; margin-bottom: 0'><font face='Arial'>0</font></td><td width=10></td>"+strshow_hour_data_msg2;
					
				case 2:
					lbhigh5.Text=((int)((float)(intmaxallhour)*10+0.5)/10).ToString();
					lbhigh6.Text=((float)(int)((3*(float)(intmaxallhour)*10/4)+0.5)/10).ToString();
					lbhigh7.Text=((float)(int)(((float)(intmaxallhour)*10/2)+0.5)/10).ToString();
					lbhigh8.Text=((float)(int)(((float)(intmaxallhour)*10/4)+0.5)/10).ToString();
					return "";

				case 3:
					return strshow_hour_data_msg3+"<td width=10><img src='images/tu_back_right.gif'></td><td width=10></td></tr><tr><td align=right><p style='line-height: 100%; margin-right: 2; margin-top: 0; margin-bottom: 0'><font face='Arial'>0</font></td><td width=10></td>"+strshow_hour_data_msg4;

				default:
					return "";

			}

		}

		public int vhourcon(int thehour)
		{
			DataSet myds2 = new DataSet();
			DataView dv2=new DataView();
			
			if(thehour==int.Parse(DateTime.Now.AddHours(int.Parse(dv[0].Row["adjtime"].ToString())).Hour.ToString()))
			{
				myds2=counter.SQLConn.ExecuteSqlForDataSet("Select count(id) as vhourcon from CounterView where vhour="+int.Parse(DateTime.Now.AddHours(int.Parse(dv[0].Row["adjtime"].ToString())).Hour.ToString())+" and vday="+int.Parse(DateTime.Now.AddHours(int.Parse(dv[0].Row["adjtime"].ToString())).Day.ToString())+" and vmonth="+int.Parse(DateTime.Now.AddHours(int.Parse(dv[0].Row["adjtime"].ToString())).Month.ToString())+" and vyear="+int.Parse(DateTime.Now.AddHours(int.Parse(dv[0].Row["adjtime"].ToString())).Year.ToString()));
				dv2=myds2.Tables[0].DefaultView;
				dv2.Table.AcceptChanges();

				if(dv2.Count>0)
				{
					return int.Parse(dv2[0].Row["vhourcon"].ToString());
				}
				else
				{
					dv2.Dispose();
					return 0;
				}
			}
			else
			{
				myds2=counter.SQLConn.ExecuteSqlForDataSet("Select count(id) as vhourcon from CounterView where vhour="+thehour+" and vtime>'"+DateTime.Now.AddHours(int.Parse(dv[0].Row["adjtime"].ToString())).AddDays(-1).ToString()+"'");
				dv2=myds2.Tables[0].DefaultView;
				dv2.Table.AcceptChanges();

				if(dv2.Count>0)
				{
					return int.Parse(dv2[0].Row["vhourcon"].ToString());
				}
				else
				{
					dv2.Dispose();
					return 0;
				}
			}

		}





		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -