sp; SohoProject.SohoDebug()).WriteToDoc(strExpr); (new SohoProject.SohoDebug()).WriteToDoc(curUser.Length.ToString()); #endif
if (curUser.Length >0 ) { for(int i = 0; i < curUser.Length; i ++) { curUser[i]["curtime"]=DateTime.Now; curUser[i]["iswhere"]=user.iswhere; } } else { //直接加入新的数据 DataRow myRow; try { myRow = _alluser.NewRow(); // Then add the new row to the collection. myRow["name"] = user.name; myRow["ip"] = user.ip; myRow["iswhere"] = user.iswhere; myRow["lasttime"] = user.lasttime; myRow["curtime"] = DateTime.Now; myRow["sessionid"] = user.sessionid; _alluser.Rows.Add(myRow); } catch(Exception e) { throw(new Exception(e + "--------------------" + e.ToString())) ; } } _alluser.AcceptChanges(); return true; }
//功能说明:判断某用户是否在线,本部分暂时不用 //返回值:TRUE代表在线,FALSE不在 public Boolean IsUserOnLine(string name) { //需要先判断用户是否已经在用户列表中了 //开始搜索是否已经存在该用户,如果存在则是改变数据,否则添加新的用户 string strExpr; strExpr = "name =''''" + name + "''''"; DataRow[] curUser; // Use the Select method to find all rows matching the filter. curUser = _alluser.Select(strExpr);
if (curUser.Length >0 ) { return true; } else { return false; } } //功能说明:更新用户在线时间 //返回值:最新的在线用户列表 public Boolean CheckUserOnLine(string name,string iswhere,string sessionid,string ip) { #if DEBUG (new SohoProject.SohoDebug()).WriteToDoc("开始进入检查用户方法...."); (new SohoProject.SohoDebug()).WriteToDoc(""); #endif
//需要先判断用户是否已经在用户列表中了 User newuser=new User(); newuser.name= name; newuser.iswhere= iswhere; newuser.lasttime=newuser.curtime=DateTime.Now; newuser.sessionid=sessionid; newuser.ip=ip;
OnLineUser alluser= new OnLineUser(); alluser.AddUserToOnLine(newuser);
#if DEBUG (new SohoProject.SohoDebug()).WriteToDoc("离开检查用户方法...."); #endif
return true; } } //定义在线用户类 public class OnLineUser_old { private static ArrayList _alluser ; //定义用户 public ArrayList alluser { get{return _alluser;} set{_alluser=value;} } public OnLineUser_old() //构造函数 { if(_alluser==null) { _alluser=new ArrayList(); } }
//功能说明:将当前用户加入在线列表 //如果该用户的数据当前仍然在在线列表中,则暂时先不让该用户登陆,提示用户存在 public bool AddUserToOnLine(User user) { //需要先判断用户是否已经在用户列表中了 if(_alluser==null) { _alluser.Add(user); return (true); } else { for ( int i = 0 ; i < _alluser.Count&nbs上一页 [1] [2] [3] [4] 下一页 |