private void ParseMetaData(SAPFunctionEx function)
        {
            //_funcMeta.Import.Count

            dgvImport.DataSource = function.FunctionMeta.Import;
            dgvExport.DataSource = function.FunctionMeta.Export;
            dgvChanging.DataSource = function.FunctionMeta.Changing;
            dgvTables.DataSource = function.FunctionMeta.Tables;
            //dgvException.DataSource = function.FunctionMeta.Exception;

            dgvImport.AutoResizeColumns();
            dgvExport.AutoResizeColumns();
            dgvChanging.AutoResizeColumns();
            dgvTables.AutoResizeColumns();
            tabPage2.BringToFront();
        }
        public void ParseMetaDataToExcel(SAPFunctionEx pFunction = null)
        {
            if (pFunction == null)
            {
                if (LoadFunctionMetaData() == false)
                {
                    MessageBox.Show("请先查找函数信息!!");
                    return;
                }

            }

            Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets.Add();
            ws = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet);

            try
            {
                ws.Name = _funcName;
            }
            catch (Exception)
            {

                // throw;
            }

            DataTable dtImport = m_function.FunctionMeta.Import;
            DataTable dtExport = m_function.FunctionMeta.Export;
            DataTable dtChange = m_function.FunctionMeta.Changing;
            DataTable dtTables = m_function.FunctionMeta.Tables;

            int rowsOffset = 0;
            int colsOffset = 0;

            rowsOffset = 4; //从第4行开始
            colsOffset = 2; //从第2行开始

            ParseParameterList(dtImport, "输入参数", rowsOffset, colsOffset);
            rowsOffset += dtImport.Rows.Count + 5;

            ParseParameterList(dtExport, "输出参数", rowsOffset, colsOffset);
            rowsOffset += dtExport.Rows.Count + 5;

            ParseParameterList(dtChange, "修改参数", rowsOffset, colsOffset);
            rowsOffset += dtChange.Rows.Count + 5;

            ParseParameterList(dtTables, "表参数", rowsOffset, colsOffset);
            rowsOffset += dtTables.Rows.Count + 5;

            if (true)
            {
                //从新的列开始存放结构或表定义
                //  rowsOffset = 6;//不能小于4
                //  colsOffset += 12;   //注意不要覆盖前面的列。
            }
            else
            {
                //在同一列开始存放结构的定义
                //  rowsOffset += dtTables.Rows.Count + 8;
                // colsOffset += 9;
            }
            rowsOffset += 5;
            colsOffset += 12;

            ParseStructToExcel(dtImport, ref rowsOffset, colsOffset);
            ParseStructToExcel(dtExport, ref rowsOffset, colsOffset);
            ParseStructToExcel(dtChange, ref rowsOffset, colsOffset);
            ParseStructToExcel(dtTables, ref rowsOffset, colsOffset);

            _parsedStructure.Clear();
            _parsedTable.Clear();
        }
        private void btnBatchInput_Click(object sender, EventArgs e)
        {
            if (dtBatchInput.Rows.Count > 0)
            {
                foreach (DataRow item in dtBatchInput.Rows)
                {
                    String systemName = item["systemName"].ToString().Trim();
                    String functionName = item["FunctionName"].ToString().Trim();
                    if (!String.IsNullOrWhiteSpace(systemName) && !String.IsNullOrWhiteSpace(functionName))
                    {
                        //function. = SAPFunctionMeta.GetRfcFuncMetaAsDataTable(systemName, functionName);
                        //LoadFunctionMetaData();
                        m_function = new SAPFunctionEx(systemName, functionName);
                        if (m_function.FunctionMeta == null)
                        {
                            MessageBox.Show("无法找到函数信息!!");
                            return;
                        }
                        //ParseMetaData(function);

                        this._funcName = functionName;
                        ParseMetaDataToExcel(m_function);
                    }
                }
            }
        }
        private bool LoadFunctionMetaData()
        {
            if (!check())
            {
                return false;
            }
            else
            {
                try
                {

                    //function.FunctionMeta = SAPFunctionMeta.GetRfcFuncMetaAsDataTable(_systemName, _funcName);

                    //if (function.FunctionMeta == null)
                    //{
                    //    MessageBox.Show("无法找到函数信息!!");
                    //}
                    //ParseMetaData();
                    m_function = new SAPFunctionEx(_systemName, _funcName);
                    if (m_function.FunctionMeta == null)
                    {
                        MessageBox.Show("无法找到函数信息!!");
                        return false;
                    }
                    ParseMetaData(m_function);
                    if (m_function.Is_rfc == true)
                    {
                        //this.button2.Enabled = true;
                        //this.button2.Text = "RFC函数,可执行";
                    }
                    else
                    {
                        // this.button2.Text = "非RFC函数,不可执行";
                        // this.button2.Enabled = false;
                    }

                    this.Text = "函数:" + _funcName;
                    return true;
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                    //throw;
                }

            }
            return true;
        }
        /// <summary>
        /// //从服务器加载函数的具体信息,包括每个参数的名称,数据类型
        /// 如果是结构体,还显示它的字段列表。
        /// </summary>
        private void LoadFunctionMetaData()
        {
            if (!check())
            {
                return;
            }
            else
            {
                try
                {
                    function = new SAPFunctionEx(_systemName, _funcName);
                    if (function.FunctionMeta == null)
                    {
                        MessageBox.Show("无法找到函数信息!!");
                        return;
                    }
                    ParseMetaData(function);
                    if (function.Is_rfc == true)
                    {
                        this.button2.Enabled = true;
                        this.button2.Text = "RFC函数,可执行";
                    }
                    else
                    {
                        this.button2.Text = "非RFC函数,不可执行";
                        this.button2.Enabled = false;
                    }

                    this.Text = "函数:" + _funcName;
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }
        }