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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 错误码同步
    /// 错误码同步
    /// </summary>
    public class QueryErrorCodeInfo : 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 CWM { get; set; }

            /// <summary>
            /// 错误描述
            /// </summary>
            public string CWMS { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {

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

                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
                                                {
                                                    CWM = x["错误码"],
                                                    CWMS = x["错误描述"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
