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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 9598查询-211201-查询批量开户明细表
    /// 211201-查询批量开户明细表
    /// </summary>
    public class QueryBatchOpenAccountList : 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 ZH { get; set; }

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

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

        }

        #endregion

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

            /// <summary>
            /// 查询条件 
            /// 交易机构
            /// </summary>
            public string JYJG { get; set; }

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


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

                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
                                                {
                                                    ZH = x["账号"],
                                                    HM = x["户名"],
                                                    ZJH = x["证件号"]
                                                };
                                            });
                output.CXJG = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
