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

using System;
using System.Web;
using System.Web.SessionState;
using EB_BLL;
using System.Data;
using Jayrock.Json;
public class UseAjax : IHttpHandler,IRequiresSessionState
{
    public void ProcessRequest(HttpContext context)
    {
        if (!String.IsNullOrEmpty(context.Request["start"])
            && !String.IsNullOrEmpty(context.Request["end"])
            && !String.IsNullOrEmpty(context.Request["rid"]))
        {
            Guid rid = new Guid(context.Request["rid"]);

            DateTime start = Convert.ToDateTime(context.Request["start"]);
            DateTime end = Convert.ToDateTime(context.Request["end"]);

            N25175_Room_BLL bll = new N25175_Room_BLL();

            DataTable data = bll.GetRoomUse(rid, start, end);

            JsonArray result = new JsonArray();

            foreach (DataRow row in data.Rows)
            {
                JsonObject item = new JsonObject();
                item.Accumulate("id", row["m_id"]);
                item.Accumulate("title", row["m_MeetingName"]);
                item.Accumulate("start", ((DateTime)row["m_startDate"]).ToString("yyyy-MM-dd HH:mm:ss"));
                item.Accumulate("end", ((DateTime)row["m_endDate"]).ToString("yyyy-MM-dd HH:mm:ss"));

                result.Add(item);
            }

            context.Response.Write(result);
            context.Response.End();
        }
        //if (!String.IsNullOrEmpty(context.Request["start"])
        //    && !String.IsNullOrEmpty(context.Request["end"]))
        //{
        //    Guid bid = N25175_Employee_BLL.GetLoginKey();

        //    DateTime start = Convert.ToDateTime(context.Request["start"]);
        //    DateTime end = Convert.ToDateTime(context.Request["end"]);

        //    N25175_Room_BLL bll = new N25175_Room_BLL();
        //    DataTable data = bll.GetUserMeeking(bid, start, end);

        //    JsonArray result = new JsonArray();

        //    foreach (DataRow row in data.Rows)
        //    {
        //        JsonObject item = new JsonObject();
        //        item.Accumulate("title", row["ee_name"]);
        //        item.Accumulate("start", ((DateTime)row["m_startDate"]).ToString("yyyy-MM-dd HH:mm:ss"));
        //        item.Accumulate("end", ((DateTime)row["m_endDate"]).ToString("yyyy-MM-dd HH:mm:ss"));
        //        result.Add(item);
        //    }

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

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}