using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HySoft.Common;
using System.Data;

namespace HySoft.BaseCallCenter.Web.reportmanage.dataanalysis.ajax
{
    /// <summary>
    /// getdictionaryvaluelist 的摘要说明
    /// </summary>
    public class getdictionaryvaluelist : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            //取得处事类型
            string action = CommonRequest.GetQueryString("action");
            switch (action)
            {
                case "getdictionary":
                    context.Response.Write(GetDictionary(context));
                    break;
            }
        }

        private string GetDictionary(HttpContext context)
        {
            string res = "";
            try
            {
                List<Model.T_Sys_DictionaryValue> pageModel = new List<Model.T_Sys_DictionaryValue>();
                if (context.Request.Params["type"] != null)
                    pageModel = new BLL.T_Sys_DictionaryValue().GetModelList("F_DictionaryFlag='" + context.Request.Params["type"] + "'");
                System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<Model.T_Sys_DictionaryValue>));

                using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                {
                    //JSON序列化
                    serializer.WriteObject(stream, pageModel);
                    res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
                }
            }
            catch (Exception err)
            {
                
            }
            finally
            {

            }
            return res;
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}