using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace userlist
{
/// <summary>
/// Service1 的摘要说明。
/// </summary>
[WebService(Namespace="http://www.ehang.com.cn/webservices/")]
public class EhangMember : System.Web.Services.WebService
{
public EhangMember()
{
//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
}
private System.Timers.Timer timer1;
#region 组件设计器生成的代码
//Web 服务设计器所必需的
private IContainer components = null;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.timer1 = new System.Timers.Timer();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 10000;
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[WebMethod]
public void Clear(){
base.Application.Lock();
base.Application.Clear();
base.Application .UnLock();
}
[WebMethod]
public String[] getUsers(){
base.Application.Lock();
string[] user=new string[base.Application.Count];
user=base.Application.AllKeys;
base.Application.UnLock();
return user;
}
[WebMethod]
public FYZ.Information.users getUser(string uid){
base.Application.Lock();
FYZ.Information.users userInfo=new FYZ.Information.users();
userInfo=(FYZ.Information.users)base.Application[uid];
base.Application.UnLock();
return userInfo;
}
[WebMethod]
public bool insertUser(string uid)
{
try
{
base.Application.Lock();
FYZ.Information.users userinfo=new FYZ.Information.users();
userinfo.LasstTime =DateTime.Now.ToString();
userinfo.name=uid;
base.Application.Add(uid,userinfo);
base.Application.UnLock();
return true;
}
catch
{
return false;
}
}
[WebMethod]
public bool insertUser(FYZ.Information.users UserInfo)
{
try
{
base.Application.Lock();
UserInfo.LasstTime =DateTime.Now.ToString();
base.Application.Add(UserInfo.name,UserInfo);
base.Application.UnLock();
return true;
}
catch
{
return false;
}
}
[WebMethod]
public int Onlines(){
return base.Application.Count;
}
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
base.Application.Remove("RM");
for(int i=0; i<base.Application.Count;i++)
{
if(DateTime.Compare(DateTime.Now.AddMinutes(-2),DateTime.Parse(((FYZ.Information.users)base.Application[i]).LasstTime))==1){
base.Application.Lock();
base.Application.RemoveAt(i);
base.Application.UnLock();
}
}
}
}
}