打印本文 打印本文 关闭窗口 关闭窗口
ASP.NET实现用户在线检测的类源码
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2678  更新时间:2009/4/23 10:45:56  文章录入:mintao  责任编辑:mintao
;             this.thread  =  new  Thread(new  ThreadStart(ThreadProc))  ;
                          thread.Name  =  "online  user"  ;
                          thread.Start()  ;
                        }
                }
    
    
                internal  void  ThreadProc()
                {
                        while(true)    
                        {
//                            SohoProject.OnLineUser  temp=new  SohoProject.OnLineUser();    //定义一个用户对象
//            for  (int  i=0  ;i<  temp.alluser.Count;i++)
//                    {
//                      User  tmpuser=(User)temp.alluser[i];
//                      //我是将该用户的最新时间加上30秒,然后和当前时间比较,小与当前时间,
//                      //则表示该用户已经吊线,则删除他的记录
//                      if(tmpuser.curtime.AddSeconds(DELAY_SECONDS).CompareTo(DateTime.Now)<0)  
//                      {
//                        temp.alluser.RemoveAt(i);
//                      }
//                    }

        

        SohoProject.OnLineUser  temp=new  SohoProject.OnLineUser();    //定义一个用户对象
        //开始检查是否有用户过期了        string  strExpr;
        //tmpuser.curtime.AddSeconds(DELAY_SECONDS).CompareTo(DateTime.Now)<0
        strExpr  =  "curtime  <  ''''"  +  DateTime.Now.AddSeconds(  0  -  DELAY_SECONDS)  +  "''''";  
#if  DEBUG
        (new  SohoProject.SohoDebug()).WriteToDoc(strExpr);
#endif

        DataRow[]  curUser;
        //  Use  the  Select  method  to  find  all  rows  matching  the  filter.
        curUser  =  temp.alluser.Select(strExpr);

        if  (curUser.Length  >0  )
        {
          //删除这些记录
          for(int  i  =  0;  i  <  curUser.Length;  i  ++)
          {
            curUser[i].Delete();
          }
          temp.alluser.AcceptChanges();
        }
                                Thread.Sleep(DELAY_TIMES)  ;
                        }
                }
        }
}


上一页  [1] [2] [3] [4] 

打印本文 打印本文 关闭窗口 关闭窗口