using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using Platform.Presentation.FocusCheck;
using TellerSystem.Communication;
using Platform.Common.RunningParameters;
using TellerSystem.Library.Ext.Function;
using TellerSystem.Communication.MessageHelper;
using TellerSystem.Library.Ext.TradeExtension;
using TellerSystem.Library.Ext.TradeInterfaces;
using TellerSystem.Library.Ext.Variables;
using Platform.Library;
using System.Text.RegularExpressions;
using System.Windows.Controls;
using System.Windows;
using System.Data;
using System.Windows.Input;
using Platform.Controls.ComponentContainer;
using Platform.Controls.ControlsHelper;
using System.Collections;
using System.Windows.Controls.Primitives;
using Platform.Print;
using Platform.Presentation.Interfaces;
using TellerSystem.ServiceProxy.Ext.ServiceHelper;
using TellerSystem.Contract.Function;
using Platform.Presentation.PageFunctions;
using Platform.Common.BasicFunctions;
using TellerSystem.PrintTemplate.Report;
using TellerSystem.PrintTemplate.Base;
using TellerSystem.Devices.Interface;
using TellerSystem.ServiceProxy.Ext.TradeBusinessEntitys;
using System.IO;
using TellerSystem.PrintTemplate.Extension;
using Platform.Common.LogSystem;
using TellerSystem.Contract.Contracts;
using Newtonsoft.Json;
using TellerSystem.PrintTemplate.Extension;
using TellerSystem.ServiceProxy.Ext;
using TellerSystem.Contract.Entry;
namespace TellerSystem.Contract.ContractBase
{
    /// <summary>
    /// 业务API的访问服务类
    /// </summary>
    public class TradeAPIsHelper
    {
        #region ctor & Property
        public TradeAPIsHelper(PageBase page)
        {
            Page = page;
        }
        public PageBase Page { get; private set; }
        #endregion

