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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询卡号段列表
    /// 根据介质代码查询卡号段列表
    /// </summary>
    public class QueryCardNoPartList : TFOutput
    {
        #region Output
        /// <summary>
        /// 介质列表
        /// 文件格式: 卡号段代码|卡号段名称|
        /// </summary>
        public string JZLB { get; internal set; }

        /// <summary>
        /// 介质列表
        /// 文件格式: 卡号段代码|卡号段名称|
        /// </summary>
        public List<E_JZLB> JZLBData { get; internal set; }

        /// <summary>
        /// 介质列表
        /// 文件格式: 卡号段代码|卡号段名称|
        /// </summary>
        public class E_JZLB
        {
            /// <summary>
            /// 卡号段代码
            /// </summary>
            public string KHDDM { get; set; }

            /// <summary>
            /// 卡号段名称
            /// </summary>
            public string KHDMC { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 介质代码 1161
            ///  
            /// </summary>
            public string JZDM { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryCardNoPartList();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd116_1 = JZDM;
                MessageData.Fd128 = "0047";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.JZLBData = AnilyzeFileData<E_JZLB>(MessageData.FileData,
                                            "卡号段代码|卡号段名称|",
                                            x =>
                                            {
                                                return new E_JZLB
                                                {
                                                    KHDDM = x["卡号段代码"],
                                                    KHDMC = x["卡号段名称"]
                                                };
                                            });
                output.JZLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
