/// <summary> /// 在线人数 /// </summary> /// <returns></returns> protected int GetOnlineCount() { DateTime lastM = DateTime.Now.AddMinutes(-15); Hashtable hasonlineCount = Sys_OnlineDal.Search(1, 1, "UpdateTime", "ASC", " and UpdateTime>'" + lastM + "'"); return(Convert.ToInt32(hasonlineCount["total"].ToString())); }
protected void UpdateOnlineUser() { DateTime now = DateTime.Now; object lastUpdateTime = Session[SK_ONLINE_UPDATE_TIME]; if (lastUpdateTime == null || (Convert.ToDateTime(lastUpdateTime).Subtract(now).TotalMinutes > 5)) { // 记录本次更新时间 Session[SK_ONLINE_UPDATE_TIME] = now; if (!User.Identity.Name.Equals("")) { Hashtable hasOnline = new Hashtable(); hasOnline["UserID"] = GetIdentityName(); hasOnline["UpdateTime"] = now; Sys_OnlineDal.Update(hasOnline); } } }
private void BindGrid(int pageIndex, int pageSize, string selectTest, out DataTable table, out int count) { string sql = string.Empty; if (!selectTest.Equals("")) { sql = sql + " and UserName like '%" + selectTest + "%'"; } if (GetUserType().Equals("2")) { sql = sql + " and FCompanyNumber='" + GetUserCompanyNumber() + "'"; } else if (GetUserType().Equals("3")) { sql = sql + " and FCustomerID=" + GetUserCustomer(); } Hashtable has = Sys_OnlineDal.Search(pageIndex, pageSize, "UpdateTime", "desc", sql); count = Int32.Parse(has["total"].ToString()); table = (DataTable)has["data"]; }
protected void RegisterOnlineUser(Hashtable user) { Hashtable hasOnline = new Hashtable(); hasOnline = Sys_OnlineDal.Get(user["ID"].ToString()); Hashtable hasInsertOnline = new Hashtable(); DateTime now = DateTime.Now; // 如果不存在,就创建一条新的记录 hasInsertOnline["UserID"] = user["ID"].ToString(); hasInsertOnline["IPAdddress"] = Request.UserHostAddress; hasInsertOnline["LoginTime"] = now; hasInsertOnline["UpdateTime"] = now; if (hasOnline == null) { Sys_OnlineDal.Insert(hasInsertOnline); } Sys_OnlineDal.Update(hasInsertOnline); // 记录本次更新时间 Session[SK_ONLINE_UPDATE_TIME] = now; }