<%@ 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_User_BLL.NotLoginBack();

        if (!String.IsNullOrEmpty(context.Request["start"])
            && !String.IsNullOrEmpty(context.Request["end"]))
        {
            DateTime start = Convert.ToDateTime(context.Request["start"]);
            DateTime end = Convert.ToDateTime(context.Request["end"]);
            Guid uid = N25175_User_BLL.GetLoginKey();
        
            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", row["u_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();


            //         [
            //    {
            //        title  : 'event1',
            //        start  : '2010-01-01'
            //    },
            //    {
            //        title  : 'event2',
            //        start  : '2010-01-05',
            //        end    : '2010-01-07'
            //    },
            //    {
            //        title  : 'event3',
            //        start  : '2010-01-09T12:30:00',
            //        allDay : false // will make the time show
            //    }
            //]

        }

    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}