using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using DirectService.Tools;
using JLHHJSvr.BLL;
using JLHHJSvr.Com;
using JLHHJSvr.Com.Model;
using JLHHJSvr.Helper;
using JLHHJSvr.LJException;
using LJLib.DAL.SQL;
using LJLib.Net.SPI.Server;

namespace JLHHJSvr.Excutor
{
    internal sealed class GetERPConfigureListExcutor : ExcutorBase<GetERPConfigureListRequest, GetERPConfigureListResponse>
    {
        protected override void ExcuteInternal(GetERPConfigureListRequest request, object state, GetERPConfigureListResponse rslt)
        {
            var tokendata = BllHelper.GetToken(request.token);
            if (tokendata == null)
            {
                rslt.ErrMsg = "会话已经中断，请重新登录";
                return;
            }

            using (var con = new SqlConnection(GlobalVar.ConnectionString))
            using (var cmd = con.CreateCommand())
            {
                con.Open();

                throw new NotImplementedException("不能直连ERP数据库，下面需要改写");
                //var configureList = new List<erp_configure_code>();

                //var param = new Dictionary<string, object>();
                //var whereList = new List<string>();
                //var selectStr = @"SELECT u_configure_code.pzid,
	               //                     u_configure_code.pzcode,
	               //                     u_configure_code.name,
	               //                     u_configure_code.inputtype
                //                FROM u_configure_code";
                //var outputFields = "pzid,pzcode,name,inputtype";

                //if (request.typeid != null && request.typeid > 0)
                //{
                //    whereList.Add("typeid = @typeid");
                //    param.Add("@typeid", request.typeid);
                //}
                //DbSqlHelper.SelectJoin(erp_cmd, selectStr, ListEx.GetWhereStr(whereList), param, "typeid", outputFields, 0, 0, configureList);

                //rslt.configureList = configureList;
                
            }
        }
    }
}
