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

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

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //取得处事类型
            string action = CommonRequest.GetQueryString("action");
            switch (action)
            {
                case "getcustomerlist":
                    context.Response.Write(LoadCustomerList(context));
                    break;
            }
        }
        private string LoadCustomerList(HttpContext context)
        {
            string res = "";
            try
            {
                List<Model.T_Cus_CustomerBase> pageModel = new List<Model.T_Cus_CustomerBase>();
                string key = context.Request.QueryString["key"];
                pageModel = new BLL.T_Cus_CustomerBase().GetModelList("F_CustomerName like '%" + key + "%' and F_DeleteFlag=0");
                System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<Model.T_Cus_CustomerBase>));

                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)
            {
                //res = err.ToString(); 
            }
            finally
            {

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