Exemplo n.º 1
0
        public List <ProfileAttributeCell> GetColumnCells(List <ProfileAttributeType> attributes)
        {
            List <ProfileAttributeCell> items = new List <ProfileAttributeCell>();

            if (ColumHeader.Where(c => attributes.Contains(c.Attribute)).Any())
            {
                List <ProfileAttributeColumn> cols = ColumHeader.Where(c => attributes.Contains(c.Attribute)).ToList();
                cols.ForEach(c => items.AddRange((from r in Rows select r.GetCell(c)).ToList()));
            }
            return(items);
        }
Exemplo n.º 2
0
 public List <ExternalColumn> VerifyDuplicationValues()
 {
     if (ColumHeader == null && ColumHeader.Count == 0)
     {
         return(new List <ExternalColumn>());
     }
     else
     {
         return(ColumHeader.Where(c => c.AllowDuplicate == false).ToList());
     }
 }
Exemplo n.º 3
0
        private ExternalRow CreateRow(TextRow tRow, ref int index)
        {
            ExternalRow row = new ExternalRow();

            row.Number = index++;

            ColumHeader.ForEach(c => row.Cells.Add(new ExternalCell()
            {
                Column = c, Row = row, Value = tRow[c.Number - 1]
            }));

            return(row);
        }
Exemplo n.º 4
0
        public List <ExternalCell> GetColumnCells(InputType inputType, Int32 index)
        {
            List <ExternalCell> items = new List <ExternalCell>();

            if (ColumHeader.Where(c => c.InputType == inputType && c.Number == index).Any())
            {
                ExternalColumn col = ColumHeader.Where(c => c.InputType == inputType && c.Number == index).FirstOrDefault();

                items = (from r in Rows select r.GetCell(col.Number)).ToList();
                // Rows.ForEach(r => items.AddRange(r.Select((value, i) => new { Value = value, Index = i }).Where(item => item.Index == index).Select(item => item.Value).ToList()));
            }
            return(items);
        }
Exemplo n.º 5
0
        //private ProfileExternalTextRow CreateExternalRow(TextRow row, List<int> colIndexes, ref int index)
        //{
        //    ProfileExternalTextRow result = new ProfileExternalTextRow();
        //    result.Number = index;
        //    result.AddRange(row.Select((value, i) => new { Value = value, Index = i }).Where(c => colIndexes.Contains(c.Index)).Select(c => c.Value).ToList());
        //    index += 1;
        //    return result;
        //}

        public List <ProfileAttributeCell> GetColumnCells(ProfileAttributeType attribute)
        {
            List <ProfileAttributeCell> items = new List <ProfileAttributeCell>();

            if (ColumHeader.Where(c => c.Attribute == attribute).Any())
            {
                ProfileAttributeColumn col = ColumHeader.Where(c => c.Attribute == attribute).FirstOrDefault();

                items = (from r in Rows select r.GetCell(col)).ToList();
                // Rows.ForEach(r => items.AddRange(r.Select((value, i) => new { Value = value, Index = i }).Where(item => item.Index == index).Select(item => item.Value).ToList()));
            }
            return(items);
        }
Exemplo n.º 6
0
        private ProfileAttributesRow CreateRow(TextRow tRow, ref int index)
        {
            ProfileAttributesRow row = new ProfileAttributesRow();

            row.Number = index++;

            ColumHeader.ForEach(c => row.Cells.Add(new ProfileAttributeCell()
            {
                Column = c, Row = row, Value = tRow[c.Number - 1]
            }));

            return(row);
        }
