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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询交易规则要素列表
    /// 通过列表类型查询list_code_rel
    /// </summary>
    public class QueryListCodeRel : TFOutput
    {
        #region Output
        /// <summary>
        /// 列表内容
        /// 列表类型|列表元素描述
        /// </summary>
        public string LBNR { get; internal set; }

        /// <summary>
        /// 列表内容
        /// 列表类型|列表元素描述
        /// </summary>
        public List<E_LBNR> LBNRData { get; internal set; }

        /// <summary>
        /// 列表内容
        /// 列表类型|列表元素描述
        /// </summary>
        public class E_LBNR
        {
            /// <summary>
            /// 列表类型
            /// </summary>
            public string LBLX { get; set; }

            /// <summary>
            /// 列表元素描述
            /// </summary>
            public string LBYSMS { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 列表类型 0710
            ///  
            /// </summary>
            public string LBLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryListCodeRel();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd71 = LBLX;
                MessageData.Fd128 = "0025";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.LBNRData = AnilyzeFileData<E_LBNR>(MessageData.FileData,
                                            "列表类型|列表元素描述|",
                                            x =>
                                            {
                                                return new E_LBNR
                                                {
                                                    LBLX = x["列表类型"],
                                                    LBYSMS = x["列表元素描述"]
                                                };
                                            });
                output.LBNR = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
