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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询卡申请登记簿(文件)
    /// 通过输入申请编号查询卡申请登记簿相关信息
    /// </summary>
    public class QueryCardApplyRecord : TFOutput
    {
        #region Output
        /// <summary>
        /// 以文件形式返回卡申请相关记录
        /// 申请日期|申请顺序号|申请张数|介质代码|卡号段|卡号的起始号码|卡号的终止号码|申请标志|申请通过标志|制卡批次|
        /// </summary>
        public string YWJXSFHKSQXGJL { get; internal set; }

        /// <summary>
        /// 以文件形式返回卡申请相关记录
        /// 申请日期|申请顺序号|申请张数|介质代码|卡号段|卡号的起始号码|卡号的终止号码|申请标志|申请通过标志|制卡批次|
        /// </summary>
        public List<E_YWJXSFHKSQXGJL> YWJXSFHKSQXGJLData { get; internal set; }

        /// <summary>
        /// 以文件形式返回卡申请相关记录
        /// 申请日期|申请顺序号|申请张数|介质代码|卡号段|卡号的起始号码|卡号的终止号码|申请标志|申请通过标志|制卡批次|
        /// </summary>
        public class E_YWJXSFHKSQXGJL
        {
            /// <summary>
            /// 申请日期
            /// </summary>
            public string SQRQ { get; set; }

            /// <summary>
            /// 申请顺序号
            /// </summary>
            public string SQSXH { get; set; }

            /// <summary>
            /// 申请张数
            /// </summary>
            public string SQZS { get; set; }

            /// <summary>
            /// 介质代码
            /// </summary>
            public string JZDM { get; set; }

            /// <summary>
            /// 卡号段
            /// </summary>
            public string KHD { get; set; }

            /// <summary>
            /// 卡号的起始号码
            /// </summary>
            public string KHDQSHM { get; set; }

            /// <summary>
            /// 卡号的终止号码
            /// </summary>
            public string KHDZZHM { get; set; }

            /// <summary>
            /// 申请标志
            /// </summary>
            public string SQBZ { get; set; }

            /// <summary>
            /// 申请通过标志
            /// </summary>
            public string SQTGBZ { get; set; }

            /// <summary>
            /// 制卡批次
            /// </summary>
            public string ZKPC { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 申请序号 0530
            ///  
            /// </summary>
            public string SQXH { get; set; }

            /// <summary>
            /// 制卡批次 0860
            ///  
            /// </summary>
            public string ZKPC { get; set; }

            /// <summary>
            /// 介质代码 1161
            ///  
            /// </summary>
            public string JZDM { get; set; }


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

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.YWJXSFHKSQXGJLData = AnilyzeFileData<E_YWJXSFHKSQXGJL>(MessageData.FileData,
                                            "申请日期|申请顺序号|申请张数|介质代码|卡号段|卡号的起始号码|卡号的终止号码|申请标志|申请通过标志|制卡批次|",
                                            x =>
                                            {
                                                return new E_YWJXSFHKSQXGJL
                                                {
                                                    SQRQ = x["申请日期"],
                                                    SQSXH = x["申请顺序号"],
                                                    SQZS = x["申请张数"],
                                                    JZDM = x["介质代码"],
                                                    KHD = x["卡号段"],
                                                    KHDQSHM = x["卡号的起始号码"],
                                                    KHDZZHM = x["卡号的终止号码"],
                                                    SQBZ = x["申请标志"],
                                                    SQTGBZ = x["申请通过标志"],
                                                    ZKPC = x["制卡批次"]
                                                };
                                            });
                output.YWJXSFHKSQXGJL = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
