// public so I can test it public static HorizonLineItem ProcessRowText(string row) { HorizonLineItem item = new HorizonLineItem(); string[] parsed; parsed = row.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); if (parsed.Count() != 14 || parsed[0].First() != quoteChar || parsed[13].Last() != quoteChar) { throw new InvalidDataException("Error in file format."); } else { parsed[0] = parsed.First().TrimStart(quoteChar); parsed[13] = parsed.Last().TrimEnd(quoteChar); // 0 - "COASTAL FINANCIAL GROUP" // 1 - "005766" item.GroupName = parsed[2]; item.GroupNumber = parsed[3]; item.Product = parsed[4]; item.EffectiveDate = parsed[5]; item.RenewalDate = parsed[6]; item.InsuredPeriod = parsed[7]; item.C_CodeOneHundredd = parsed[8]; // always "100" item.C_CoastalCode = parsed[9]; // always "005766" item.CommissionSchedule = parsed[10]; item.C_TotalPremiumYTD = parsed[11]; item.PremiumReceived = Decimal.Parse(parsed[12]); item.CommissionReceived = Decimal.Parse(parsed[13]); } return item; }
private static HorizonLineItem ProcessRowExcel(DataRow row) { /// only use rows with the code /// (other rows are not data) if (row[0].ToString().Trim() != CfgCode) return null; HorizonLineItem item = new HorizonLineItem(); // 0 - "COASTAL FINANCIAL GROUP" // 1 - "005766" item.GroupName = row.StringAt(2); item.GroupNumber = row.StringAt(3); item.Product = row.StringAt(4); item.EffectiveDate = row.StringAt(5); item.RenewalDate = row.StringAt(6); item.InsuredPeriod = row.StringAt(7); item.C_CodeOneHundredd = row.StringAt(8); // always "100" item.C_CoastalCode = row.StringAt(9); // always "005766" item.CommissionSchedule = row.StringAt(10); item.C_TotalPremiumYTD = row.StringAt(11); item.PremiumReceived = row.DecimalAt(12); item.CommissionReceived = row.DecimalAt(13); return item; }