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

using System;
using System.Web;
using EB_BLL;
using System.Data;
using Jayrock.Json;
public class EquipmentUse : 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["eid"]))
        {
            DateTime start = Convert.ToDateTime(context.Request["start"]);
            DateTime end = Convert.ToDateTime(context.Request["end"]);
            Guid eid = new Guid(context.Request["eid"]);

            N25175_EquipmentUse_BLL bll = new N25175_EquipmentUse_BLL();

            DataTable data = bll.GetEquipmentUse(eid,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"]==Convert.DBNull?"教学日":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();


            //         [
            //    {
            //        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;
        }
    }

}