Exemplo n.º 1
0
        private IEnumerable <object> ProcessDataProperty(EdiDataPropertySettings dataPropertySettings, CultureInfo cultureInfo)
        {
            var offsetRowIndex = 0;
            var loopCount      = 0;
            var endOfFile      = false;
            var dataRecords    = new List <object>();

            if (!(dataPropertySettings.DataProperty.DataProperties?.Any() ?? false))
            {
                return(dataRecords);
            }

            do
            {
                var currentStartRowIndex = dataPropertySettings.StartRowIndex + loopCount * offsetRowIndex;

                if (dataPropertySettings.DataRows.Length > currentStartRowIndex)
                {
                    var dataRecord = Activator.CreateInstance(dataPropertySettings.DataRecordType);
                    offsetRowIndex = CalculateRowIndexOffset(dataPropertySettings.DataProperty, offsetRowIndex);

                    var settings = new EdiSettings
                    {
                        DataRows             = dataPropertySettings.DataRows,
                        DataRecord           = dataRecord,
                        DataType             = dataPropertySettings.DataRecordType,
                        CurrentStartRowIndex = currentStartRowIndex,
                        CultureInfo          = cultureInfo
                    };

                    foreach (var dataProperty in dataPropertySettings.DataProperty.DataProperties)
                    {
                        settings.DataProperty = dataProperty;
                        endOfFile             = ProcessPropertyInfo(settings);
                    }

                    dataRecords.Add(dataRecord);
                }
                else
                {
                    endOfFile = true;
                }

                loopCount++;
            }while (dataPropertySettings.DataProperty.CanRepeatEDI && !endOfFile);

            return(dataRecords);
        }
Exemplo n.º 2
0
        private void ProcessEnumerableProperty(EdiSettings settings)
        {
            var dataRecordEnumerable = InitDataRecordEnumerable(settings.DataRecord, settings.PropertyInfo);

            var dataPropertySettings = new EdiDataPropertySettings
            {
                DataRows       = settings.DataRows,
                DataProperty   = settings.DataProperty,
                DataRecordType = settings.PropertyInfo.PropertyType.GetGenericArguments()[0],
                StartRowIndex  = settings.CurrentStartRowIndex
            };

            var childs = ProcessDataProperty(dataPropertySettings, settings.CultureInfo);

            ProcessEnumerablePropertyResult(childs, dataRecordEnumerable);
        }
Exemplo n.º 3
0
        private void ProcessClassProperty(EdiSettings settings)
        {
            var dataPropertySettings = new EdiDataPropertySettings
            {
                DataRows       = settings.DataRows,
                DataProperty   = settings.DataProperty,
                DataRecordType = settings.PropertyInfo.PropertyType,
                StartRowIndex  = settings.CurrentStartRowIndex
            };

            var child = ProcessDataProperty(dataPropertySettings, settings.CultureInfo).FirstOrDefault();

            if (child != null && !(child as IEmpty).IsEmpty)
            {
                SetPropertyValue(settings.PropertyInfo, settings.DataRecord, child, settings.CultureInfo);
            }
        }
Exemplo n.º 4
0
        private List <T> ProcessRow <T>(DataProperty configuration, string[] dataRows)
        {
            var dataRecords = new List <T>();

            var settings = new EdiDataPropertySettings
            {
                DataRows       = dataRows,
                DataProperty   = configuration,
                DataRecordType = typeof(T),
                StartRowIndex  = 0
            };

            var items = ProcessDataProperty(settings, configuration.CultureCode.GetCultureInfo());

            foreach (var item in items)
            {
                dataRecords.Add((T)item);
            }

            return(dataRecords);
        }