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;

namespace JLHHJSvr.Excutor
{
    internal sealed class GetChangeSoftBedMxListExcutor : ExcutorBase<GetChangeSoftBedMxListRequest, GetChangeSoftBedMxListResponse>
    {
        protected override void ExcuteInternal(GetChangeSoftBedMxListRequest request, object state, GetChangeSoftBedMxListResponse rslt)
        {
            var tokendata = BllHelper.GetToken(request.token);
            if (tokendata == null)
            {
                rslt.ErrMsg = "会话已经中断，请重新登录";
                return;
            }
            if (request.billid <= 0)
            {
                rslt.ErrMsg = "软床id有误,请检查!";
                return;
            }

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

                var softbedHelpr = HelperBase.GetHelper<SoftBedHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
                rslt.mxList = softbedHelpr.GetChangeSoftBedMxList(request.billid,request.mxList,request.codeList);
            }
        }
    }
}
