頁面js
<script language="javascript">
//關(guān)閉IE提示------------------------------------------------------------
var i = 0
document.onkeydown = function KeyDown() {
if ((event.keyCode == 116) || (event.ctrlKey && event.keyCode == 82)) { //屏蔽 F5 刷新鍵和Ctrl + R
i = 1;
}
}
function window_onbeforeunload() {
var a = 0;
a = top.window.document.body.offsetWidth;
if (event.clientY > 0 || (event.clientY < 0 && event.screenX < (a - 25))) {//屏蔽右鍵刷新和刷新按鈕
i = 1;
}
if (i != 1) {
return "你確定要退出本系統(tǒng)?";
}
}
function window.onunload() { //關(guān)閉ie時(shí)清空session
var sessionid = '<%=sessionID%>';
if (i != 1) {
//alert(sessionid);
SignOutByPost(sessionid);
}
}
function SignOutByPost(sessionid) {
var data;
data = '<?xml version="1.0" encoding="utf-8"?>';
data = data + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
data = data + '<soap:Body>';
data = data + '<SignOut xmlns="http://tempuri.org/">';
data = data + '<SessionID>' + sessionid + '</SessionID>';
data = data + '</SignOut>';
data = data + '</soap:Body>';
data = data + '</soap:Envelope>';
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var URL = "/iOffice/prg/set/wss/ioCtlSet.asmx";
xmlhttp.Open("POST", URL, true);
xmlhttp.SetRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.SetRequestHeader("SOAPAction", "http://tempuri.org/SignOut");
xmlhttp.Send(data);
}
//-----------------------------------------------------------------
</script>
ioctlset.asmx.vb
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' 若要允許使用 ASP.NET AJAX 從腳本中調(diào)用此 Web 服務(wù),請(qǐng)取消對(duì)下行的注釋。
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class ioCtlSet
Inherits System.Web.Services.WebService
'保存折疊cookies
<WebMethod()> _
Public Sub SaveFoldCookies(ByVal empid As Integer, ByVal fold As Boolean, ByVal mode As String)
Dim cookie As New ioCom.EmpCookie("ioFoldDisplay_" & mode, empid.ToString)
cookie.ItemAdd("IsFold", fold)
cookie.SessionFlag = False
cookie.SaveFoldCookie()
End Sub
'結(jié)束當(dāng)前人員在線對(duì)話會(huì)話
<WebMethod()> _
Public Sub ifChatClose(ByVal empid As Integer, ByVal chatid As Integer)
If chatid > 0 Then
ioSet.DataDel("ifChatEmp", "EmpID", empid, " and chatid=" & pf.SafeSql(chatid.ToString))
End If
End Sub
'關(guān)閉瀏覽器時(shí)做清空操作
<WebMethod()> _
Public Sub SignOut(ByVal SessionID As String)
Dim Log As Integer = 1
If Not HttpContext.Current Is Nothing Then
If Log = 1 And ioCom.Profile("PwdPolicy", "StrongLog") = "1" Then '啟用強(qiáng)日志,退出系統(tǒng)寫日志
Dim dt As DataTable
Dim eid As String
Dim ename As String
Dim ip As String
dt = SqlData.ExecuteDataset(ioCom.ConnectString, CommandType.Text, "select * from ssLogInfo where SessionID='" + SessionID + "'").Tables(0)
If dt.Rows.Count = 1 Then
eid = dt.Rows(0)("LoginID").ToString
ename = dt.Rows(0)("UserName").ToString
ip = dt.Rows(0)("LoginIP").ToString
ioSet.ssActLogAdd(ename, "退出系統(tǒng)", "登錄表", "", ip, eid, 1, 1)
End If
End If
'清除會(huì)話變量,關(guān)閉聯(lián)接記錄
SqlData.ExecuteNonQuery(ioCom.ConnectString, "ssLoginSessionClose", SessionID)
'清除配置緩存
pf.RemoveCache("EmpProfile" & SessionID)
'標(biāo)示已注銷
System.Web.Security.FormsAuthentication.SignOut()
HttpContext.Current.Session.Clear()
HttpContext.Current.Session.Abandon()
Try
Dim iNum As Integer
Dim sql As String
sql = "select count(sessionid) "
sql &= " from ssloginfo WITH(NOLOCK) "
sql &= " where status=1 and not(empid is null)"
iNum = SqlData.ExecuteScalar(ioCom.ConnectString, CommandType.Text, sql)
ioCom.OnLineNum = iNum
Catch ex As Exception
End Try
End If
End Sub
End Class