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;
using LJLib.SQLEX;
using Newtonsoft.Json.Linq;

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

            using (var con = GlobalVar.ConnectionString.NewSqlConnection())
            using (var cmd = con.CreateCommand())
            {
                con.Open();
                var erpHelper = HelperBase.GetHelper<ERPHelper>(null);

                //var wgp = new u_sc_workgroup();
                //if (request.wrkgrpid != null && request.wrkgrpid > 0)
                //{
                //    wgp.Add("wrkgrpid", request.wrkgrpid);
                //}

                var list = erpHelper.GetERPScWorkgroup(cmd);

                rslt.workgroupList = list;
            }
        }
    }
}
