Exemple #1
0
        private List <ErrCell> GetErrCellByParameter <T>(List <RowNoHeader> rows, int startRowIndex)
        {
            List <string> colNames  = _propertyCollection.Values.Select(u => u.ColName).ToList();
            List <int>    colIndexs = _propertyCollection.Values.Select(u => u.ColIndex).ToList();

            List <ErrCell> errCells = new List <ErrCell>();

            for (int rowIndex = startRowIndex; rowIndex < rows.Count; rowIndex++)
            {
                List <string> rowValues = rows[rowIndex].Where((u, index) => colIndexs.Any(p => p == index)).Select(u => u.ToString()).ToList();
                errCells.AddRange(RowValidate.Validate <T>(rowIndex, colNames, colIndexs, rowValues));
            }
            return(errCells);
        }
Exemple #2
0
        private List <ErrCell> GetErrCellByMatching <T>(T box, int rowIndex, List <CellMatching <T> > rowValidates)
        {
            List <T> row = new List <T>();

            row.Add(box);

            List <ErrCell> errCells = new List <ErrCell>();

            for (int i = 0; i < rowValidates.Count; i++)
            {
                var rowValidate = rowValidates[i];
                if (!row.Any(rowValidate.matchCondition))
                {
                    string errMsg = rowValidate.errMsg;

                    PropertyExpressionParser <T> property = new PropertyExpressionParser <T>(rowValidate.paramater);
                    var colDescription = (Attribute.GetCustomAttribute(property.GetPropertyInfo(rowValidate.paramater), typeof(ExcelColumnAttribute))) as ExcelColumnAttribute;
                    int ColIndex       = _propertyCollection[property.Name].ColIndex;

                    if (!errCells.Any(u => u.RowIndex == rowIndex && u.ColumnIndex == ColIndex))
                    {
                        errCells.Add(new ErrCell()
                        {
                            RowIndex    = rowIndex,
                            ColumnIndex = ColIndex,
                            Name        = RowValidate.GetCellStation(rowIndex, ColIndex),
                            ErrMsg      = errMsg
                        });
                    }
                    else
                    {
                        errCells.Find(u => u.RowIndex == rowIndex && u.ColumnIndex == ColIndex).ErrMsg += ";" + errMsg;
                    }
                }
            }
            return(errCells);
        }