        #region 封装交易API函数
        #region Message操作
        /// <summary>
        /// 初始化数据域
        /// </summary>
        /// <param name="message">Message对象</param>
        public void InitFd(Message message)
        {
            SystemFunction.InitFd(Page, message);
        }
        /// <summary>
        /// 初始化常用域
        /// </summary>
        /// <param name="message"></param>
        public void CommSend(Message message)
        {
            SystemFunction.CommSend(Page, message);
        }
        /// <summary>
        /// 辅助域
        /// </summary>
        /// <param name="message"></param>
        public void CommSend96(Message message)
        {
            UserFunction.CommSend96(Page, message);
        }
        /// <summary>
        /// 向核心服务端执行通讯操作
        /// </summary>
        /// <param name="message">Message对象</param>
        /// <returns></returns>
        public bool CallServer(Message message)
        {
            return Page.CallServer(message);
        }
        /// <summary>
        /// 向平台服务端执行通讯操作
        /// </summary>       
        public bool CallAgn(Message message)
        {
            return Page.CallAgn(message);
        }
        /// <summary>
        /// 向Tips服务端执行通讯操作
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnTips(Message message)
        {
            return Page.CallAgnTips(message);
        }
        /// <summary>
        /// 统一跑批
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnRun(Message message)
        {
            return Page.CallAgnRun(message);
        }
        /// <summary>
        /// 向Tips服务端执行通讯操作
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallMobileBanking(Message message)
        {
            return Page.DoTransit(message, TransitType.CallMobileBanking);
        }
        /// <summary>
        ///向有线电视平台通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnCIS(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnCIS);
        }
        /// <summary>
        /// 向IC卡服务端执行通讯操作
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnCard(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnCard);
        }
        /// <summary>
        /// 集团热力
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnHeat01(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnHeat01);
        }
        /// <summary>
        /// 宽城热力
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnHeat02(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnHeat02);
        }
        /// <summary>
        /// 兴业热力
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnHeat03(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnHeat03);
        }
        /// <summary>
        /// 向黄行进行身份检查接口通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnIDC(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnIDC);
        }

        /// <summary>
        /// 超级网银通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnIBPS(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnIBPS);
        }

        /// <summary>
        /// 向身份核查接口平台通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnSHCZ(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnSHCZ);
        }
        /// <summary>
        /// 向新总账平台通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnIBDW(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnIBDW);
        }
        /// <summary>
        /// 向农信银平台通讯 wh 201805改
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnNew(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnNew);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnCardEx(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnCardEx);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnCartoon(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnCartoon);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnHPF(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnHPF);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnTV(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnTV);
        }

        /// <summary>
        /// 向财税库银接口平台通讯 201809 改
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnFSSR(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnFSSR);
        }
        /// <summary>
        /// 存量房监管 
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnCLFJG(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnCLFJG);
        }
        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnHontax(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnHontax);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnOrder(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnOrder);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnMIS(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnMIS);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnWXJJ_LP(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnWXJJ_LP);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnWXJJ_CDX(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnWXJJ_CDX);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnNetBank(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnNetBank);
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnMF01(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnMF01);
        }
        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnMF02(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnMF02);
        }
        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnWater(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnWater);
        }
        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnCnaps2(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnCnaps2);
        }

        /// <summary>
        /// 向网银平台通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_CZYYSW(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_CZYYSW);
        }
        /// <summary>
        /// 向易缴费平台通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_EasyPay(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_EasyPay);
        }
        /// <summary>
        /// 向电子汇票平台通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_Ebill(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_Ebill);
        }
        /// <summary>
        /// 向一窗通平台通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_SDYCT(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_SDYCT);
        }

        /// <summary>
        /// 向燃气费通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_GasFee(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_GasFee);
        }

        /// <summary>
        /// 向农金通通讯
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_NJT(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_NJT);
        }
        /// <summary>
        /// 二代货币反假币
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallNoFileSys(Message message)
        {
            return Page.DoTransit(message, TransitType.CallNoFileSys);
        }
        /// <summary>
        /// 青隆房管局网签
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_FGJWQ(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_FGJWQ);
        }
        /// <summary>
        /// 向农信银网联平台通讯 201912改
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgnNew_WL(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgnNew_WL);
        }
        /// <summary>
        /// 固始公积金
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_GGJ(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_GGJ);
        }

        /// <summary>
        /// 青隆房管局网签   黄骅市
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_FGJWQ_HH(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_FGJWQ_HH);
        }

        /// <summary>
        /// 农民工工资代发   扶沟
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_DF(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_DF);
        }
        /// <summary>
        /// 中牟超网
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_CW(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_CW);
        }
        /// <summary>
        /// 中牟资金监管
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_ZJJG(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_ZJJG);
        }
        /// <summary>
        /// 中牟查控系统
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool CallAgn_CKXT(Message message)
        {
            return Page.DoTransit(message, TransitType.CallAgn_CKXT);
        }

        /// <summary>
        /// 对报文对象进行自定义通讯处理
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="func"></param>
        public void CustomizeTransit(Message msg, Func<Message.CustomizeTransit, bool> func)
        {
            //取消自定义处理
            if (func == null)
            {
                msg.CustomizeTransitEntry = null;
                return;
            }
            msg.CustomizeTransitEntry = new Message.CustomizeTransit(x =>
            {
                return (bool)Page.Dispatcher.Invoke(new Func<bool>(() =>
                {
                    try
                    {
                        return func(x);
                    }
                    catch (Exception ex)
                    {
                        PlatformLogger.SystemErrorInfo("TradeAPIsHelper.CustomizeTransit:执行异常！", ex);
                        x.Error = ex.Message;
                        return false;
                    }
                }));
            });
        }
        #endregion

        #region 控件辅助操作
        /// <summary>
        /// 给combobx添加【“全部”】
        /// </summary>
        /// <param name="element">Combobox集合</param>
        /// <param name="value">索引</param>
        /// <returns>Combobox集合</returns>
        public bool AddItemOfSelecteAll(System.Windows.Controls.ComboBox element, string value = "")
        {
            return SystemFunction.AddItemOfSelecteAll(Page, element, value);
        }
        /// <summary>
        /// 删除combobx【“全部”】
        /// </summary>
        /// <param name="element">Combobox集合</param>
        /// <returns></returns>
        public bool RemoveItemOfSelecteAll(System.Windows.Controls.ComboBox element)
        {
            return SystemFunction.RemoveItemOfSelecteAll(Page, element);
        }

        /// <summary>
        /// 返回错误编号对应的错误信息
        /// </summary>        
        /// <param name="errorNo">错误信息编号</param>
        /// <returns>错误信息</returns>
        public string GetError(Message msg)
        {
            return SystemFunction.GetError(Page, msg);
        }

        /// <summary>
        /// 获取提示信息
        /// </summary>
        /// <param name="notify"></param>
        /// <returns></returns>
        public string GetNotifyMessage(string notify)
        {
            return TransitErrorCodeMap.GetInstance().GetErrorMessage(notify, "notify");
        }

        /// <summary>
        /// 获取提示信息
        /// </summary>
        /// <param name="notify"></param>
        /// <returns></returns>
        public string GetNotifyMessage(NotifyMessage notify)
        {
            return GetNotifyMessage(notify.ToString());
        }

        /// <summary>
        /// 检索CombBox数据,减少通讯次数
        /// </summary>
        /// <param name="comboBox">CombBox数据</param>
        /// <param name="message">message对象</param>
        /// <param name="formatString">Combobox格式</param>
        /// <param name="defalutCombox">默认Combobox标识符</param>
        /// <returns>需要返回错误描述</returns>
        public Result CallComboBoxData(ComboBox comboBox, Message message, string formatString, string defalutCombox = "Null")
        {
            return SystemFunction.CallComboBoxData(Page, comboBox, message, formatString, defalutCombox);
        }

        /// <summary>
        /// 拉取ComboBox数据
        /// </summary>
        /// <param name="selector"></param>
        /// <param name="code"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public bool CallComboBoxData(Selector selector, string code, Dictionary<string, string> arguments = null)
        {
            if (selector == null) return false;
            selector.Items.Clear();
            IEnumerable dict;
            if (string.IsNullOrEmpty(Page.TradeInfo.MainCode))
                dict = SelectionManager.Instance.PullSelection(code, arguments);
            else
                dict = SelectionManager.Instance.PullSelection(code, arguments, Page.TradeInfo.MainCode);
            if (dict == null) return false;
            selector.SetItems(dict);
            return true;
        }

        /// <summary>
        /// 设置控件项是否采用非空验证
        /// </summary>
        /// <param name="element">元素</param>
        /// <param name="flag">flag：true成功 false:失败</param>
        public void SetAssertNotEmpty(FrameworkElement element, bool flag)
        {
            SystemFunction.SetAssertNotEmpty(Page, element, flag);
        }
        /// <summary>
        /// 获取Combobox当前选择项
        /// </summary>
        /// <param name="combo">combobox集合</param>
        /// <returns>返回当前选中的项</returns>
        public string GetSelectedValue(ComboBox combo)
        {
            return UserFunction.GetSelectedValue(combo);
        }
        /// <summary>
        /// ComboBox赋值的SelectValue扩展
        /// </summary>
        /// <param name="combo">ComboBox</param>
        /// <param name="val">value值</param>
        public void SetSelectedValue(ComboBox combo, object val)
        {
            UserFunction.SetSelectedValue(combo, val);
        }
        /// <summary>
        /// 根据Key值为combo赋值
        /// </summary>
        /// <param name="combo">ComboBox</param>
        /// <param name="key">key值</param>
        public void SetSelectedKey(ComboBox combo, string key)
        {
            UserFunction.SetSelectedKey(combo, key);
        }
        /// <summary>
        /// 字符串转换成decimal对象
        /// </summary>
        /// <param name="src">src源对象</param>
        /// <returns>decimal对象</returns>
        public decimal ToDecimal(string src)
        {
            return UserFunction.ToDecimal(src);
        }
        /// <summary>
        ///  将yyyyMMdd格式的字符串转换成对应的DateTime对象
        /// </summary>
        /// <param name="src"></param>
        /// <returns>日期对象</returns>
        public DateTime ToDateTime(string src)
        {
            return UserFunction.ToDateTime(src);
        }
        /// <summary>
        /// 将日期转换成大写
        /// </summary>
        /// <param name="date">8位日期</param>
        /// <returns></returns>
        public string[] DateToBig(string date)
        {
            return Page.DateToBig(date);
        }
        #endregion

        #region 字符串数字处理类
        #region 转换字符串为数字 atoi(string)
        /// <summary>
        /// 将数字串转换成整数
        /// </summary>
        /// <param name="number">数字串</param>
        /// <returns>整数</returns>
        public int Atoi(string number)
        {
            return SystemFunction.Atoi(Page, number);
        }
        #endregion

        #region  转换数字为字符串 itoa(number,string)
        /// <summary>
        /// 将数字按指定格式格式化为字符串 暂时支持%d %f这两大类
        /// </summary>
        /// <param name="target"></param>
        /// <param name="numString">数字字符串</param>
        /// <param name="targetStyle">格式</param>
        /// <returns>格式化后的字符串</returns>
        public string Itoa(decimal number, string format)
        {
            return SystemFunction.Itoa(Page, number, format);
        }
        #endregion

        #region 截取一个子串 substr(string,number,number)
        /// <summary>
        /// 截取子字符串
        /// </summary>      
        /// <param name="sourcedata">源字符串</param>
        /// <param name="startIndex">起始index</param>
        /// <param name="length">截取长度</param>
        /// <returns>返回截取后的值</returns>
        public string SubStr(string sourceData, int start, int length)
        {
            return SystemFunction.SubStr(Page, sourceData, start, length);
        }
        #endregion

        #region 得到字符串的长度	len(string)
        /// <summary>
        /// 内部函数，取得字符串长度
        /// </summary>
        /// <param name="target"></param>
        /// <param name="sourcedata"></param>
        /// <returns></returns>
        public int Len(string sourceData)
        {
            return SystemFunction.Len(Page, sourceData);
        }
        #endregion

        #region 把指定的ascii码值转换为字符串	chr(number)
        /// <summary>
        /// 将ASCII码值转换为字符串
        /// </summary>        
        /// <param name="number">ASCII码值</param>
        /// <param name="targetChar">字符串</param>
        /// <returns></returns>
        public string Chr(int number)
        {
            return SystemFunction.Chr(Page, number);
        }
        #endregion

        #region 求两个整数的余	mod(number1,number)
        /// <summary>
        /// 求两个整数的余
        /// </summary>
        /// <param name="number1"></param>
        /// <param name="number2"></param>        
        /// <returns></returns>
        public int Mod(int number1, int number2)
        {
            return SystemFunction.Mod(Page, number1, number2);
        }
        #endregion

        #region 把一个数字型字符串转换为','分割的形式	comma(string,[number])
        /// <summary>
        /// 将数字串转换成千分位方式显示
        /// </summary>      
        /// <param name="sourcedata">处理前数据</param>
        /// <param name="length">指定长度</param>
        /// <param name="targetdata">处理后数据</param>
        /// <returns></returns>
        public string Comma(string sourceData, int length)
        {
            return SystemFunction.Comma(Page, sourceData, length);
        }
        #endregion

        #region 得到数字字符串对应的数值	val(string,[number])
        /// <summary>
        /// 数字串（十进制或十六进制）与权重相乘
        /// </summary>        
        /// <param name="sourcedata">数字串</param>
        /// <param name="weight">权重</param>
        /// <param name="targetdata">结果</param>
        /// <returns></returns>
        public decimal Val(string sourceData, decimal weight)
        {
            return SystemFunction.Val(Page, sourceData, weight);
        }
        #endregion

        #region 去掉尾部空格 	rtrim(string)
        /// <summary>
        /// 去除字符串后面空格
        /// </summary>
        /// <param name="sourceData">源数据</param>
        /// <returns>处理后数据</returns>
        public string RTrim(string sourceData)
        {
            return SystemFunction.RTrim(Page, sourceData);
        }
        #endregion

        #region 去掉左边空格	 ltrim(string)
        /// <summary>
        /// 去除字符串开始空格
        /// </summary>
        /// <param name="sourceData">源数据</param>
        /// <returns>处理后数据</returns>
        public string LTrim(string sourceData)
        {
            return SystemFunction.LTrim(Page, sourceData);
        }

        #endregion

        #region 去掉所有空格，包括字符串中间的空格	delspace(string)
        /// <summary>
        /// 内部函数，去掉空格
        /// </summary>       
        /// <param name="sourcedata">数据源</param>
        /// <returns></returns>
        public string Delspace(string sourceData)
        {
            return SystemFunction.Delspace(Page, sourceData);
        }
        #endregion

        #region 左补齐参数字符	 PadLeft(string,int,char)
        /// <summary>
        /// 左补齐参数字符
        /// </summary>        
        /// <param name="sourcedata">源字符串</param>
        /// <param name="len">补齐长度</param>
        /// <param name="var">参数字符</param>
        /// <returns></returns>
        public string PadLeft(string sourcedata, int length, char var = ' ')
        {
            return SystemFunction.PadLeft(Page, sourcedata, length, var);
        }
        #endregion

        #region 右补齐参数字符	 PadRight(string,length,var)
        /// <summary>
        /// 右补齐参数字符
        /// </summary>        
        /// <param name="sourcedata">源字符串</param>
        /// <param name="len">补齐长度</param>
        /// <param name="var">参数字符</param>
        /// <returns></returns>
        public string PadRight(string sourcedata, int length, char var = ' ')
        {
            return SystemFunction.PadRight(Page, sourcedata, length, var);
        }
        #endregion

        #region 以某个字符构建某长度的字符串	Space(lenth,char)
        /// <summary>
        /// 以某个字符构建某长度的字符串
        /// </summary>
        /// <param name="c">字符</param>
        /// <param name="lenght">长度</param>
        /// <returns></returns>
        public string Space(int lenght, char c = ' ')
        {
            return SystemFunction.Space(Page, lenght, c);
        }
        #endregion

        #region 计算两个日期直接的绝对差值（天数）
        /// <summary>
        /// 计算两个日期之间的绝对差值（天数）
        /// </summary>        
        /// <param name="fDate">起始日期</param>
        /// <param name="sDate">终止日期</param>
        /// <returns>相距天数</returns>
        public int Func(string fDate, string sDate)
        {
            var startDate = new DateTime(int.Parse(fDate.Substring(0, 4)), int.Parse(fDate.Substring(4, 2)), int.Parse(fDate.Substring(6)));
            var endDate = new DateTime(int.Parse(sDate.Substring(0, 4)), int.Parse(sDate.Substring(4, 2)), int.Parse(sDate.Substring(6)));
            var timeSpan = endDate - startDate;
            return timeSpan.Days;
        }
        #endregion

        #region 将数字类型转换成大写金额字符串 ChangeToCNY（decimal）
        /// <summary>
        /// 将数字类型转换成大写金额字符串
        /// </summary>       
        /// <param name="num">数字</param>
        /// <returns>金额字符串</returns>
        public string ChangeToCNY(decimal num)
        {
            return SystemFunction.ChangeToCNY(Page, num);
        }
        #endregion

        #region  按格式解析返回字串，给combox添加项
        /// <summary>
        /// 按格式解析返回字串，给combox添加项 SetSel(ComboBox,string,string)
        /// </summary>
        /// <param name="target"></param>
        /// <param name="comboBox"></param>
        /// <param name="fileData"></param>
        /// <param name="formatString"></param>
        /// <returns></returns>
        public bool SetSel(ComboBox comboBox, string fileData, string formatString)
        {
            return SystemFunction.SetSel(Page, comboBox, fileData, formatString);
        }
        #endregion

        #region 非法汉字字符检查
        /// <summary>
        /// 检查是否非法字符
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public bool CheckHalf(string str)
        {
            return true;
        }
        #endregion

        #region 格式化金额数值：千分位、去空格（左对齐）
        public string FormatAMT(decimal amtVal)
        {
            return Delspace(Comma(amtVal.ToString(), 17));
        }
        #endregion

        #region 将数字转换成中文
        static List<string> unit = new List<string> { "", "十", "百", "千", "万", "十万", "百万", "千万", "亿", "十亿", "百亿", "千亿", "万亿" };
        static List<string> unit_T = new List<string> { "", "拾", "佰", "仟", "萬", "拾萬", "佰萬", "仟萬", "亿", "拾亿", "佰亿", "仟亿", "萬亿" };
        /// <summary>
        /// 将整数转化成中文数字串
        /// </summary>
        /// <param name="value"></param>
        /// <param name="isSimple"></param>
        /// <param name="hasUnit"></param>
        /// <returns></returns>
        public string ChangeToCI(int value, bool isSimple = true, bool hasUnit = false)
        {
            var ret = new StringBuilder();
            var data = Math.Abs(value).ToString();
            for (int i = 0; i < data.Length; i++)
            {
                char item = data[i];
                var c = string.Empty;
                switch (item)
                {
                    case '0': c = isSimple ? "零" : "零"; break;
                    case '1': c = isSimple ? "一" : "壹"; break;
                    case '2': c = isSimple ? "二" : "贰"; break;
                    case '3': c = isSimple ? "三" : "叁"; break;
                    case '4': c = isSimple ? "四" : "肆"; break;
                    case '5': c = isSimple ? "五" : "伍"; break;
                    case '6': c = isSimple ? "六" : "陆"; break;
                    case '7': c = isSimple ? "七" : "柒"; break;
                    case '8': c = isSimple ? "八" : "捌"; break;
                    case '9': c = isSimple ? "九" : "玖"; break;
                    default:
                        throw new ArgumentException("ChangeToCI:参数异常！");
                }
                ret.Append(c);
                if (hasUnit)
                {
                    //加载单位
                    ret.Append(isSimple ? unit[data.Length - i - 1] : unit_T[data.Length - i - 1]);
                }
            }
            return ret.ToString();
        }
        #endregion

        /// <summary>
        /// 将汉字（零，一 ……十二转换为阿拉伯数字1至12）
        /// </summary>
        /// <param name="value">要转换的汉字数字</param>
        /// <returns>转换后的阿拉伯数字</returns>
        public int ChangeToNum(string value)
        {
            int c = -1;
            switch (value)
            {
                case "零": c = 0; break;
                case "一": c = 1; break;
                case "二": c = 2; break;
                case "三": c = 3; break;
                case "四": c = 4; break;
                case "五": c = 5; break;
                case "六": c = 6; break;
                case "七": c = 7; break;
                case "八": c = 8; break;
                case "九": c = 9; break;
                case "十": c = 10; break;
                case "十一": c = 11; break;
                case "十二": c = 12; break;
                default: break;
            }
            return c;
        }

        #region 转换证件类型
        private static Dictionary<string, string> _LicKindList_;
        /// <summary>
        /// 证件类型转换,支持双向转换
        /// </summary>
        /// <param name="kind"></param>
        /// <returns></returns>
        public string ChgLicKind(string kind)
        {
            if (_LicKindList_ == null)
            {
                _LicKindList_ = SelectionManager.Instance.PullSelection("C004", null);
                SelectionManager.Instance.PullSelection("C003", null).ToList().ForEach(x => _LicKindList_[x.Key] = x.Value);
            }
            if (_LicKindList_.ContainsKey(kind))
                return _LicKindList_[kind];
            var item = _LicKindList_.FirstOrDefault(x => x.Value == kind);
            return item.Key ?? kind;
        }
        #endregion

        #endregion

        #region 解析文本文件、excel文件、DataTable文件
        /// <summary>
        /// 解析文本文件导入数据
        /// </summary>
        /// <param name="txt_RowSplit">行分隔符</param>
        /// <param name="txt_ColumnSlit">列分割符</param>
        /// <param name="txt_EnCode">编码方式</param>
        /// <param name="isColumnHeader">是否显示列头</param>
        /// <returns>返回一个DataTable</returns>
        public DataTable AnalyzeTxtData(char[] txt_RowSplit, char txt_ColumnSlit, string txt_EnCode, bool isColumnHeader = true)
        {
            return SystemFunction.AnalyzeTxtData(txt_RowSplit, txt_ColumnSlit, txt_EnCode, isColumnHeader);
        }
        /// <summary>
        /// 解析Excel文件导入的数据
        /// </summary>
        /// <param name="RowCount">可选参数 RowCount=0-默认解析全部行</param>
        /// <param name="columnCount">可选参数 ColumnCount=0-默认解析全部列</param>
        /// <returns>返回DataTable</returns>
        public DataTable AnalyseExcelData(int RowCount = 0, int columnCount = 0)
        {
            return SystemFunction.AnalyseExcelData(RowCount, columnCount);
        }
        /// <summary>
        /// 解析DataTable结构到指定方式的txt文件流
        /// </summary>
        /// <param name="data">DataTable数据结构</param>
        /// <param name="txt_RowSplit">行分隔符</param>
        /// <param name="txt_ColumnSlit">列分割符</param>
        ///  <returns>返回byte[]文件流</returns>
        public string AnalyseDataTable(DataTable data, string txt_RowSplit, string txt_ColumnSlit)
        {
            return AnalyseDataTable(data, txt_RowSplit, txt_ColumnSlit);
        }
        #endregion

        #region 文件操作相关
        /// <summary>
        /// 执行服务端shell命令
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public bool Shell(string cmd)
        {
            return TradeHandle.ExcuteShell(cmd);
        }

        /// <summary>
        /// 获取服务端文件的内容
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public string Getfiletxt(string fileName)
        {
            return SystemFunction.Getfiletxt(fileName);
        }
        /// <summary>
        /// 往服务端保存文件
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <param name="fileContent">内容</param>
        /// <param name="append">是否追加</param>
        /// <returns>布尔型，是否保存成功</returns>
        public bool Savefiletxt(string fileName, string fileContent, bool append)
        {
            return SystemFunction.Savefiletxt(fileName, fileContent, append);
        }
        #endregion

        #region MessageBox-弹出消息框
        #region 消息提示默认值
        const bool IsCoverAll = true;
        const bool IsReverse = true;
        const int Direction = 3;
        const bool AnimationEnable = false;
        #endregion

        #region 输入信息提示
        /// <summary>
        /// Tip消息提示
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool ShowTip(string message)
        {
            FrameworkElement current = this.Page;
            var flag = Platform.Presentation.FocusManagers.FocusManager.GetEnableFocusControl(this.Page);
            if (flag)
            {
                var fm = Platform.Presentation.FocusManagers.FocusManager.GetManagerInstance(this.Page);// new UIElement();

                if (fm != null)
                    current = fm.CurrentFocusedElement;
            }
            return ShowTip(current, message);
        }

        /// <summary>
        /// Tip消息提示
        /// </summary>
        /// <param name="target"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool ShowTip(UIElement target, string message)
        {
            return target.ShowTip(message);
        }

        /// <summary>
        /// Tip消息提示
        /// </summary>
        /// <param name="target"></param>
        /// <param name="placement"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool ShowTip(UIElement target, string message, TipAdornerPlacement placement = TipAdornerPlacement.Bottom)
        {
            return target.ShowTip(placement, message);
        }
        #endregion

        #region 功能选择消息提示
        /// <summary>
        /// 弹出一个自定义按钮提示框，这个是有效的实现
        /// </summary>
        /// <param name="message"></param>
        /// <param name="comfirm"></param>
        /// <param name="defaultfocus"></param>
        /// <returns></returns>
        public string ShowComfirmBox(string message, List<string> comfirm, string defaultfocus = null)
        {
            var def = 1;
            if (comfirm.Contains(defaultfocus))
                def = comfirm.IndexOf(defaultfocus) + 1;
            var ret = Page.ShowComfirmBox(message, comfirm, def);
            return comfirm[ret];
        }

        /// <summary>
        /// 弹出一个自定义按钮提示框
        /// </summary>        
        /// <param name="message">显示的内容</param>
        /// <param name="comfirm">按钮和快捷键键值对</param>
        /// <param name="defaultfocus">默认定位的按钮焦点</param>
        /// <returns></returns>
        [Obsolete]
        public Key ShowComfirmBox(string message, Dictionary<Key, string> comfirm, Key defaultfocus = Key.None)
        {
            return Page.ShowPageMessageBoxExt(message, comfirm, defaultfocus);
        }

        /// <summary>
        /// 询问决策消息框，最多允许6个分支，返回值为1-6
        /// </summary>
        /// <param name="message">message对象</param>
        /// <param name="comfirm">扩展参数-快捷键键值对集合</param>
        /// <returns>返回询问框索引</returns>
        public int ShowComfirmBox(string message, params string[] comfirm)
        {
            return Page.ShowComfirmBox(message, comfirm);
        }
        #endregion

        #region 推送消息提示
        /// <summary>
        /// 推送消息提示
        /// </summary>
        /// <param name="content"></param>
        /// <param name="caption"></param>
        public void ShowPopueMessageBox(object content, string caption = "提示信息")
        {

        }
        #endregion

        #region 默认选择提示

        /// <summary>
        /// 显示一个询问提示框
        /// </summary>       
        /// <param name="content">显示的内容</param>
        /// <param name="caption">标题</param>
        /// <param name="focuResult">默认焦点</param>
        /// <param name="results">选项列表</param>
        /// <returns></returns>
        public MessageBoxResult ShowQuestionMessageBox(object content, string caption = "询问信息", MessageBoxResult focuResult = MessageBoxResult.Yes, MessageBoxButton results = MessageBoxButton.YesNo)
        {
            var result = Page.ShowPageMessageBoxMetro(content, caption, null, ConvertMessageBoxResultToStr(focuResult), Direction, IsReverse, IsCoverAll, AnimationEnable, ConvertMessageBoxButton(results));
            return ConvertStrToMessageBoxResult(result);
        }

        /// <summary>
        /// 显示一个自定义抉择的询问提示框
        /// </summary>       
        /// <param name="content">显示的内容</param>
        /// <param name="caption">标题</param>
        /// <param name="focuResult">默认焦点</param>
        /// <param name="results">选项列表</param>
        /// <returns></returns>
        public string ShowQuestionMessageBox(object content, string[] results, int defaultIndex, string caption = "询问信息")
        {
            var defaultValue = results[results.Length > defaultIndex ? defaultIndex : 0];
            return Page.ShowPageMessageBoxMetro(content, caption, null, defaultValue, Direction, IsReverse, IsCoverAll, AnimationEnable, results);
        }
        #endregion

        #region 场景信息提醒提示
        /// <summary>
        /// 显示一个成功信息提示框
        /// </summary>       
        /// <param name="content">显示的内容</param>
        /// <param name="caption">标题</param>
        /// <returns></returns>
        public MessageBoxResult ShowSuccessMessageBox(object content = null, string caption = "业务办理成功")
        {
            var image = Application.Current.Resources["MessageBoxMetroSuccess"] as ImageSource;
            var result = Page.ShowPageMessageBoxMetro(content, caption, image, ConvertMessageBoxResultToStr(MessageBoxResult.OK), Direction, IsReverse, IsCoverAll, AnimationEnable, ConvertMessageBoxButton(MessageBoxButton.OK));
            return ConvertStrToMessageBoxResult(result);
        }

        /// <summary>
        /// 显示一个信息提示框
        /// </summary>       
        /// <param name="content">显示的内容</param>
        /// <param name="caption">标题</param>
        /// <returns></returns>
        public MessageBoxResult ShowInfoMessageBox(object content = null, string caption = "提示信息")
        {
            var image = Application.Current.Resources["MessageBoxMetroInfo"] as ImageSource;
            var result = Page.ShowPageMessageBoxMetro(content, caption, image, ConvertMessageBoxResultToStr(MessageBoxResult.OK), Direction, IsReverse, IsCoverAll, AnimationEnable, ConvertMessageBoxButton(MessageBoxButton.OK));
            return ConvertStrToMessageBoxResult(result);
        }

        /// <summary>
        /// 显示一个错误提示框
        /// </summary>        
        /// <param name="content">显示的内容</param>
        /// <param name="caption">标题</param>
        /// <returns></returns>
        public MessageBoxResult ShowErrorMessageBox(object content = null, string caption = "错误信息")
        {
            var image = Application.Current.Resources["MessageBoxMetroError"] as ImageSource;
            var result = Page.ShowPageMessageBoxMetro(content, caption, image, ConvertMessageBoxResultToStr(MessageBoxResult.OK), Direction, IsReverse, IsCoverAll, AnimationEnable, ConvertMessageBoxButton(MessageBoxButton.OK));
            return ConvertStrToMessageBoxResult(result);
        }

        /// <summary>
        /// 显示一个警告提示框
        /// </summary>        
        /// <param name="content">显示的内容</param>
        /// <param name="caption">标题</param>
        /// <returns></returns>
        public MessageBoxResult ShowWarnMessageBox(object content = null, string caption = "警告信息")
        {
            var image = Application.Current.Resources["MessageBoxMetroWarn"] as ImageSource;
            var result = Page.ShowPageMessageBoxMetro(content, caption, image, ConvertMessageBoxResultToStr(MessageBoxResult.OK), Direction, IsReverse, IsCoverAll, AnimationEnable, ConvertMessageBoxButton(MessageBoxButton.OK));
            return ConvertStrToMessageBoxResult(result);
        }

        #region 转换方法
        private MessageBoxResult ConvertStrToMessageBoxResult(string str)
        {
            str = str ?? string.Empty;
            switch (str.Trim())
            {
                case "取消":
                    return MessageBoxResult.Cancel;
                    break;
                case "否":
                    return MessageBoxResult.No;
                    break;
                case "确定":
                    return MessageBoxResult.OK;
                    break;
                case "是":
                    return MessageBoxResult.Yes;
                    break;
                default:
                    return MessageBoxResult.None;
                    break;
            }
        }

        private string ConvertMessageBoxResultToStr(MessageBoxResult result)
        {
            switch (result)
            {
                case MessageBoxResult.Cancel:
                    return "取消";
                    break;
                case MessageBoxResult.No:
                    return "否";
                    break;
                case MessageBoxResult.OK:
                    return "确定";
                    break;
                case MessageBoxResult.Yes:
                    return "是";
                    break;
                default:
                    return "未知";
                    break;
            }
        }

        private string[] ConvertMessageBoxButton(MessageBoxButton msg)
        {
            switch (msg)
            {
                case MessageBoxButton.OK:
                    return new string[] { "确定" };
                    break;
                case MessageBoxButton.OKCancel:
                    return new string[] { "确定", "取消" };
                    break;
                case MessageBoxButton.YesNo:
                    return new string[] { "是", "否" };
                    break;
                case MessageBoxButton.YesNoCancel:
                    return new string[] { "是", "否", "取消" };
                    break;
                default:
                    return null;
                    break;
            }
        }
        #endregion

        #endregion

        #endregion

        #region DataBox相关函数
        /// <summary>
        /// 初始化DataBox数据
        /// </summary>
        /// <param name="databox">DataBox数据源</param>
        public void InitDataBox(DataBox databox)
        {
            databox.InitDataBox();
        }
        /// <summary>
        /// 把databox数据转换成DataTable
        /// </summary>
        /// <param name="databox">DataBox数据源</param>
        /// <returns>DataTable对象</returns>
        public DataTable GetDataForDataTable(DataBox databox)
        {
            return databox.GetDataForDataTable();
        }
        /// <summary>
        /// 把databox数据转换成字符串
        /// </summary>
        /// <param name="databox">DataBox数据源</param>
        /// <returns>字符串</returns>
        public string GetDataForString(DataBox databox)
        {
            return databox.GetDataForString();
        }
        /// <summary>
        /// 绑定DataTable数据源并自动设置列宽
        /// </summary>
        /// <param name="databox">DataBox数据源</param>
        /// <param name="dtSource">DataTable对象</param>
        public void BindDataTable(DataBox databox, DataTable dtSource)
        {
            databox.BindDataTable(dtSource);
        }
        /// <summary>
        /// 数据绑定,显示所有数据
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="fileData">数据源</param>
        /// <param name="columnName">显示指定列名,如果数据源中没有列名,必须显示指定</param>
        public void DataBinding(DataBox databox, string fileData, params string[] columnName)
        {
            databox.DataBinding(fileData, columnName);
        }
        /// <summary>
        /// 数据绑定,显示所有数据
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="fileData">XML数据源</param>
        /// <param name="nodeName">最后一级Node目录名</param>
        /// <param name="columnName">显示指定列名,如果数据源中没有列名,必须显示指定</param>
        public void DataBinding(DataBox databox, string fileData, string nodeName, params string[] columnName)
        {
            var str = DataBoxExtension.AnalyzeXMLtoStr(fileData, nodeName);
            databox.DataBinding(string.IsNullOrEmpty(str) ? fileData : str, columnName);
        }
        /// <summary>
        /// 数据绑定,根据数据显示等级对于数据进行相应处理
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="fileData">数据源</param>
        /// <param name="level">数据显示等级</param>
        /// <param name="columnNames">显示指定列名,如果数据源中没有列名,必须显示指定</param>
        public void DataBinding(DataBox databox, string fileData, DisplayLevelEnum level, params string[] columnNames)
        {
            databox.DataBinding(fileData, level, columnNames);
        }
        /// <summary>
        /// 设置列明
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="columnIndex">列索引</param>
        /// <param name="header">列标头</param>
        public void SetColumnsHeader(DataBox databox, int columnIndex, string header)
        {
            databox.SetColumnsHeader(columnIndex, header);
        }
        /// <summary>
        /// 设置列宽
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="columnIndex">列索引</param>
        /// <param name="width">列宽度</param>
        public void SetColumnsWidth(DataBox databox, int columnIndex, double width)
        {
            databox.SetColumnsWidth(columnIndex, width);
        }
        /// <summary>
        /// 设置列的显示状态
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="columnIndex">列索引</param>
        /// <param name="visible">是否隐藏</param>
        public void SetColumnsVisible(DataBox databox, int columnIndex, bool visible)
        {
            databox.SetColumnsVisible(columnIndex, visible);
        }
        /// <summary>
        /// 格式化当前列的值
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="columnIndex">列索引</param>
        /// <param name="format">格式化字符串</param>
        public void SetColumnsFormat(DataBox databox, int columnIndex, string format)
        {
            databox.SetColumnsFormat(columnIndex, format);
        }
        /// <summary>
        /// 设置当前列的对其方式
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="columnIndex">当前列的索引</param>
        /// <param name="align">枚举 Center 居中对齐、Justify 两端对其、Left 文本左对齐、Right 文本右对齐</param>
        public void SetColumnsAlign(DataBox databox, int columnIndex, TextAlignment align)
        {
            databox.SetColumnsAlign(columnIndex, align);
        }
        /// <summary>
        /// 获取当前选择的所有行
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <returns>当前选择的所有行DataRow集合</returns>
        public DataRow[] GetSelectMultiRows(DataBox databox)
        {
            return databox.GetSelectMultiRows();
        }
        /// <summary>
        /// 获取选中的行
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <returns>选中前行</returns>
        public DataRow GetSelectSingleRow(DataBox databox)
        {
            return databox.GetSelectSingleRow();
        }
        /// <summary>
        /// 获取当前行的值
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <returns>返回当前行的所有列</returns>
        public string[] GetSelectRowValue(DataBox databox, bool hasRowIndex = true)
        {
            var ret = databox.GetSelectRowValue();
            if (!hasRowIndex && ret != null && ret.Length > 1)
            {
                var tmp = new string[ret.Length - 1];
                Array.Copy(ret, 1, tmp, 0, tmp.Length);
                ret = tmp;
            }
            return ret;
        }
        /// <summary>
        /// 将指定列名的列转换为ComboBoxColumn
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="colName">列明</param>
        /// <param name="dic">字典</param>
        public void SetSel(DataBox databox, string colName, Dictionary<string, string> dic)
        {
            databox.SetSel(colName, dic);
        }
        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="column">列</param>
        public void AddColumn(DataBox databox, DataGridColumn column)
        {
            databox.AddColumn(column);
        }
        /// <summary>
        /// 添加带下划线的列的内容
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="colName">列名称</param>
        /// <param name="click">注册的事件</param>
        /// <param name="hotkey">焦点</param>
        public void AddHyperlinkColumn(DataBox databox, string colName, RoutedEventHandler click, Key hotkey = Key.None)
        {
            databox.AddHyperlinkColumn(colName, click, hotkey);
        }
        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="newRow">DataRow</param>
        /// <returns>布尔型 是否添加成功</returns>
        public bool AddRow(DataBox databox, DataRow newRow)
        {
            return databox.AddRow(newRow);
        }
        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="databox">DataBox</param>
        /// <param name="values">变量的集合</param>
        /// <returns>是否添加成功</returns>
        public bool AddRow(DataBox databox, params object[] values)
        {
            return databox.AddRow(values);
        }
        /// <summary>
        /// 更新行
        /// </summary>
        /// <param name="target">DataBox</param>
        /// <param name="values">当前行的数组</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateRow(DataBox target, params object[] values)
        {
            return target.UpdateRow(values);
        }
        /// <summary>
        /// 删除选中的所有行(多选和单选)
        /// </summary>
        /// <returns>布尔型True|False</returns>
        public bool DeleteSelectRows(DataBox databox)
        {
            return databox.DeleteSelectRows();
        }
        #endregion

        #region Combobox控件相关
        /// <summary>
        /// 添加数据列表
        /// </summary>
        /// <param name="target">集合控件</param>
        /// <param name="items">数据列表</param>
        public void AddItems(ItemsControl target, IEnumerable items)
        {
            target.AddItems(items);
        }
        /// <summary>
        /// 设置数据列表
        /// </summary>
        /// <param name="target">集合控件</param>
        /// <param name="items">数据列表</param>
        public void SetItems(ItemsControl target, IEnumerable items)
        {
            target.SetItems(items);
        }
        /// <summary>
        /// 取Combobox当前值
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public string GetSelectedKey(Selector target)
        {
            return target.GetSelectedKey();
        }

        #endregion

        #region 设置焦点相关
        /// <summary>
        /// 设置焦点
        /// </summary>
        /// <param name="element">当前元素</param>
        public void SetFocus(FrameworkElement element = null)
        {
            Page.SetFocus(element);
        }
        #endregion

        #region 检查账号是否是卡
        /// <summary>
        /// 检查账号是否是卡，是，返回true；否，返回false
        /// </summary>
        /// <param name="acno">账号</param>
        /// <returns></returns>
        public bool CheckCardBin(string acno)
        {
            return Page.CheckCardBin(acno);
        }
        #endregion

        #region 打印相关
        /// <summary>
        /// 创建一个仅具备特殊标签的打印对象
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="markText"></param>
        public PrintContainer CreateSpecialMarkPrint(PrintTypes pt, double left, double top, string markText)
        {
            var tb = new TemplateBase();
            tb.PrintType = pt;
            tb.DrawingSpecialMark(left, top, markText);
            return tb;
        }

        /// <summary>
        /// 创建一个仅具备特殊标签的打印对象
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="markText"></param>
        public PrintContainer CreateSpecialMarkPrint(PrintTypes pt, double left, double top, UIElement element)
        {
            var tb = new TemplateBase();
            tb.PrintType = pt;
            tb.DrawingSpecialMark(left, top, element);
            return tb;
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// 打印表单（非补打交易）
        /// </summary>
        public void PrintCertificate(PrintContainer[] authForms)
        {
            Page.PrintCertificate(authForms);
            //add by chuhai 清空前端流水，避免交易不关闭导致流水重复。
            Page.ClearSerialNumber();
        }

        ///// <summary>
        ///// TODO NotImplemented By NanQi 20140219
        ///// 打印表单（非补打交易）
        ///// </summary>
        //public void PrintCertificate(PrintContainer authForm)
        //{

        //}

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// 分录打印
        /// </summary>
        public string PrintAcdtl_1(Message message)
        {
            return string.Empty;
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// 分录打印
        /// </summary>
        public string PrintAcdtl_hst(Message message)
        {
            return string.Empty;
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// 取消分录
        /// </summary>
        public string PrintAcdtl_h(Message message)
        {
            return string.Empty;
        }

        /// <summary>
        /// TODO NotImplemented By NanQi 20140219
        /// 授权
        /// </summary>
        public string Print_Sq(Message message)
        {
            return string.Empty;
        }

        /// <summary>
        /// 根据格式化字符串打印报表信息
        /// </summary>
        /// <param name="formatMessage">格式化的字符串</param>
        /// <param name="reportURI">报表的资源路径</param>
        /// <param name="paraDic">额外的参数</param>
        public void PrintReport(string formatMessage, string reportURI, Dictionary<string, string> paraDic)
        {

            StringBuilder sb = new StringBuilder();
            sb.Append(formatMessage);
            if (paraDic != null)
            {
                sb.AppendLine("[parameters]");
                foreach (var item in paraDic)
                {
                    sb.AppendLine(item.Key + "=" + item.Value);
                }
                sb.AppendLine(";");
            }
            ReportEntity re = new ReportEntity(reportURI);
            //补偿PrintAttributes给ReportEntity
            var pa = PrintContainerExt.GetPrintElement(this.Page);
            if (pa == null) pa = this.Page.GetPrintAttributes();
            PrintContainerExt.SetPrintElement(re, pa);
            re.Analyze(sb.ToString());
            re.Print();
        }
        #endregion

        #region 查找上层Ipage
        private T FindAncestor<T>(UIElement element) where T : class
        {
            DependencyObject obj = new DependencyObject();
            for (obj = VisualTreeHelper.GetParent(element); !(obj is T); obj = VisualTreeHelper.GetParent(obj))
            {
                if (obj == null) break;
            }

            return obj as T;
        }
        #endregion

        #region 授权/复核
        /// <summary>
        /// 还原交易页面
        /// </summary>
        /// <param name="target"></param>
        /// <param name="serialid">流水ID</param>
        /// <param name="resultflag">操作结果(授权或复核)</param>
        /// <param name="busData">总线数据</param>
        public void RestoreTradePage(string serialid, TradeBusData busData)
        {
            Page.ShowTradeTab(serialid, new Action<IPage>(page =>
            {
                Page.Dispatcher.BeginInvoke(new Action(() =>
                {
                    string resultKey = busData.ContainsKey("SuperFlag") ? "SuperFlag" : "AuthFlag";
                    bool resultflag = false;
                    if (!string.IsNullOrWhiteSpace(busData[resultKey]))
                    {
                        resultflag = bool.Parse(busData[resultKey]);
                    }
                    // 没有找到page，说明已经关闭过前端软件
                    if (page == null)
                    {
                        // target.ShowErrorMessageBox("此任务的交易已丢失！");
                        // 如果target是消息推送过来的，用target.ShowErrorMessageBox会报错，暂时用这个代替
                        this.ShowInfoMessageBox("此任务的交易已丢失,请重新做该交易");
                        //MessageBox.Show("此任务的交易已丢失,请重新做该交易", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        string deletereason = "";
                        if ("SuperFlag".Equals(resultKey))
                        {
                            deletereason = "SuperFaild";
                        }
                        else if ("AuthFlag".Equals(resultKey))
                        {
                            deletereason = "AuthFaild";
                        }
                        else
                        {
                            deletereason = "TellerDelete";
                        }
                        // 如果失败，不管是找没找到能还原的界面，因为工作流配置为不非环形流程，都需要删除流程，tradepage的流水号serialid也不用更新，
                        // 如果还原了界面，客户还可以使用原来的流水号再提交申请，这个由服务端做了处理。
                        WorkFlowHandle.deleteProcessInsById(busData["ProcessId"], deletereason); // TellerDelete只是做为删除流程实例原因的描述
                    }
                    else
                    {
                        //TabItem item = page.GetCurrentTabItem();
                        page.GetTradeInfoData().SetTradeBus(busData);// .SetTradeData(data);                        
                        //CheckManager c = item as CheckManager;
                        //AuthManager a = item as AuthManager;
                        AsksuperResultType t = AsksuperResultType.Failed;
                        if (resultflag)
                        {
                            if (busData.ContainsKey("WorkItemId"))
                            {
                                WorkFlowHandle.CompleteTaskById(busData["WorkItemId"]); //提交任务
                            }
                            t = AsksuperResultType.Success;
                        }
                        else
                        {
                            string deletereason = string.Empty;
                            string processid = string.Empty;
                            if ("SuperFlag".Equals(resultKey))
                            {
                                CheckDataHelper checkdata = new CheckDataHelper(page);
                                deletereason = "SuperFaild";
                                processid = checkdata.ProcessId;
                                checkdata.ClearCheckData();
                            }
                            else if ("AuthFlag".Equals(resultKey))
                            {
                                deletereason = "AuthFaild";
                                AuthDataHelper authdata = new AuthDataHelper(page);
                                processid = authdata.ProcessId;
                                authdata.ClearAuthData();
                            }
                            /* 如果失败，不管是找没找到能还原的界面，因为工作流配置为不非环形流程，都需要删除流程，tradepage的流水号serialid也不用更新，
                             如果还原了界面，客户还可以使用原来的流水号再提交申请，这个由服务端做了处理。
                            TellerDelete只是做为删除流程实例原因的描述  */
                            WorkFlowHandle.deleteProcessInsById(processid, deletereason);
                            t = AsksuperResultType.Failed;
                        }

                        //if (c != null)
                        //    c.Result(t, busData);
                        //else
                        var c = CheckManager.GetCheckManager(page as DependencyObject);
                        var a = AuthManager.GetAuthManager(page as DependencyObject);
                        if (c != null && resultKey == "SuperFlag")
                            c.Result(t, busData);
                        else if (a != null && resultKey == "AuthFlag")
                            a.Result(t, busData);
                    }
                }), System.Windows.Threading.DispatcherPriority.Loaded, null);
            }));
            return;
            //IPage page = Page.ShowTradeTab(serialid);
            ////后续的动作都需要等待页面呈现之后进行，否则会造成视觉树断裂
            //Page.Dispatcher.BeginInvoke(new Action(() =>
            //{
            //    string resultKey = busData.ContainsKey("SuperFlag") ? "SuperFlag" : "AuthFlag";
            //    bool resultflag = false;
            //    if (!string.IsNullOrWhiteSpace(busData[resultKey]))
            //    {
            //        resultflag = bool.Parse(busData[resultKey]);
            //    }
            //    // 没有找到page，说明已经关闭过前端软件
            //    if (page == null)
            //    {
            //        // target.ShowErrorMessageBox("此任务的交易已丢失！");
            //        // 如果target是消息推送过来的，用target.ShowErrorMessageBox会报错，暂时用这个代替
            //        this.ShowInfoMessageBox("此任务的交易已丢失,请重新做该交易");
            //        //MessageBox.Show("此任务的交易已丢失,请重新做该交易", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
            //        string deletereason = "";
            //        if ("SuperFlag".Equals(resultKey))
            //        {
            //            deletereason = "SuperFaild";
            //        }
            //        else if ("AuthFlag".Equals(resultKey))
            //        {
            //            deletereason = "AuthFaild";
            //        }
            //        else
            //        {
            //            deletereason = "TellerDelete";
            //        }
            //        // 如果失败，不管是找没找到能还原的界面，因为工作流配置为不非环形流程，都需要删除流程，tradepage的流水号serialid也不用更新，
            //        // 如果还原了界面，客户还可以使用原来的流水号再提交申请，这个由服务端做了处理。
            //        WorkFlowHandle.deleteProcessInsById(busData["ProcessId"], deletereason); // TellerDelete只是做为删除流程实例原因的描述
            //    }
            //    else
            //    {
            //        //TabItem item = page.GetCurrentTabItem();
            //        page.GetTradeInfoData().SetTradeBus(busData);// .SetTradeData(data);
            //        var item = AuthManager.GetAuthManager(page as DependencyObject);
            //        //CheckManager c = item as CheckManager;
            //        AuthManager a = item as AuthManager;
            //        AsksuperResultType t = AsksuperResultType.Failed;
            //        if (resultflag)
            //        {
            //            if (busData.ContainsKey("WorkItemId"))
            //            {
            //                WorkFlowHandle.CompleteTaskById(busData["WorkItemId"]); //提交任务
            //            }
            //            t = AsksuperResultType.Success;
            //        }
            //        else
            //        {
            //            string deletereason = string.Empty;
            //            string processid = string.Empty;
            //            if ("SuperFlag".Equals(resultKey))
            //            {
            //                CheckDataHelper checkdata = new CheckDataHelper(page);
            //                deletereason = "SuperFaild";
            //                processid = checkdata.ProcessId;
            //                checkdata.ClearCheckData();
            //            }
            //            else if ("AuthFlag".Equals(resultKey))
            //            {
            //                deletereason = "AuthFaild";
            //                AuthDataHelper authdata = new AuthDataHelper(page);
            //                processid = authdata.ProcessId;
            //                authdata.ClearAuthData();
            //            }
            //            /* 如果失败，不管是找没找到能还原的界面，因为工作流配置为不非环形流程，都需要删除流程，tradepage的流水号serialid也不用更新，
            //             如果还原了界面，客户还可以使用原来的流水号再提交申请，这个由服务端做了处理。
            //            TellerDelete只是做为删除流程实例原因的描述  */
            //            WorkFlowHandle.deleteProcessInsById(processid, deletereason);
            //            t = AsksuperResultType.Failed;
            //        }

            //        //if (c != null)
            //        //    c.Result(t, busData);
            //        //else
            //            if (a != null)
            //            a.Result(t, busData);
            //    }
            //}), System.Windows.Threading.DispatcherPriority.Loaded, null);
        }

        /// <summary>
        /// 获取授权信息
        /// 根据传入的借方、贷方账户调用短交易查询账户属性等授权信息
        /// 函数会将授权信息写入 msg.FD125
        /// </summary>
        /// <param name="ipage">this</param>
        /// <param name="oepnBranch">开户行</param>
        /// <param name="DeAccount">借方账号 %-24s</param>
        /// <param name="CrAccount">贷方账号 %-24s</param>
        /// <param name="SinAmt">单笔金额 %-17.2f</param>
        /// <param name="CTSigns">1-现金 2-转账</param>
        /// <returns>
        ///  Result 类型对象, Result.Code 等同于交易返回码Fd12
        ///   Result.Desc 等同于交易返回码描述
        /// </returns>
        public AuthConditionElement GetAuthElement(out string oepnBranch, string DeAccount = "", string CrAccount = "", string SinAmt = "", string CTSigns = "", string OperationType = "", string DeAccountSeqn = "")
        {
            oepnBranch = "";
            AuthConditionElement result = null;
            Message message = new Message();
            InitFd(message);
            CommSend(message);
            message.Fd16 = "8980";
            message.Fd30 = DeAccount;
            message.Fd31 = CrAccount;
            message.Fd100_1 = SinAmt;
            message.Fd34 = DeAccountSeqn;
            CallServer(message);
            if (message.Fd12 != "0000")
            {
                this.ShowErrorMessageBox(Page.GetError(message));
                return null;
            }
            else
            {
                result = new AuthConditionElement();
                //操作类型
                result.OperationType = string.IsNullOrEmpty(OperationType) ? "" : OperationType.Trim();
                //要素详情：
                //1、	Txcode:交易代码  前端的交易码
                //类型：字符类型
                //值 ：交易号，如：2301
                result.Txcode = TradeInfoData.GetTradeInfo(Page).TradeCode;
                //2、  CTSigns:转账/现金标志
                //类型：数字类型
                //值 ：1：转账；2：现金
                result.CTSigns = string.IsNullOrEmpty(CTSigns) ? "" : CTSigns.Trim();
                //10、  SinAmt:单笔金额
                //类型：数字类型
                //值 ：金额，如：100000.00
                result.SinAmt = string.IsNullOrEmpty(SinAmt) ? "" : SinAmt.Trim();
                var fd125 = Feild8583.SetAuthFd125(message.Fd125);
                fd125.CTSigns = CTSigns;
                fd125.SinAmt = SinAmt;
                oepnBranch = string.IsNullOrEmpty(DeAccount) ? Feild8583.GetStrBytes(message.Fd125, 181, 5) : Feild8583.GetStrBytes(message.Fd125, 176, 5);
                //3、  DeAccountType:借方账户类型（对公、对私、内部）
                //类型：数字类型
                //值 ：1：对公；2：对私；3：内部
                result.DeAccountType = fd125.DeAccountType.Trim();
                //4、  CrAccountType:贷方账户类型（对公、对私、内部）
                //类型：数字类型
                //值 ：1：对公；2：对私；3：内部
                result.CrAccountType = fd125.CrAccountType.Trim();
                //5、  DeAccountPro:借方账户属性（基本户、一般户、专用户、临时户）
                //类型：数字类型
                //值 ：1：基本户；2：一般户；3：专用户；4：临时户;5;验资户
                result.DeAccountPro = fd125.DeAccountPro.Trim();
                //6、  CrAccountPro:贷方账户属性（基本户、一般户、专用户、临时户）
                //类型：数字类型
                //值 ：1：基本户；2：一般户；3：专用户；4：临时户；5;验资户
                result.CrAccountPro = fd125.CrAccountPro.Trim();
                //7、  DeIsOwn:借方是否是本行账号
                //类型：布尔类型
                //值 ：true：是；false：否
                if (fd125.DeIsOwn == "Y")
                {
                    result.DeIsOwn = "true";
                }
                else
                {
                    result.DeIsOwn = "false";
                }

                //8、  CrIsOwn:贷方是否是本行账号
                //类型：布尔类型
                //值 ：true：是；false：否
                if (fd125.CrIsOwn == "Y")
                {
                    result.CrIsOwn = "true";
                }
                else
                {
                    result.CrIsOwn = "false";
                }

                //9、  DCIsSameCus:借记方和贷记方是否是同一客户
                //类型：布尔类型
                //值 ：true：是；false：否
                if (fd125.DCIsSameCus == "Y")
                {
                    result.DCIsSameCus = "true";
                }
                else
                {
                    result.DCIsSameCus = "false";
                }

                //11、DeCaAddAmt:当日借方现金累计金额
                //类型：数字类型
                //值 ：金额，如：100000.00

                result.DeCaAddAmt = fd125.DeCaAddAmt.Trim();
                //12、DeTrAddAmt:当日借方转账累计金额
                //类型：数字类型
                //值 ：金额，如：100000.00

                //result.DeTrAddAmt = fd125.DeTrAddAmt.Trim();
                if (string.IsNullOrWhiteSpace(SinAmt.Trim())) SinAmt = "0.0";
                //if (CTSigns == "1") //现金
                //{
                //11、DeCaAddAmt:当日借方现金累计金额
                //类型：数字类型
                //值 ：金额，如：100000.00
                result.DeCaAddAmt = (double.Parse(fd125.DeCaAddAmt.Trim()) + double.Parse(SinAmt)).ToString();
                //13、CrTrAddAmt:当日贷方现金累计金额（启用为现金累计）
                //类型：数字类型
                //值 ：金额，如：100000.00
                result.CrTrAddAmt = (double.Parse(fd125.CrTrAddAmt.Trim()) + double.Parse(SinAmt)).ToString();
                //}
                //else if (CTSigns == "2")//转账
                //{
                //12、DeTrAddAmt:当日借方转账累计金额
                //类型：数字类型
                //值 ：金额，如：100000.00
                result.DeTrAddAmt = (double.Parse(fd125.DeTrAddAmt.Trim()) + double.Parse(SinAmt)).ToString();
                //当日借方金额总数
                result.SumAddAmt = (double.Parse(fd125.DeTrAddAmt.Trim()) + double.Parse(SinAmt) +
                                    double.Parse(fd125.DeCaAddAmt.Trim())).ToString();
                //}
                if (fd125.LossMarked == "Y")
                {
                    result.LossMarked = "true";
                }
                else if (fd125.LossMarked == "N")
                {
                    result.LossMarked = "false";
                }

                // 14、DocumentType：凭证种类
                // 类型：字符类型
                result.DocumentType = fd125.DocumentType.Trim();
                // 15、DeductMarked：扣划标志
                // 类型：字符类型
                result.DeductMarked = fd125.DeductMarked.Trim();
                //16、LongOrShort：长短款标志
                //类型：布尔类型
                //值 ：true：是；false：否
                if (fd125.LongOrShort == "Y")
                {
                    result.LongOrShort = "true";
                }
                else if (fd125.LongOrShort == "N")
                {
                    result.LongOrShort = "false";
                }
                result.LegalPerson = LoginAuthentication.Instance.GroupKinbrNo;
            }

            return result;
        }

        /// <summary>
        /// 调用核心短交易查询复核时需要的条件信息
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public CheckConditionElements GetCheckElement(Entry.RecheckEntry.PreviewRecheckEventArgs args)
        {
            var SinAmt = args.SinAmt.ToString();
            CheckConditionElements result = null;
            Message message = new Message();
            InitFd(message);
            CommSend(message);
            message.Fd16 = "8980";
            message.Fd30 = args.DeAccount;
            message.Fd31 = args.CrAccount;
            message.Fd100_1 = SinAmt;
            message.Fd34 = args.DeAccountSeqn;
            CallServer(message);
            if (message.Fd12 != "0000")
            {
                this.ShowErrorMessageBox(Page.GetError(message));
                return null;
            }
            else
            {
                result = new CheckConditionElements() { Account = args.Account, Money = args.Amt };
                //操作类型
                result.OperationType = string.IsNullOrEmpty(args.OperationType) ? "" : args.OperationType.Trim();
                //要素详情：
                //1、	Txcode:交易代码  前端的交易码
                //类型：字符类型
                //值 ：交易号，如：2301
                result.Txcode = TradeInfoData.GetTradeInfo(Page).TradeCode;
                //2、  CTSigns:转账/现金标志
                //类型：数字类型
                //值 ：1：转账；2：现金
                result.CTSigns = string.IsNullOrEmpty(args.CTSigns) ? "" : args.CTSigns.Trim();
                //10、  SinAmt:单笔金额
                //类型：数字类型
                //值 ：金额，如：100000.00
                if (string.IsNullOrEmpty(args.Amt.ToString()) || args.Amt == 0)
                {
                    result.SinAmt = string.IsNullOrEmpty(SinAmt) ? "" : SinAmt;
                }
                var fd125 = Feild8583.SetAuthFd125(message.Fd125);
                fd125.CTSigns = args.CTSigns;
                fd125.SinAmt = SinAmt;
                //3、  DeAccountType:借方账户类型（对公、对私、内部）
                //类型：数字类型
                //值 ：1：对公；2：对私；3：内部
                result.DeAccountType = fd125.DeAccountType.Trim();
                //4、  CrAccountType:贷方账户类型（对公、对私、内部）
                //类型：数字类型
                //值 ：1：对公；2：对私；3：内部
                result.CrAccountType = fd125.CrAccountType.Trim();
                //5、  DeAccountPro:借方账户属性（基本户、一般户、专用户、临时户）
                //类型：数字类型
                //值 ：1：基本户；2：一般户；3：专用户；4：临时户;5;验资户
                result.DeAccountPro = fd125.DeAccountPro.Trim();
                //6、  CrAccountPro:贷方账户属性（基本户、一般户、专用户、临时户）
                //类型：数字类型
                //值 ：1：基本户；2：一般户；3：专用户；4：临时户；5;验资户
                result.CrAccountPro = fd125.CrAccountPro.Trim();
                //7、  DeIsOwn:借方是否是本行账号
                //类型：布尔类型
                //值 ：true：是；false：否
                if (fd125.DeIsOwn == "Y")
                {
                    result.DeIsOwn = "true";
                }
                else
                {
                    result.DeIsOwn = "false";
                }

                //8、  CrIsOwn:贷方是否是本行账号
                //类型：布尔类型
                //值 ：true：是；false：否
                if (fd125.CrIsOwn == "Y")
                {
                    result.CrIsOwn = "true";
                }
                else
                {
                    result.CrIsOwn = "false";
                }

                //9、  DCIsSameCus:借记方和贷记方是否是同一客户
                //类型：布尔类型
                //值 ：true：是；false：否
                if (fd125.DCIsSameCus == "Y")
                {
                    result.DCIsSameCus = "true";
                }
                else
                {
                    result.DCIsSameCus = "false";
                }

                //11、DeCaAddAmt:当日借方现金累计金额
                //类型：数字类型
                //值 ：金额，如：100000.00

                result.DeCaAddAmt = fd125.DeCaAddAmt.Trim();
                //12、DeTrAddAmt:当日借方转账累计金额
                //类型：数字类型
                //值 ：金额，如：100000.00

                //result.DeTrAddAmt = fd125.DeTrAddAmt.Trim();
                if (string.IsNullOrWhiteSpace(SinAmt.Trim())) SinAmt = "0.0";
                //if (CTSigns == "1") //现金
                //{
                //11、DeCaAddAmt:当日借方现金累计金额
                //类型：数字类型
                //值 ：金额，如：100000.00
                result.DeCaAddAmt = (double.Parse(fd125.DeCaAddAmt.Trim()) + double.Parse(SinAmt)).ToString();
                //13、CrTrAddAmt:当日贷方现金累计金额（启用为现金累计）
                //类型：数字类型
                //值 ：金额，如：100000.00
                result.CrTrAddAmt = (double.Parse(fd125.CrTrAddAmt.Trim()) + double.Parse(SinAmt)).ToString();
                //}
                //else if (CTSigns == "2")//转账
                //{
                //12、DeTrAddAmt:当日借方转账累计金额
                //类型：数字类型
                //值 ：金额，如：100000.00
                result.DeTrAddAmt = (double.Parse(fd125.DeTrAddAmt.Trim()) + double.Parse(SinAmt)).ToString();
                //当日借方金额总数
                result.SumAddAmt = (double.Parse(fd125.DeTrAddAmt.Trim()) + double.Parse(SinAmt) +
                                    double.Parse(fd125.DeCaAddAmt.Trim())).ToString();
                //}
                if (fd125.LossMarked == "Y")
                {
                    result.LossMarked = "true";
                }
                else if (fd125.LossMarked == "N")
                {
                    result.LossMarked = "false";
                }

                // 14、DocumentType：凭证种类
                // 类型：字符类型
                result.DocumentType = fd125.DocumentType.Trim();
                // 15、DeductMarked：扣划标志
                // 类型：字符类型
                result.DeductMarked = fd125.DeductMarked.Trim();
                //16、LongOrShort：长短款标志
                //类型：布尔类型
                //值 ：true：是；false：否
                if (fd125.LongOrShort == "Y")
                {
                    result.LongOrShort = "true";
                }
                else if (fd125.LongOrShort == "N")
                {
                    result.LongOrShort = "false";
                }
                result.LegalPerson = LoginAuthentication.Instance.GroupKinbrNo;
            }

            return result;
        }


        /// <summary>
        /// 设置复核相字符串显示
        /// </summary>
        /// <param name="element">元素</param>
        /// <param name="flag">flag：true成功 false:失败</param>
        public void SetAuthCheckTitle(FrameworkElement element, string str)
        {
            TellerSystem.Contract.Function.CheckManager.SetAuthCheckTitle((DependencyObject)element, str);
        }
        #endregion

        #region 获取菜单属性
        /// <summary>
        /// 获取交易菜单附属属性
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public string GetTradeMetadata(string name)
        {
            var model = this.Page.TradeModel;
            if (model == null || !model.Metadata.ContainsKey(name)) return string.Empty;
            return model.Metadata[name];
        }

        /// <summary>
        /// 检查交易是否拥有制定的权限编号
        /// </summary>
        /// <param name="powerCode"></param>
        /// <returns></returns>
        public bool CheckTradePower(string powerCode)
        {
            if (!TradePowerManager.Instance.IsPowerCheckByUser)
                return true;
            var list = TradePowerManager.Instance.GetTradePowerByCode(Page.TradeInfo.TradeCode);
            if (list == null || list.Count == 0) return false;
            return list.Any(x => x.RuleNo == powerCode);
        }

        private static List<string> _SignInStateList_ = new List<string>
        {
            "TellerTransfer",
            "TellerChecking",
            "TellerChecked",
            "TellerSignOut",
        };

        /// <summary>
        /// 检查柜员工作状态，当前是否签到情况
        /// </summary>
        /// <returns></returns>
        public bool CheckWorkState(bool? defV = null)
        {
            string FLAG = TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("2ea3a7e6cfa04f89a335bf1e363295de");
            if (FLAG == "V24")
            {
                //若给定了默认值，则需要检查当前交易菜单配置
                if (defV.HasValue)
                {
                    var flag = false;
                    if (!bool.TryParse(GetTradeMetadata("isCheckWorkState"), out flag))
                        flag = defV.Value;
                    if (!flag) return true;
                }
                string TSGY = TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("TSGY");
                if (TSGY.Contains(LoginUserInfo.TellerNo))
                {
                    return true;
                }
                var status = LoginUserInfo.GetUserInfo("WorkState");
                if (_SignInStateList_.Contains(status)) return true;
                this.ShowWarnMessageBox("当前柜员非签到状态，请先签到...");
                return false;
            }
            else
            {
                return true;
            }
        }

        /// <summary>
        /// 检查代发交易状态
        /// </summary>
        /// <returns></returns>
        public bool CheckDFState(bool? defV = null)
        {
            string FLAG = TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("2ea3a7e6cfa04f89a335bf1e363295de");
            if (FLAG == "V0" && !(TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("TGJC") == "true"))
            {
                //若给定了默认值，则需要检查当前交易菜单配置
                if (defV.HasValue)
                {
                    var flag = false;
                    if (!bool.TryParse(GetTradeMetadata("isCheckDFState"), out flag))
                        flag = defV.Value;
                    if (!flag) return true;
                }
                Message msg = new Message();
                this.InitFd(msg);
                this.CommSend(msg);
                msg.Fd16 = "K119";
                msg.Fd92 = LoginUserInfo.TellerNo;
                this.CallServer(msg);
                if (msg.Fd12 != "0000")
                {
                    this.ShowErrorMessageBox(this.GetError(msg));
                    this.SetFocus();
                    return false;
                }
                if (msg.Fd67 == "1")
                {
                    this.ShowWarnMessageBox("当前柜员存在代发交易未完成！");
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                return true;
            }
        }
        #endregion

        #region 控件相关
        /// <summary>
        /// 检查磁道信息是否来源于设备
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="textbox"></param>
        /// <returns></returns>
        public bool CheckMsrDataByDevice(TextBox textbox)
        {
            if (ExamSystem.Instance.InExamMode) return true;
            var retIC = DeviceManager.GetICCardData(textbox);
            bool isICforDevice = false;
            bool IsMsrByDevice = false;
            if (retIC != null)
            {
                isICforDevice = CheckICDevice(retIC.Data);
            }

            var ret = DeviceManager.GetSwipeCardData(textbox);
            if (ret != null)
            {
                IsMsrByDevice = CheckMsrDataByDevice(ret.Data);
            }
            return isICforDevice || IsMsrByDevice;

        }

        /// <summary>
        /// 检查磁道信息是否来源于设备
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool CheckMsrDataByDevice(SwipeCardReaderEntity entity)
        {
            if (ExamSystem.Instance.InExamMode) return true;
            if (entity == null) return false;
            //二磁道信息存在即表示数据来自设备
            return !string.IsNullOrWhiteSpace(entity.TracksTwo);
        }
        /// <summary>
        /// 检查IC卡信息是否来源于设备
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool CheckICDevice(ICCardEntity entity)
        {
            if (ExamSystem.Instance.InExamMode) return true;
            if (entity == null) return false;
            //二磁道信息存在即表示数据来自设备
            return !string.IsNullOrWhiteSpace(entity.TracksTwo);
        }
        /// <summary>
        /// 检查磁道信息是否来源于设备
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="textbox"></param>
        /// <returns></returns>
        public bool CheckICDevice(TextBox textbox)
        {
            if (ExamSystem.Instance.InExamMode) return true;
            var ret = DeviceManager.GetICCardData(textbox);
            if (ret == null) return false;
            return CheckICDevice(ret.Data);
        }
        #endregion

        #region 冠字号管理
        /// <summary>
        /// 触发现金冠字号管理流程
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="userName"></param>
        /// <param name="biz"></param>
        /// <returns></returns>
        public bool RaiseCashCode(string cardNo, string userName, TellerSystem.Contract.Entry.CashCodeEntry.BizType biz)
        {
            return Page.CashCode.LoadData(Page, new Message()) && Page.CashCode.Preview(cardNo, userName, biz);
        }
        #endregion

        #region 打印流程化
        /// <summary>
        /// 触发打印流程化
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public bool RaisePrintflow(PrintflowEntry flow)
        {
            //raise主流程
            return flow.RaisePrintflow();
        }

        /// <summary>
        /// 触发打印流程化
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool RaisePrintflow<T>(Message message)
            where T : PrintflowEntry, new()
        {
            var flow = new T();
            flow.LoadData(Page, message);
            return RaisePrintflow(flow);
        }

        /// <summary>
        /// 触发无纸化操作
        /// </summary>
        /// <param name="message"></param>
        /// <param name="dict"></param>
        /// <returns></returns>
        public bool RaisePaperless(Message message, Dictionary<string, string> dict = null)
        {
            if (message == null)
                throw new ArgumentNullException("message");
            //装载无纸化对象
            if (!this.Page.Paperless.LoadData(this.Page, message))
                return false;
            //触发无纸化
            return this.Page.Paperless.DocPicker(dict) != false;
        }

        internal Dictionary<string, string> Notify2CustomerMatch(string match = null)
        {
            //执行解析
            var sp = new char[] { '|', '&' };
            var keymap = new Dictionary<Tuple<string, int, bool, string, string[]>, string>();//Tuple:<key,index,true=ui|false=bus,ui=title(定位)|bus=val,args[]>
            if (string.IsNullOrEmpty(match) || match.StartsWith("+"))//合成抓取规则
            {
                //提取基础规则
                var def = "账／卡号|户    名|交易金额|证件号码|证件类型|证件种类|账号|扣划账号|扣划金额|内部账号|记账账号|付款人账号|姓名|证件号码|收款人账号|附言|金额大写|手续费|联系地址|职业|币种|账/卡号|产品名称|凭证种类|支取标志|加息摘要|接收行名称|优先级别|汇款类型|到账方式|收取方式|原委托日期|原交易序号|原发起行行号|退汇原因|原报文类型|原委托日期|变更方式|支取方式|限制原因|芯片余额|圈存类型|IC 卡 号|转出账户|圈存金额|圈提金额|账户户名|绑定卡类型|绑定卡号|手机号|账号户名|升降级|客户姓名|操作类型|账    号|处理类型|处理方式|解除金额|签约账号|手机号码|扣费账号|收费金额|摘    要|开户金额|存期类型|产品代码|执行利率|收款人名称|付款人名称|交易  金额|接收行行名|更换方式";
                match = def + "|" + ServiceSettings.GetConfig("Device.UnifiedNotify.Match", "") + "|" + (match ?? "+").TrimStart('+');
            }
            match.Split(sp).ToList().ForEach(x =>
            {
                //移除项,排重
                var item = keymap.LastOrDefault(o => o.Key.Item1 == x.TrimStart('!'));
                if (item.Key != null)
                    keymap.Remove(item.Key);
                //仅移除
                if (x.StartsWith("!")) return;
                var key = x;
                var ind = -1;
                var ui = true;
                var val = key;
                var tmp = x.Split('@');
                if (tmp.Length > 1)
                {
                    key = val = tmp[0];
                    var up = 0;
                    if (int.TryParse(tmp[1], out up))
                        ind = up;
                    if (tmp.Length > 2)//非页面提取方式
                    {
                        if (!string.IsNullOrEmpty(tmp[2]))
                        {
                            val = tmp[2];
                            var bus = Page.TradeBus[tmp[2]];
                            if (!string.IsNullOrWhiteSpace(bus))//从总线提取
                            {
                                val = bus;
                                ui = false;
                            }
                        }

                    }
                }
                //新增项
                keymap[new Tuple<string, int, bool, string, string[]>(key, ind, ui, val, tmp)] = ui ? string.Empty : val;
            });
            //提取要素
            Page.PositioningUIText(keymap.Keys.Where(x => x.Item3).Select(x => x.Item4).Distinct().ToList()).ToList().ForEach(x =>
            {
                keymap.Keys.Where(o => o.Item3 && o.Item4 == x.Key).ToList().ForEach(k =>
                {
                    var val = x.Value.Last().Value;//默认取最后的值
                    if (k.Item5.Length > 3)//额外匹配处理
                    {
                        var picker = k.Item5[3];
                        val = string.Empty;//置空，防干扰
                        var i = -1;
                        if (int.TryParse(picker, out i))//规则为数字，则按照索引定位
                        {
                            if (i >= 0 && i < x.Value.Count)
                                val = x.Value.ElementAt(i).Value;
                        }
                        else
                        {
                            var header = picker;//按照所属TradePanel的Header定位
                            foreach (var item in x.Value)
                            {
                                var tp = item.Key.FindVisualTreeAncestor(d => d.GetType().FullName == "TellerSystem.Controls.Ext.ControlsExt.TradePanel");//查找TradePanel类型的父元素
                                if (tp != null && ((dynamic)tp).Header == header)//对比Header
                                {
                                    val = item.Value;
                                    break;
                                }
                            }
                        }
                    }
                    keymap[k] = val;
                });
            });
            //进行排序
            var list = keymap.Where(x => !string.IsNullOrEmpty(x.Value)).ToList();
            list.Where(x => x.Key.Item2 >= 0).ToList().ForEach(x =>
            {
                var item = list.FirstOrDefault(y => y.Key == x.Key);
                if (item.Key == null) return;
                list.Remove(item);//先移除
                //检查索引登记，进行排序定位
                var i = (x.Key.Item2 < 0 || x.Key.Item2 > list.Count) ? list.Count : x.Key.Item2;
                list.Insert(i, item);
            });
            return list.ToDictionary(x => x.Key.Item1, x => x.Value);
        }

        /// <summary>
        /// 通知客户交易信息
        /// </summary>
        /// <param name="dict"></param>
        /// <param name="title"></param>
        /// <param name="callback"></param>
        /// <param name="match"></param>
        /// <param name="force"></param>
        /// <returns></returns>
        public bool? Notify2Customer(Dictionary<string, string> dict = null, string title = null, Action<bool?, string> callback = null, string match = null, bool force = false)
        {
            if (!force && GetTradeMetadata("isNotify").ToLower() != "true") return null;
            //若未传入信息，则按照统一规则抓取
            if (dict == null || dict.Count == 0)
                dict = Notify2CustomerMatch(match);
            var list = dict.Where(x => !string.IsNullOrWhiteSpace(x.Value)).ToList();
            if (list.Count == 0) return null;
            //组织通知字段
            var sb = new StringBuilder();
            if (title != string.Empty)
                list.Insert(0, new KeyValuePair<string, string>("交易名称", title ?? Page.TradeModel.Name));
            //检测协议通知情况
            var protocol = Page.TradeBus["NotifyProtocolList"];
            if (!string.IsNullOrEmpty(protocol))
                list.Add(new KeyValuePair<string, string>("确认已阅读协议", protocol));
            list.ForEach(item => sb.AppendLine(item.Key + ":" + item.Value));
            dict = list.ToDictionary(x => x.Key, x => x.Value);//转换格式，用于存储json
            var flag = false;
            var msg = "客户取消操作！";
            var action = new Action(() =>
            {
                var ret = TellerSystem.Devices.DeviceHelper.PrintTransInfo(sb.ToString(), false);
                flag = !ret.HasError && ret.Data;
                if (ret.HasError)
                    msg = ret.ErrorInfo;
                Page.Dispatcher.Invoke(new Action<object>(d =>
                {
                    flag = flag && TraderecordsExp("Notify2Customer", JsonConvert.SerializeObject(d), "");
                    if (callback != null)
                        callback(flag, msg);//UI线程执行
                }), dict);
            });
            if (callback != null)//异步执行确认操作
            {
                action.BeginInvoke(null, null);
                return true;
            }
            Page.OwnerContainer.ModalInvoke(action, "客户使用柜外清确认关键信息，请稍候...");
            //操作失败，需要提醒柜员
            if (!flag) Page.TradeAPIs.ShowErrorMessageBox("柜外清确认操作失败=>" + msg);
            return flag;
        }

        /// <summary>
        /// 获取指定流水的客户通知确认要素
        /// </summary>
        /// <param name="serialId"></param>
        /// <returns></returns>
        public Dictionary<string, string> GetNotify2Customer(string serialId)
        {
            var rows = UserManagerHandle.ExecuteQuery(string.Format("SELECT PARAMVALUE FROM TWFT_TRADERECORDS_PROP_EXP WHERE SERIALID ='{0}' AND PARAMNAME ='{1}'"
                , serialId, "Notify2Customer"));
            if (rows.Length == 0 || string.IsNullOrEmpty(rows[0])) return null;
            return (Dictionary<string, string>)JsonConvert.DeserializeObject(rows[0], typeof(Dictionary<string, string>));
        }

        /// <summary>
        /// 柜面流水表扩展属性
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="remark"></param>
        /// <param name="unique"></param>
        /// <returns></returns>
        public bool TraderecordsExp(string name, string value, string remark = "", bool unique = true)
        {
            var id = Page.CreateSerialNumber();
            var sqls = new ArrayList();
            if (unique)
                sqls.Add(string.Format("DELETE FROM TWFT_TRADERECORDS_PROP_EXP WHERE SERIALID='{0}' AND PARAMNAME='{1}'", id, name));
            sqls.Add(string.Format("INSERT INTO TWFT_TRADERECORDS_PROP_EXP(SERIALID, PARAMNAME, PARAMVALUE, REMARKS) VALUES('{0}', '{1}', '{2}', '{3}')", id, name, value, remark));
            return UserManagerHandle.ExecuteSQLTran(sqls);
        }

        /// <summary>
        /// 柜外清推送协议清单，供客户阅览。默认无需确认
        /// </summary>
        /// <param name="protocolList"></param>
        /// <param name="callback"></param>
        /// <param name="mustConfirm"></param>
        /// <returns></returns>
        public bool NotifyProtocolList(List<string> protocolList, Action<Dictionary<FileInfo, bool>> callback = null, bool mustConfirm = false)
        {
            //清空缓存
            Page.TradeBus["NotifyProtocolList"] = string.Empty;
            Page.TradeBus["NotifyProtocolList2Confirm"] = string.Empty;
            //参数检查:全局开关、设备启用
            if (!ServiceSettings.GetConfig("Device.NotifyProtocolList", false)
                || !Devices.Config.DeviceConfig.TransInfoEnabled) return false;
            //协议确认过程
            var func = new Func<List<string>, Dictionary<FileInfo, bool>>(list =>
            {
                var dict = new Dictionary<FileInfo, bool>();
                //获取有效的协议清单文件
                var plist = list.Distinct().Select(x => new FileInfo(RES.GetUri("/Protocol/" + x).LocalPath)).Where(x => x.Exists).ToList();
                Page.TradeBus["NotifyProtocolList"] = string.Join("、", plist.Select(x => string.Format("《{0}》", Path.GetFileNameWithoutExtension(x.Name))));//登记协议清单
                foreach (var p in plist)
                {
                    //进行柜外清推送
                    var ret = Devices.DeviceHelper.PrintTransInfo(p.FullName, false, mustConfirm);
                    dict[p] = !ret.HasError && ret.Data;
                }
                Page.TradeBus["NotifyProtocolList2Confirm"] = string.Join("、", dict.Where(x => x.Value).Select(x => string.Format("《{0}》", Path.GetFileNameWithoutExtension(x.Key.Name))));//登记确认的协议
                return dict;
            });
            ////判定异步模式
            //if (async)
            //{
            //    func.BeginInvoke(protocolList, x =>
            //    {
            //        try
            //        {
            //            var dict = func.EndInvoke(x);
            //            if (callback != null)
            //                Page.Dispatcher.Invoke(callback, dict);
            //        }
            //        catch (Exception ex)
            //        {
            //            PlatformLogger.SystemErrorInfo("TradeAPIsHelper.NotifyProtocolList:执行发生异常！", ex);
            //        }
            //    }, null);
            //}
            //else
            {
                Dictionary<FileInfo, bool> dict = null;
                Page.OwnerContainer.ModalInvoke(() =>
                {
                    dict = func.Invoke(protocolList);
                }, "客户正在确认协议文件，请稍候...");
                //触发回调
                if (callback != null)
                    callback(dict);
            }
            return true;
        }

        #region PrintLimit
        /// <summary>
        /// 打印限制规则
        /// </summary>
        private static List<PrintDataLimit> _printLimitRules;

        /// <summary>
        /// 执行打印配置筛选
        /// </summary>
        /// <param name="code">交易码</param>
        /// <param name="list">打印清单</param>
        /// <returns></returns>
        internal List<PrintContainer> DoPrintLimit(string code, IEnumerable<PrintContainer> list)
        {
            if (_printLimitRules == null)
                _printLimitRules = PrintManagerHandle.GetPrintLimit().ToList();
            return list.Where(x =>
            {
                //查找相关的配置项，id一致且存在交易号时，需要进行比对
                var tmp = _printLimitRules.Where(y =>
                    y.Formid == x.DocumentId && (string.IsNullOrEmpty(y.Tradeno) || y.Tradeno == code));
                //若未配置表单，默认允许打印
                if (tmp.Count() == 0) return true;
                var item = tmp.ElementAt(0);
                //表单未配置打印策略，允许打印
                if (string.IsNullOrEmpty(item.Printflag)) return true;
                //Printflag:第一位[0-不打印  1-打印]
                return item.Printflag[0] == '1';
            }).ToList(); ;
        }
        #endregion
        #endregion

        #region 手机银行3.0接口直连

        /// <summary>
        /// 手机银行3.0接口直连
        /// </summary>
        /// <param name="url"></param>
        /// <param name="dict"></param>
        /// <param name="method"></param>
        /// <returns>"000000".Equals(ret["errCode"])判断调用结果</returns>
        public Dictionary<string, object> CallMobileBank3(string txCode, Dictionary<string, Object> dict, string method = "post")
        {
            Dictionary<string, object> ret = new Dictionary<string, object>
            {
                {"errCode", "COMM"},
                {"errMsg", "通讯调用异常！"},
                {"outMsgNo", ""},
            };
            //兼容转换,支持老版本url写法
            var flag = txCode.StartsWith("/");
            if (flag)
            {
                switch (txCode)
                {
                    case "/teller/querysigninfo"://手机银行签约查询
                        txCode = "970001";
                        break;
                    case "/teller/signmobilebank"://手机银行签约
                        txCode = "970002";
                        break;
                    case "/teller/querydefaultlimit"://查询默认限额
                        txCode = "970003";
                        break;
                    case "/teller/opentransandpay"://开通支付转账
                        txCode = "970004";
                        break;
                    case "/teller/unsignmobilebank"://手机银行解约
                        txCode = "970005";
                        break;
                    case "/teller/closemobilebank"://手机银行注销
                        txCode = "970006";
                        break;
                    case "/teller/reSetPass"://手机银行个人客户密码重置
                        txCode = "970007";
                        break;
                    case "/teller/changePhone"://手机银行个人客户手机号修改
                        txCode = "970008";
                        break;
                    case "/com/getVerifyCode"://获取验证码
                        txCode = "000001";
                        break;
                    default:
                        throw new NotSupportedException("暂不支持的url=>" + txCode);
                }
            }
            //调用手机银行3.0直连接口
            var tuple = SystemFunction.CallMobileBank3(txCode, dict);
            ret["errCode"] = tuple.Item1 ? "000000" : "999999";
            ret["errMsg"] = tuple.Item2;
            ret["outMsgNo"] = tuple.Item2;
            if (tuple.Item1)
            {
                ret["bizContent"] = tuple.Item3;
                //兼容模式下，需要特殊处理
                if (flag)
                    ret["bizContent"] = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonHelper.ParseDictionary2Json(tuple.Item3));
            }
            return ret;
        }
        /// <summary>
        /// 手机银行3.0接口直连,cifName客户名称 certNo证件号 certType证件类型
        /// </summary>
        /// <param name="cifName">客户名称</param>
        /// <param name="certNo"> 证件号</param>
        /// <param name="certType">证件类型</param>
        /// <returns>"000000".Equals(ret["errCode"])判断调用结果</returns>
        public Dictionary<string, object> CallBank970001(string cifName, string certNo, string certType)
        {
            var Input970001 = new Dictionary<string, object>() { { "cifName", cifName }, { "certNo", certNo }, { "certType", certType == "1" ? "CT01" : certType } };
            var Output970001 = CallMobileBank3("/teller/querysigninfo", Input970001);
            if (Output970001["errCode"].ToString().Trim() != "000000")
            {
                this.ShowInfoMessageBox(Output970001["errMsg"].ToString().Trim());
                this.SetFocus();
                return null;
            }
            var OutInfo = Output970001["bizContent"] is Dictionary<string, object> ? Output970001["bizContent"] as Dictionary<string, object> : new Dictionary<string, object>();
            return OutInfo;
        }


        #endregion
        #region 手机银行2.0
        public Dictionary<string, object> CallMobileBank2(string txCode, Dictionary<string, Object> dict, string method = "post")
        {
            Dictionary<string, object> ret = new Dictionary<string, object>
            {
                {"errCode", "COMM"},
                {"errMsg", "通讯调用异常！"},
                {"outMsgNo", ""},
            };
            //调用手机银行3.0直连接口
            var tuple = SystemFunction.CallMobileBank2(txCode, dict);
            ret["errCode"] = tuple.Item1 ? "000000" : "999999";
            ret["errMsg"] = tuple.Item2;
            ret["outMsgNo"] = tuple.Item2;
            if (tuple.Item1)
            {
                ret["bizContent"] = tuple.Item3;
                //兼容模式下，需要特殊处理
            }
            return ret;
        }
        #endregion
        #endregion
    }
}
