<%@ WebHandler Language="C#" Class="UserUse" %>

using System;
using System.Web;
using EB_BLL;
using System.Data;
using Jayrock.Json;
public class UserUse : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        N25175_SystemAdmin_BLL.NotLoginBack();

        if (!String.IsNullOrEmpty(context.Request["start"])
            && !String.IsNullOrEmpty(context.Request["end"])&&
            !String.IsNullOrEmpty(context.Request["uid"]))
        {
            DateTime start = Convert.ToDateTime(context.Request["start"]);
            DateTime end = Convert.ToDateTime(context.Request["end"]);
            Guid uid = new Guid(context.Request["uid"]);

            N25175_EquipmentUse_BLL bll = new N25175_EquipmentUse_BLL();

            DataTable data = bll.GetUserUseTime(uid, start, end);

            JsonArray result = new JsonArray();

            foreach (DataRow row in data.Rows)
            {
                JsonObject item = new JsonObject();
                
                item.Accumulate("title", String.Format("{0}/{1}",row["u_name"],row["e_name"]));
                item.Accumulate("start", ((DateTime)row["eu_start"]).ToString("yyyy-MM-dd HH:mm:ss"));
                item.Accumulate("end", ((DateTime)row["eu_end"]).ToString("yyyy-MM-dd HH:mm:ss"));

                result.Add(item);
            }

            context.Response.Write(result);
            context.Response.End();

        }

    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}