using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
namespace test
{
/// <summary>
/// WebService 的摘要说明
/// </summary>
[WebService(Namespace = "
http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService : System.Web.Services.WebService
{
//模拟数据库
private static List<User> users = new List<User>();
static WebService()
{
//初始化模拟数据
users.Add(new User() { data = DateTime.Now, id = 1, batchNo = "u1001", barcode = "c12", score = 95 });
users.Add(new User() { data = DateTime.Now.AddDays(-1), id = 1, batchNo = "u1002", barcode = "c12", score = 96 });
users.Add(new User() { data = DateTime.Now.AddDays(1), id = 1, batchNo = "u1003", barcode = "c12", score = 97 });
users.Add(new User() { data = DateTime.Now, id = 1, batchNo = "u1004", barcode = "c12", score = 98 });
users.Add(new User() { data = DateTime.Now, id = 1, batchNo = "u1005", barcode = "c13", score = 99 });
users.Add(new User() { data = DateTime.Now, id = 1, batchNo = "u1006", barcode = "c13", score = 100 });
}
[WebMethod]
public List<User> Query(DateTime d1, DateTime d2, int id, string batchNo, string barcode)
{
List<User> result = null;
if (!string.IsNullOrEmpty(barcode))
{
result = users.FindAll(f => f.barcode.Equals(barcode));
}
else
{
if (!string.IsNullOrEmpty(batchNo))
{
result = users.FindAll(f => f.batchNo.Equals(batchNo));
}
else
{
result = users.FindAll(f => f.id == id && f.data > d1 && f.data < d2);
}
}
return result;
}
}
public class User
{
public DateTime data { get; set; }
public int id { get; set; }
public string batchNo { get; set; }
public string barcode { get; set; }
public int score { get; set; }
}
}