Ejemplo n.º 1
0
        public static SAPFileMapping GetConfig()
        {
            SAPFileMapping result = (SAPFileMapping)ConfigurationBroker.GetSection("DynamicsFiledTypesMapping");

            if (result == null)
            {
                result = new SAPFileMapping();
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据SAP字段类型和长度返回UEP字段和长度
        /// </summary>
        /// <param name="fileType">字段类型</param>
        /// <param name="fileLength">字段长度</param>
        public static FieldTypeEnum SAPFiledTypeToUEPFiledType(string fileType, ref int fileLength)
        {
            FieldTypeEnum fieldType = new FieldTypeEnum();

            SAPFileMapping settings = SAPFileMapping.GetConfig();

            //settings.SAPFileds
            string outfiletype      = fileType;
            int    outFilelenth     = fileLength;
            var    sapFiledElements = settings.SAPFileds.Cast <SAPFiledElement>();

            // GetTypeMapping gm = new GetTypeMapping(GetUepTypeMappingAdd);

            var sapElementMapping = sapFiledElements.FirstOrDefault(p => p.OutType.ToUpper().Equals(outfiletype.ToUpper()) && GetUepTypeMapping(p.Opration, outFilelenth, p.OutLength));

            if (sapElementMapping != null)
            {
                fieldType = (FieldTypeEnum)(Enum.Parse(typeof(FieldTypeEnum), sapElementMapping.UEPType));
                fileType  = sapElementMapping.UEPType;
                string[]         typeStrings    = sapElementMapping.UEPLengthDelegate.Split(',');
                Type             uepLenthType   = Type.GetType(typeStrings[0]);
                object           instance       = Activator.CreateInstance(uepLenthType);
                GetUepTypeLength uepTypeMothend =
                    (GetUepTypeLength)Delegate.CreateDelegate(typeof(GetUepTypeLength), instance, typeStrings[1]);

                fileLength = uepTypeMothend(outFilelenth, sapElementMapping.OperationLength);
            }
            else
            {
                fieldType = FieldTypeEnum.String;
                fileType  = "string";
            }
            return(fieldType);

            // this.GetSapFileElement(settings.SAPFileds, fileType, fileLength);
        }