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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询到期证件
    /// 查询到期证件
    /// </summary>
    public class QueryDQZJ : TFOutput
    {
        #region Output
        /// <summary>
        /// 文件
        /// 文件格式:证件类型|证件号码|户名|起始日期|结束日期|主副标志|
        /// </summary>
        public string WJ { get; internal set; }

        /// <summary>
        /// 文件
        /// 文件格式:证件类型|证件号码|户名|起始日期|结束日期|主副标志|
        /// </summary>
        public List<E_WJ> WJData { get; internal set; }

        /// <summary>
        /// 文件
        /// 文件格式:证件类型|证件号码|户名|起始日期|结束日期|主副标志|
        /// </summary>
        public class E_WJ
        {
            /// <summary>
            /// 证件类型
            /// </summary>
            public string ZJLX { get; set; }

            /// <summary>
            /// 证件号码
            /// </summary>
            public string ZJHM { get; set; }

            /// <summary>
            /// 户名
            /// </summary>
            public string HM { get; set; }

            /// <summary>
            /// 起始日期
            /// </summary>
            public string QSRQ { get; set; }

            /// <summary>
            /// 结束日期
            /// </summary>
            public string JSRQ { get; set; }

            /// <summary>
            /// 主副标志
            /// </summary>
            public string ZFBZ { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 户名 0250
            ///  
            /// </summary>
            public string HM { get; set; }

            /// <summary>
            /// 到期起始日期 0440
            ///  
            /// </summary>
            public string DQQSRQ { get; set; }

            /// <summary>
            /// 到期结束日期 0450
            ///  
            /// </summary>
            public string DQJSRQ { get; set; }

            /// <summary>
            /// 证件号码 0620
            ///  
            /// </summary>
            public string ZJHM { get; set; }

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


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryDQZJ();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd25 = HM;
                MessageData.Fd44 = DQQSRQ;
                MessageData.Fd45 = DQJSRQ;
                MessageData.Fd62 = ZJHM;
                MessageData.Fd72 = ZJLX;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.WJData = AnilyzeFileData<E_WJ>(MessageData.FileData,
                                            "证件类型|证件号码|户名|起始日期|结束日期|主副标志|",
                                            x =>
                                            {
                                                return new E_WJ
                                                {
                                                    ZJLX = x["证件类型"],
                                                    ZJHM = x["证件号码"],
                                                    HM = x["户名"],
                                                    QSRQ = x["起始日期"],
                                                    JSRQ = x["结束日期"],
                                                    ZFBZ = x["主副标志"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
