/* * Copyright 2010 www.wojilu.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using System.Text; using wojilu.Web.Context; using wojilu.Web; using wojilu.Web.Mvc; namespace wojilu.Common.Onlines { /// /// 提供在线状态的各类数据 /// public class OnlineService { public static List GetAll() { List all = cdb.findAll(); all.Sort(); return all; } public static List GetGuest() { List all = GetAll(); List allUsers = new List(); foreach (OnlineUser info in all) { if (info.UserId <= 0) allUsers.Add( info ); } return allUsers; } public static List GetLoggerUser() { List all = GetAll(); List allUsers = new List(); foreach (OnlineUser info in all) { if (info.UserId > 0) allUsers.Add( info ); } return allUsers; } public static List GetRecent( int count ) { List all = GetAll(); int icount = 1; List results = new List(); foreach (OnlineUser info in all) { if (icount > count) break; if (info.UserId > 0) { results.Add( info ); icount++; } } return results; } public static List GetRecentAll( int count ) { List all = GetAll(); int icount = 1; List results = new List(); foreach (OnlineUser info in all) { if (icount > count) break; results.Add( info ); icount++; } return results; } } }