public static int importGreenBarDetail(string _yrmo, string _fileName) { string _Reportyrmo = ""; int _count = 0; int _recCount = 0; string line = string.Empty; string _PatternDate = @"(?<month>JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER)\s+(?<year>\d{4})\s+PAYMENT\s*"; TextReader reader = new StreamReader(File.OpenRead(_fileName)); Regex r = new Regex(_PatternDate); DataSet dsGreenBar = new DataSet(); dsGreenBar.Clear(); try { while ((line = reader.ReadLine()) != null && _count == 0) { Match parsed = Regex.Match(line, _PatternDate); if (parsed.Success) { string _pyear = parsed.Groups["year"].Value.ToString(); string _pmonth = calucluateMonth(parsed.Groups["month"].Value.ToString()); _Reportyrmo = _pyear + _pmonth; _count++; } } if (_Reportyrmo.Equals(_yrmo)) { dsGreenBar = parseGreenBarDetails(_fileName, _yrmo); _recCount = IPBAImportDAL.insertGreenBar(dsGreenBar, _yrmo); } else { throw (new Exception("YRMO entered doesnt match with Report, Please check the Report.")); } } catch (Exception ex) { throw ex; } finally { reader.Close(); } return(_recCount); }
public static int importRatesTemplate(string _file, string _year) { DataSet impData = new DataSet(); DataTable dt = new DataTable("rateTemplate"); if (_file.Contains(_year)) { try { impData.Tables.Add(ConvertExcel.ConvertXLS(_file, dt)); int _cnt = IPBAImportDAL.insertRates(impData); return(_cnt); } catch (Exception ex) { throw ex;; } } else { throw (new Exception("Selected file is not for year - '" + _year + "'. Please import correct file.")); } }
public static int importADPDetail(string _yrmo, string _fileName) { string _Reportyrmo = null; int _count = 0; int _recCount = 0; string line = string.Empty; string _PatternDate = @"(?<month>\d{1,2})\/(?<year>\d{4})[ \t]*\*(All Plans)"; TextReader reader = new StreamReader(File.OpenRead(_fileName)); Regex r = new Regex(_PatternDate); ImportDAL iobj = new ImportDAL(); string _prevyrmo = iobj.getPrevYRMO(_yrmo); DataSet dsADP = new DataSet(); dsADP.Clear(); try { while ((line = reader.ReadLine()) != null && _count == 0) { Match parsed = Regex.Match(line, _PatternDate); if (parsed.Success) { string _pyear = parsed.Groups["year"].Value.ToString(); int _pmonth = Int32.Parse(parsed.Groups["month"].Value.ToString()); string _monthnew; if (_pmonth < 10) { _monthnew = "0" + Convert.ToString(_pmonth); } else { _monthnew = Convert.ToString(_pmonth); } _Reportyrmo = _pyear + _monthnew; _count++; } } if (_Reportyrmo.Equals(_prevyrmo)) { dsADP = parseADPDetails(_fileName, _prevyrmo); _recCount = IPBAImportDAL.insertADP(dsADP, _yrmo); } else { throw (new Exception("YRMO entered doesnt match with Report, Please check the Report.")); } } catch (Exception ex) { throw ex; } finally { reader.Close(); } return(_recCount); }
protected static DataSet parseADPDetails(string _fileName, string _yrmo) { string line = string.Empty; string _plan = ""; bool _planfound = false; List <string> _hmoCodes = new List <string>(); _hmoCodes = IPBAImportDAL.getHMOCodes(); DataRow rowNew; DataSet dsTotal = new DataSet(); DataTable newTable; newTable = dsTotal.Tables.Add("newTable1"); DataColumn col; col = new DataColumn("plan"); newTable.Columns.Add(col); col = new DataColumn("fname"); newTable.Columns.Add(col); col = new DataColumn("lname"); newTable.Columns.Add(col); col = new DataColumn("SSN"); newTable.Columns.Add(col); col = new DataColumn("dob"); newTable.Columns.Add(col); col = new DataColumn("bensts"); newTable.Columns.Add(col); col = new DataColumn("effdt"); newTable.Columns.Add(col); col = new DataColumn("termdt"); newTable.Columns.Add(col); col = new DataColumn("covlvl"); newTable.Columns.Add(col); col = new DataColumn("comments"); newTable.Columns.Add(col); col = new DataColumn("premium"); newTable.Columns.Add(col); col = new DataColumn("covgperiod"); newTable.Columns.Add(col); string _planPattern = @"^\s+Plan:\s+(?<plan>[A-Z0-9]+)\s+"; TextReader reader = new StreamReader(File.OpenRead(_fileName)); Regex r = new Regex(_planPattern); try { while ((line = reader.ReadLine()) != null) { Match parsed = Regex.Match(line, _planPattern); if (parsed.Success) { _planfound = false; _plan = parsed.Groups["plan"].Value.ToString(); foreach (string _cd in _hmoCodes) { if (_plan.Trim().Equals(_cd)) { _planfound = true; break; } } continue; } if (_planfound) { bool _found = false; if (line.Length > 27) { _found = checkSSN(line.Substring(27, 11)); } if (_found) { string period = line.Substring(126, 7).Trim(); int _pmonth; string _year; _pmonth = Convert.ToInt32(period.Substring(0, period.IndexOf("/"))); _year = period.Substring(period.IndexOf("/") + 1); string _monthnew; if (_pmonth < 10) { _monthnew = "0" + Convert.ToString(_pmonth); } else { _monthnew = Convert.ToString(_pmonth); } string _nyrmo = (_year + _monthnew); //if (_nyrmo.Equals(_yrmo)) //{ rowNew = newTable.NewRow(); rowNew["plan"] = _plan; string _name = line.Substring(1, 20).Trim(); int _index = _name.IndexOf(','); string _lname = _name.Substring(0, _index); string _fname = _name.Substring(_index + 1); rowNew["fname"] = _fname; rowNew["lname"] = _lname; rowNew["SSN"] = line.Substring(27, 11).Trim(); rowNew["dob"] = line.Substring(39, 11).Trim(); rowNew["bensts"] = line.Substring(81, 1).Trim(); rowNew["effdt"] = line.Substring(94, 10).Trim(); rowNew["termdt"] = line.Substring(105, 10).Trim(); string _nCode = ""; if (!line.Substring(116, 2).Trim().Equals("")) { _nCode = cobraTiercode(line.Substring(116, 2).Trim()); } rowNew["covlvl"] = _nCode; rowNew["comments"] = line.Substring(146, 10).Trim(); string _rate = line.Substring(158, 10).Trim(); string _delimit = "CR"; object _frate = ""; if (_rate.Contains("CR")) { _frate = (-1) * Convert.ToDecimal(_rate.Trim(_delimit.ToCharArray())); } else { _frate = _rate; } rowNew["premium"] = _frate; rowNew["covgperiod"] = _nyrmo; newTable.Rows.Add(rowNew); //} } } } } catch (Exception ex) { throw ex; } finally { reader.Close(); } return(dsTotal); }