Пример #1
0
        public static List <Dictionary <string, object> > GetListDictionaryForMetadataExport(IRfcFunction rfc, string tableName)
        {
            Dictionary <string, object>         dictionary     = new Dictionary <string, object>();
            List <Dictionary <string, object> > listDictionary = new List <Dictionary <string, object> >();

            for (int i = 0; i < rfc.Metadata.ParameterCount; i++)
            {
                if (rfc.Metadata[i].Name.ToString().ToUpper() == tableName)
                {
                    switch (rfc.Metadata[i].DataType.ToString())
                    {
                    case "STRUCTURE":
                        IRfcStructure detailStructure = rfc[tableName].GetStructure();
                        dictionary = new Dictionary <string, object>();
                        for (int j = 0; j < detailStructure.Count(); j++)
                        {
                            //dictionary[rfc.Metadata[i].ValueMetadataAsStructureMetadata[j].Name] = Activator.CreateInstance(SAPData.GetDataType(rfc.Metadata[i].ValueMetadataAsStructureMetadata[j].DataType));

                            var valueObj = detailStructure.GetValue(rfc.Metadata[i].ValueMetadataAsStructureMetadata[j].Name);
                            dictionary[rfc.Metadata[i].ValueMetadataAsStructureMetadata[j].Name] = valueObj;
                        }
                        listDictionary.Add(dictionary);
                        break;

                    case "TABLE":
                        IRfcTable detail = rfc[tableName].GetTable();
                        for (int j = 0; j < detail.Count(); j++)
                        {
                            //foreach (IRfcStructure column in detail[j])
                            dictionary = new Dictionary <string, object>();
                            for (int x = 0; x < detail[j].Count(); x++)
                            {
                                var valueObj = detail[j].GetValue(rfc.Metadata[i].ValueMetadataAsTableMetadata[x].Name);
                                dictionary[rfc.Metadata[i].ValueMetadataAsTableMetadata[x].Name] = valueObj;
                            }
                            listDictionary.Add(dictionary);
                        }

                        break;
                    }
                }
            }
            return(listDictionary);
        }