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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询介质代码支持的产品列表
    /// 通过介质种类查询该介质支持的产品代码及产品名称
    /// </summary>
    public class QueryProductListByDielectric : TFOutput
    {
        #region Output
        /// <summary>
        /// 产品列表数据
        /// 产品代码|产品名称|
        /// </summary>
        public string CPLBSJ { get; internal set; }

        /// <summary>
        /// 产品列表数据
        /// 产品代码|产品名称|
        /// </summary>
        public List<E_CPLBSJ> CPLBSJData { get; internal set; }

        /// <summary>
        /// 产品列表数据
        /// 产品代码|产品名称|
        /// </summary>
        public class E_CPLBSJ
        {
            /// <summary>
            /// 产品代码
            /// </summary>
            public string CPDM { get; set; }

            /// <summary>
            /// 产品名称
            /// </summary>
            public string CPMC { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 币种 0210
            ///  
            /// </summary>
            public string BZ { get; set; }

            /// <summary>
            /// 产品类型 0670
            /// 1活期 2定期 
            /// </summary>
            public string CPLX { get; set; }

            /// <summary>
            /// 客户类型 0680
            /// 1个人 2对公 
            /// </summary>
            public string KHLX { get; set; }

            /// <summary>
            /// 介质种类 1161
            ///  
            /// </summary>
            public string JZZL { get; set; }

            /// <summary>
            /// 业务种类 0300
            /// 一级科目号 
            /// </summary>
            public string CPFL { get; set; }

            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryProductListByDielectric();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd21 = BZ;
                MessageData.Fd67 = CPLX;
                MessageData.Fd68 = KHLX;
                MessageData.Fd116_1 = JZZL;
                MessageData.Fd128 = "0021";
                MessageData.Fd30 = CPFL;
                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.CPLBSJData = AnilyzeFileData<E_CPLBSJ>(MessageData.FileData,
                                            "产品代码|产品名称|",
                                            x =>
                                            {
                                                return new E_CPLBSJ
                                                {
                                                    CPDM = x["产品代码"],
                                                    CPMC = x["产品名称"]
                                                };
                                            });
                output.CPLBSJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
