Global.asax.cs
资源名称:OA_at.rar [点击查看]
上传用户:tree100901
上传日期:2007-06-03
资源大小:2295k
文件大小:3k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Net;
- using System.Collections;
- using System.ComponentModel;
- using System.Web;
- using System.IO;
- using System.Data;
- using System.Data.SqlClient;
- using System.Web.SessionState;
- namespace insideweb
- {
- /// <summary>
- /// Global 的摘要说明。
- /// </summary>
- public class Global : System.Web.HttpApplication
- {
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- public Global()
- {
- InitializeComponent();
- }
- protected void Application_Start(Object sender, EventArgs e)
- {
- Application["user_sessions"] = 0;
- }
- protected void Session_Start(Object sender, EventArgs e)
- {
- SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
- if (Session["whenLogin"]==null)
- {
- Response.Redirect("index.htm");
- Session["whenLogin"]="now";
- }
- if(Session["online"]==null)
- {
- Application.Lock();
- Application["user_sessions"] = (int)Application["user_sessions"] + 1;
- Application.UnLock();
- Session["online"]="set";
- }
- }
- protected void Application_BeginRequest(Object sender, EventArgs e)
- {
- }
- protected void Application_EndRequest(Object sender, EventArgs e)
- {
- }
- protected void Application_AuthenticateRequest(Object sender, EventArgs e)
- {
- }
- protected void Application_Error(Object sender, EventArgs e)
- {
- }
- protected void Session_End(Object sender, EventArgs e)
- {
- Application.Lock();
- Application["user_sessions"] = (int)Application["user_sessions"] - 1;
- Application.UnLock();
- if(Session["UserSN"]!=null)
- {
- SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
- SqlCommand MyCommand2=new SqlCommand("DeleteOnlineUser",MyConnection);
- MyCommand2.CommandType = CommandType.StoredProcedure;
- MyCommand2.Parameters.Add(new SqlParameter("@UserSN", SqlDbType.NVarChar, 50));
- MyCommand2.Parameters["@UserSN"].Value = Session["UserSN"].ToString();
- MyCommand2.Connection.Open();
- try
- {
- MyCommand2.ExecuteNonQuery();
- }
- catch (SqlException)
- {
- }
- MyConnection.Close();
- }
- }
- protected void Application_End(Object sender, EventArgs e)
- {
- }
- #region Web 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- }
- #endregion
- }
- }