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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询客户允许的卡介质列表
    /// 根据客户级别和卡种类返回卡介质列表
    /// </summary>
    public class QueryCardListOfCustomer : 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 JZDM { get; set; }

            /// <summary>
            /// 介质名称
            /// </summary>
            public string JZMC { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 是否自选号 0680
            /// Y:是 N:否 
            /// </summary>
            public string SFZXH { get; set; }

            /// <summary>
            /// 卡类型 0690
            /// 0:普通卡 1:联名卡 2:专用卡 
            /// </summary>
            public string KLX { get; set; }

            /// <summary>
            /// 是否记名卡 0700
            /// Y:是 N:否 
            /// </summary>
            public string SFJMK { get; set; }

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


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryCardListOfCustomer();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd68 = SFZXH;
                MessageData.Fd69 = KLX;
                MessageData.Fd70 = SFJMK;
                MessageData.Fd71 = KHJB;
                MessageData.Fd128 = "0046";

                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
                                                {
                                                    JZDM = x["介质代码"],
                                                    JZMC = x["介质名称"]
                                                };
                                            });
                output.JZLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