Exemplo n.º 7
0
        private ProfileAttributesRow CreateRow(List <ProfileAttributeCell> tRow, ref int index)
        {
            ProfileAttributesRow row = new ProfileAttributesRow();

            row.Number = index++;
            if (tRow.Count == ColumHeader.Count)
            {
                ColumHeader.Select((c, colIndex) => new { Col = c, Index = colIndex }).ToList().ForEach(c => row.Cells.Add(ProfileAttributeCell.Update(tRow[c.Index], c.Col, row)));
            }
            else
            {
                ColumHeader.ForEach(c => row.Cells.Add(ProfileAttributeCell.Update(tRow[c.Number - 1], c, row)));
            }

            return(row);
        }
Exemplo n.º 8
0
        public ExternalResource(List <ExternalColumnComparer <String, Int32> > columns, CsvFile csvFile) : this()
        {
            if (csvFile != null)
            {
                List <int> colIndexes = columns.Where(ec => ec.isValid).Select(c => c.Number).ToList();

                foreach (TextColumn column in csvFile.ColumHeader.Where(c => colIndexes.Contains(c.Number)))
                {
                    ColumHeader.Add(new ExternalColumn(columns.Where(c => c.Number == column.Number).Select(c => c.InputType).FirstOrDefault())
                    {
                        Number = column.Number, Name = columns.Where(c => c.Number == column.Number).Select(c => c.DestinationColumn.Name).FirstOrDefault()
                    });
                }
                int index = 0;
                csvFile.Rows.ForEach(r => Rows.Add(CreateRow(r, ref index)));
                ValidateSourceData();
            }
        }
Exemplo n.º 9
0
        private void ValidateSourceData()
        {
            // Find all columns to validate at startup !
            List <ExternalColumn> cols = ColumHeader.Where(c => c.AllowDuplicate == false).ToList();

            foreach (ExternalColumn col in cols)
            {
                List <ExternalCell> cells = GetDuplicatedCells(col.InputType, col.Number);
                if (cells != null && cells.Count > 0)
                {
                    cells.ForEach(c => c.SetDuplicatedRows(cells.Where(cc => cc != c).Select(cr => cr.Row.Number).ToList()));
                }
            }
            foreach (ExternalRow row in Rows)
            {
                row.AllowImport = row.isValid();
            }
        }
Exemplo n.º 10
0
        private void ValidateStartData()
        {
            // Find all columns to validate at startup !
            List <ProfileAttributeColumn> cols = ColumHeader.Where(c => c.AllowDuplicate == false).ToList();

            foreach (ProfileAttributeColumn col in cols)
            {
                List <ProfileAttributeCell> cells = GetDuplicatedCells(col.Attribute);
                if (cells != null && cells.Count > 0)
                {
                    cells.ForEach(c => c.SetDuplicatedRows(cells.Where(cc => cc != c).Select(cr => cr.Row.Number).ToList()));
                }
            }
            foreach (ProfileAttributesRow row in Rows)
            {
                row.AllowImport = row.isValid();
            }
        }
Exemplo n.º 11
0
        private ExternalRow CreateRow(List <String> tRow, ref int index)
        {
            ExternalRow row = new ExternalRow();

            row.Number = index++;
            if (tRow.Count == ColumHeader.Count)
            {
                ColumHeader.Select((c, colIndex) => new { Col = c, Index = colIndex }).ToList().ForEach(c => row.Cells.Add(new ExternalCell()
                {
                    Column = c.Col, Row = row, Value = tRow[c.Index]
                }));
            }
            else
            {
                ColumHeader.ForEach(c => row.Cells.Add(new ExternalCell()
                {
                    Column = c, Row = row, Value = tRow[c.Number - 1]
                }));
            }

            return(row);
        }
Exemplo n.º 12
0
 public void ValidateSourceData(List <Int32> notEmptyColumns, List <Int32> notDuplicatedColumns)
 {
     ColumHeader.Where(c => notEmptyColumns.Contains(c.Number)).ToList().ForEach(c => c.AllowEmpty          = false);
     ColumHeader.Where(c => notDuplicatedColumns.Contains(c.Number)).ToList().ForEach(c => c.AllowDuplicate = false);
     ValidateSourceData();
 }