using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 9598查询-210203-查询客户基本信息
    /// 210203-查询客户基本信息
    /// </summary>
    public class QueryCustomerBaseInfoList : TFOutput
    {
        #region Output
        /// <summary>
        /// 查询结果
        /// 文件格式:客户号|客户级别
        /// </summary>
        public string CXJG { get; internal set; }

        /// <summary>
        /// 查询结果
        /// 文件格式:客户号|客户级别
        /// </summary>
        public List<E_CXJG> CXJGData { get; internal set; }

        /// <summary>
        /// 查询结果
        /// 文件格式:客户号|客户级别
        /// </summary>
        public class E_CXJG
        {
            /// <summary>
            /// 客户号
            /// </summary>
            public string KHH { get; set; }

            /// <summary>
            /// 客户级别
            /// </summary>
            public string KHJB { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 查询条件 
            /// 证件号
            /// </summary>
            public string ZJH { get; set; }

            /// <summary>
            /// 查询条件 
            /// 证件类型
            /// </summary>
            public string ZJLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryCustomerBaseInfoList();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "9598";
                MessageData.Fd123 = string.Format("1,210203,{0},{1},",ZJH,ZJLX);

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.CXJGData = AnilyzeFileData<E_CXJG>(MessageData.FileData,
                                            "客户号|客户级别|",
                                            x =>
                                            {
                                                return new E_CXJG
                                                {
                                                    KHH = x["客户号"],
                                                    KHJB = x["客户级别"]
                                                };
                                            });
                output.CXJG = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
