Example #1
0
        void ParseCellTexts()
        {
            List <int> linesWithNumbers = GetLinesStaringWithNumbers(SquareCell.DataCell.GetText(true));

            if (linesWithNumbers.Count > 1)
            {
                EstateTypeCell.ParseByEmptyLines(linesWithNumbers);
                OwnTypeCell.ParseByEmptyLines(linesWithNumbers);
                SquareCell.ParseByEmptyLines(linesWithNumbers);
                CountryCell.ParseByEmptyLines(linesWithNumbers);
            }
            else
            {
                SquareCell.ParseByAntlr(new AntlrSquareParser());
                if (OwnTypeCell.DataCell != null)
                {
                    EstateTypeCell.ParseByAntlr(new AntlrRealtyTypeParser());
                    OwnTypeCell.ParseByAntlr(new AntlrOwnTypeParser());
                }
                else
                {
                    foreach (var r in new AntlrRealtyTypeAndOwnTypeParser().Parse(EstateTypeCell.DataCell.GetText(true)))
                    {
                        var i = (RealtyTypeAndOwnTypeFromText)r;
                        EstateTypeCell.ParsedItems.Add(i.RealtyType);
                        OwnTypeCell.ParsedItems.Add(i.OwnType);
                    }
                }
                CountryCell.ParseByAntlr(new AntlrCountryListParser());
            }
        }
Example #2
0
        void ParseTypeAndCountry(DataRow currRow, DeclarationField realtyType, string ownTypeByColumn, Person person)
        {
            var        typeAndCountry   = new TRealtyCell(currRow.GetDeclarationField(realtyType));
            var        cellSquareField  = (realtyType == DeclarationField.OwnedRealEstateTypeAndCountry) ? DeclarationField.OwnedRealEstateSquare : DeclarationField.StatePropertySquare;
            var        squareCell       = new TRealtyCell(currRow.GetDeclarationField(cellSquareField));
            List <int> linesWithNumbers = TRealtyCellSpan.GetLinesStaringWithNumbers(squareCell.DataCell.GetText(true));

            if (linesWithNumbers.Count > 0)
            {
                typeAndCountry.ParseByEmptyLines(linesWithNumbers);
                squareCell.ParseByEmptyLines(linesWithNumbers);
            }
            for (int i = 0; i < squareCell.ParsedItems.Count; ++i)
            {
                var typeAndCountryStr = typeAndCountry.GetParsedItem(i);
                var type       = typeAndCountryStr;
                var countryStr = "";

                if (typeAndCountryStr.Contains('('))
                {
                    int bracket = typeAndCountryStr.IndexOf('(');
                    type       = typeAndCountryStr.Substring(0, bracket).Trim();
                    countryStr = typeAndCountryStr.Substring(bracket).Trim(' ', '\n', '(', ')');
                }
                var squareRaw = squareCell.GetParsedItem(i);

                RealEstateProperty realEstateProperty = new RealEstateProperty();
                realEstateProperty.Text               = type;
                realEstateProperty.type_raw           = type;
                realEstateProperty.square             = DataHelper.ParseSquare(squareRaw);
                realEstateProperty.square_raw         = ParserBase.NormalizeRawDecimalForTest(squareRaw);
                realEstateProperty.country_raw        = DataHelper.ParseCountry(countryStr).NormSpaces();
                realEstateProperty.own_type_by_column = ownTypeByColumn;
                person.RealEstateProperties.Add(realEstateProperty);
            }
        }