protected void Page_Load(object sender, EventArgs e)
{
// Insert Hits
try
{
if (Session["UserID"].ToString() == "")
{
new UserLogs().HitsCounter(Session["UserID"].ToString(), "Hit");
}
}
catch
{
new UserLogs().HitsCounter("0", "Anonymous Hit");
}
}
-----------------------------
public void HitsCounter(string UserID, string Operation)
{
try
{
SqlParameter[] param = new SqlParameter[5]
{
new SqlParameter("UserID", UserID),
new SqlParameter("IP", HttpContext.Current.Request.UserHostAddress.ToString()),
new SqlParameter("PageName", HttpContext.Current.Request.Url.ToString()),
new SqlParameter("RefererPage", RefererUrl()),
new SqlParameter("Operation", Operation)
};
new DataAccess().Write("InsertHits", param);
}
catch
{
}
-------------------
ALTER proc [dbo].[InsertHits]
@UserID bigint,
@IP varchar(130),
@PageName varchar(800),
@RefererPage varchar(800),
@Operation varchar(800)
as
begin
insert into HitssCounter(UserID,IP,PageName,RefererPage,Operation) values(@UserID,@IP,@PageName,@RefererPage,@Operation)
end
No comments:
Post a Comment