private void ProcessIncomeTable(Table table, PublicServant person) { var rows = table.Descendants <TableRow>().ToList().Skip(1); foreach (var row in rows) { var cells = row.Descendants <TableCell>().ToList(); var incomeType = cells[1].InnerText.OnlyRussianLowercase(); if (incomeType.StartsWith("декларированныйгодовойдоход")) { var incomeRaw = cells[2].InnerText.Trim(); if (incomeRaw == "") { continue; } person.DeclaredYearlyIncomeRaw = incomeRaw; person.DeclaredYearlyIncome = DataHelper.ParseDeclaredIncome(incomeRaw, false); } else if (DataHelper.IsRelativeInfo(incomeType)) { var incomeRaw = cells[2].InnerText.Trim(); var relationType = DataHelper.ParseRelationType(incomeType, false); var relative = new Relative(); relative.RelationType = relationType; relative.DeclaredYearlyIncomeRaw = incomeRaw; relative.DeclaredYearlyIncome = DataHelper.ParseDeclaredIncome(incomeRaw, false); person.AddRelative(relative); } } }
public void CreateNewRelative(DataRow row) { Logger.Debug(String.Format("Relative {0} at row {1}", row.RelativeType, row.GetRowIndex())); if (CurrentDeclarant == null) { if (FailOnRelativeOrphan) { throw new SmartParserRelativeWithoutPersonException( string.Format("Relative {0} at row {1} without main Person", row.RelativeType, row.GetRowIndex())); } else { return; } } Relative relative = new Relative(); CurrentDeclarant.AddRelative(relative); CurrentPerson = relative; RelationType relationType = DataHelper.ParseRelationType(row.RelativeType, false); if (relationType == RelationType.Error) { throw new SmartParserException( string.Format("Wrong relative name '{0}' at row {1} ", row.RelativeType, row)); } relative.RelationType = relationType; relative.document_position = row.NameDocPosition; relative.sheet_index = _Declaration.Properties.SheetNumber; }
private Relative GetPersonRelative(PublicServant person, RelationType relationType) { var foundRelatives = person.Relatives.Where(x => x.RelationType == relationType).ToList(); if (foundRelatives.Count != 0) { return(foundRelatives[0]); } var relative = new Relative(); relative.RelationType = relationType; person.AddRelative(relative); return(relative); }