Esempio n. 1
0
        /// <summary>
        /// 读取RFC函数的全部信息
        /// </summary>
        /// <param name="sysName"></param>
        /// <param name="funame"></param>
        /// <returns></returns>
        public static RfcFunctionMetaAsList GetFuncMetaAsList(string sysName, string funame)
        {
            funame = funame.ToUpper().Trim();
            RfcFunctionMetadata   MetaData = GetRfcFunctionMetadata(sysName, funame);
            RfcFunctionMetaAsList metaList = new RfcFunctionMetaAsList();

            // metaList.Import.Add(
            //根据参数的方向,分为四种(CHANGING,EXPORT,IMPORT,TABLES);
            for (int i = 0; i < MetaData.ParameterCount; i++)
            {
                RfcParameterMetadata pMetadata = MetaData[i];
                FunctionField        field     = null;
                String dataTypeName            = String.Empty;
                if (pMetadata.DataType == RfcDataType.STRUCTURE)
                {
                    RfcContainerMetadata <RfcFieldMetadata> meta = pMetadata.ValueMetadataAsStructureMetadata;
                    dataTypeName = meta.Name;
                }
                else if (pMetadata.DataType == RfcDataType.TABLE)
                {
                    RfcContainerMetadata <RfcFieldMetadata> meta = pMetadata.ValueMetadataAsTableMetadata;
                    RfcTableMetadata tablem = pMetadata.ValueMetadataAsTableMetadata;
                    dataTypeName = tablem.LineType.Name;
                }
                field = new FunctionField(pMetadata.Name, pMetadata.Direction.ToString(), pMetadata.DataType.ToString(), pMetadata.Decimals, pMetadata.DefaultValue, pMetadata.NucLength, pMetadata.Optional, pMetadata.Documentation, dataTypeName);
                switch (pMetadata.Direction)
                {
                //创建四个方向的参数列表
                case RfcDirection.CHANGING:
                    metaList.Changing.Add(pMetadata.Name, field);
                    break;

                case RfcDirection.EXPORT:
                    metaList.Export.Add(pMetadata.Name, field);
                    break;

                case RfcDirection.IMPORT:
                    metaList.Import.Add(pMetadata.Name, field);
                    break;

                case RfcDirection.TABLES:
                    metaList.Tables.Add(pMetadata.Name, field);
                    break;
                }
                if (pMetadata.DataType == RfcDataType.STRUCTURE)
                {
                    RfcContainerMetadata <RfcFieldMetadata> fieldMeta = pMetadata.ValueMetadataAsStructureMetadata;
                    if (!metaList.StructureDetail.Keys.Contains(fieldMeta.Name))
                    {
                        RfcStructureMetadata  strucmeta = pMetadata.ValueMetadataAsStructureMetadata;
                        List <StructureField> fieldList = new List <StructureField>();
                        for (int f = 0; f < strucmeta.FieldCount; f++)
                        {
                            RfcFieldMetadata fieldm         = strucmeta[f];
                            StructureField   structureField = new StructureField(fieldm.Name, fieldm.DataType.ToString(), fieldm.Decimals, fieldm.NucLength, fieldm.Documentation);
                            fieldList.Add(structureField);
                        }
                        metaList.StructureDetail.Add(fieldMeta.Name, fieldList);
                    }
                }
                else if (pMetadata.DataType == RfcDataType.TABLE)
                {
                    RfcTableMetadata tableMeta = pMetadata.ValueMetadataAsTableMetadata;
                    if (!metaList.StructureDetail.Keys.Contains(tableMeta.LineType.Name))
                    {
                        List <StructureField> tableFieldList = new List <StructureField>();
                        for (int f = 0; f < tableMeta.LineType.FieldCount; f++)
                        {
                            RfcFieldMetadata fieldm         = tableMeta.LineType[f];
                            StructureField   structureField = new StructureField(fieldm.Name, fieldm.DataType.ToString(), fieldm.Decimals, fieldm.NucLength, fieldm.Documentation);
                            tableFieldList.Add(structureField);
                        }
                        metaList.StructureDetail.Add(tableMeta.LineType.Name, tableFieldList);
                    }
                }
            }
            return(metaList);
        }
 /// <summary>
 /// 读取RFC函数的全部信息
 /// </summary>
 /// <param name="sysName"></param>
 /// <param name="funame"></param>
 /// <returns></returns>
 public static RfcFunctionMetaAsList GetFuncMetaAsList(string sysName, string funame)
 {
     funame = funame.ToUpper().Trim();
     RfcFunctionMetadata MetaData = GetRfcFunctionMetadata(sysName, funame);
     RfcFunctionMetaAsList metaList = new RfcFunctionMetaAsList();
     // metaList.Import.Add(
     //根据参数的方向,分为四种(CHANGING,EXPORT,IMPORT,TABLES);
     for (int i = 0; i < MetaData.ParameterCount; i++)
     {
         RfcParameterMetadata pMetadata = MetaData[i];
         FunctionField field = null;
         String dataTypeName = String.Empty;
         if (pMetadata.DataType == RfcDataType.STRUCTURE)
         {
             RfcContainerMetadata<RfcFieldMetadata> meta = pMetadata.ValueMetadataAsStructureMetadata;
             dataTypeName = meta.Name;
         }
         else if (pMetadata.DataType == RfcDataType.TABLE)
         {
             RfcContainerMetadata<RfcFieldMetadata> meta = pMetadata.ValueMetadataAsTableMetadata;
             RfcTableMetadata tablem = pMetadata.ValueMetadataAsTableMetadata;
             dataTypeName = tablem.LineType.Name;
         }
         field = new FunctionField(pMetadata.Name, pMetadata.Direction.ToString(), pMetadata.DataType.ToString(), pMetadata.Decimals, pMetadata.DefaultValue, pMetadata.NucLength, pMetadata.Optional, pMetadata.Documentation, dataTypeName);
         switch (pMetadata.Direction)
         {
             //创建四个方向的参数列表
             case RfcDirection.CHANGING:
                 metaList.Changing.Add(pMetadata.Name, field);
                 break;
             case RfcDirection.EXPORT:
                 metaList.Export.Add(pMetadata.Name, field);
                 break;
             case RfcDirection.IMPORT:
                 metaList.Import.Add(pMetadata.Name, field);
                 break;
             case RfcDirection.TABLES:
                 metaList.Tables.Add(pMetadata.Name, field);
                 break;
         }
         if (pMetadata.DataType == RfcDataType.STRUCTURE)
         {
             RfcContainerMetadata<RfcFieldMetadata> fieldMeta = pMetadata.ValueMetadataAsStructureMetadata;
             if (!metaList.StructureDetail.Keys.Contains(fieldMeta.Name))
             {
                 RfcStructureMetadata strucmeta = pMetadata.ValueMetadataAsStructureMetadata;
                 List<StructureField> fieldList = new List<StructureField>();
                 for (int f = 0; f < strucmeta.FieldCount; f++)
                 {
                     RfcFieldMetadata fieldm = strucmeta[f];
                     StructureField structureField = new StructureField(fieldm.Name, fieldm.DataType.ToString(), fieldm.Decimals, fieldm.NucLength, fieldm.Documentation);
                     fieldList.Add(structureField);
                 }
                 metaList.StructureDetail.Add(fieldMeta.Name, fieldList);
             }
         }
         else if (pMetadata.DataType == RfcDataType.TABLE)
         {
             RfcTableMetadata tableMeta = pMetadata.ValueMetadataAsTableMetadata;
             if (!metaList.StructureDetail.Keys.Contains(tableMeta.LineType.Name))
             {
                 List<StructureField> tableFieldList = new List<StructureField>();
                 for (int f = 0; f < tableMeta.LineType.FieldCount; f++)
                 {
                     RfcFieldMetadata fieldm = tableMeta.LineType[f];
                     StructureField structureField = new StructureField(fieldm.Name, fieldm.DataType.ToString(), fieldm.Decimals, fieldm.NucLength, fieldm.Documentation);
                     tableFieldList.Add(structureField);
                 }
                 metaList.StructureDetail.Add(tableMeta.LineType.Name, tableFieldList);
             }
         }
     }
     return metaList;
 }