private void ScanLineCharges(ref ScannedRecord scannedRecord, ref int failedMatches) { int _unitsField = 1; int _costPerUnitField = 2; int _chargeField = 3; string _resultString = ""; Regex _regex = new Regex(@"(Fixed Line Charge).*(Variable Line Charge)"); //_resultString = _regex.Match(_scannedText).ToString().OnlyDigits().TrimAndReduce(); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.LCfixedUnits = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField, 0); scannedRecord.LCfixedCostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, _costPerUnitField); scannedRecord.LCfixedCharge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Variable Line Charge).*(Anytime Maximum Demand)"); //_resultString = _regex.Match(_scannedText).ToString().OnlyDigits().TrimAndReduce(); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.LCvariableUnits = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.LCvariableCostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, _costPerUnitField, 3); scannedRecord.LCvariableCharge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Anytime Maximum Demand).*(Assessed Capacity)"); //_resultString = _regex.Match(_scannedText).ToString().OnlyDigits().TrimAndReduce(); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.LCmaxDemandUnits = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField, 1); scannedRecord.LCmaxDemandCostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, _costPerUnitField); scannedRecord.LCmaxDemandCharge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Assessed Capacity).*(Total Line)"); _costPerUnitField = 3; _chargeField = 99; // When 99 - returns the last number form input string //_resultString = _regex.Match(_scannedText).ToString().RemoveKnownSymbols().OnlyDigits().TrimAndReduce(); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.LCassessedCapacityUnits = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField, 0); scannedRecord.LCassessedCapacityPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, _costPerUnitField); scannedRecord.LCassessedCapacityCharge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); }
private void ScanFixedData(ref ScannedRecord scannedRecord, ref int failedMatches) { Regex _regex = new Regex(@"(Account)\s+(Number:)\s+\w+"); scannedRecord.AccountNumber = ReturnText(_regex.Match(_scannedText).ToString(), ':', ref failedMatches, 1); _regex = new Regex(@"(Invoice)\s+(Number:)\s+\w+"); scannedRecord.InvoiceNumber = ReturnText(_regex.Match(_scannedText).ToString(), ':', ref failedMatches, 1); _regex = new Regex(@"(ICP).*(Fixed)"); scannedRecord.ICPnumber = ReturnText(_regex.Match(_scannedText).ToString(), ' ', ref failedMatches, 2).RemoveSymbols(); }
private ScannedRecord ProcessMeridianInvoice(string scannedText) { ScannedRecord scannedRecord = new ScannedRecord(); // Logic for Meridian invoice type. // 1. "Invoice number: xxxxx" scannedRecord.InvoiceNumber = Convert.ToString(Regex.Match(scannedText, "Invoice Number: [0-9]*")).Split(':')[1]; scannedRecord.AccountNumber = Convert.ToString(Regex.Match(scannedText, "Account Number: [0-9]*")).Split(':')[1]; scannedRecord.ICPnumber = Convert.ToString(Regex.Match(scannedText, "ICP Number: [0-9]*")).Split(':')[1]; // return(scannedRecord); }
private void ScanDate(ref ScannedRecord scannedRecord, ref int failedMatches) { Regex _regex = new Regex(@"(From).*(Days)"); var dt = ReturnDate(_regex.Match(_scannedText).ToString().RemoveString("From").RemoveString("Days"), ref failedMatches); if (dt.Count() == 2) { scannedRecord.FromDate = dt[0]; scannedRecord.ToDate = dt[1]; } else { failedMatches++; } }
public ScanPageStatus Process(string fileName, ref ScannedRecord scannedRecord) { //ScanPageStatus scanPageStatus = new ScanPageStatus(); bool _debug = System.Diagnostics.Debugger.IsAttached; _debug = false; // Scan the PDF, create readable PDF output file if (_debug) { scanPageStatus.rc = 0; } else { CreateTxtFromPDF(fileName); } if (scanPageStatus.rc == 0) { string companyData; // If file has scanned correctly, then read in processed PDF, identifying company name and key data (only return the key data) if (_debug) { companyData = "ACCOUNT DETAILS Page 2 of 3 Account Number: 2707108410 Electricity Charges for 25D Bouverie Street Invoice Number: 659510 From 1 OCt0ber2011 to 31 October 2011 (31 Days) ’ 111 _ d @l ICP Number: 0O01452560UN-B21 Line Charges I Fixed Line Charge (GX99) 31 Day($l) $20.49 per Day $635.34 Variable Line Charge (GX99) 66,916.44 kWh 0.720c per kWh $481.80 Anytime Maximum Demand (GX99) $6.65 per kVA $2,211.45 Assessed Capacity (GX99) 31 Day(s) 1,000 kVA * 1.71c/day22 $530.10 Total Line Charges $3,858.69 Energy kWh kWh Losses cents per kWh Weekdays (0000 - 0400) 1,943.98 54.43 7.794 $155.76 Weekdays (0400 - 0800) 6,309.36 176.66 8.591 $557.21 Weekdays (0800 - 1200) 13,086.08 366.41 11.428 $1,537.35 Weekdays (1200 — 1600) 11,622.74 325.44 10.803 $1,290.76 Weekdays (1600 ~ 2000) 10,750.22 301.01 11.838 $1,308.24 Weekdays (2000 - 2400) 2,501.30 70.04 10.171 $261.53 Weekends (0000 ~ 0400) 997.00 27.92 6.494 $66.56 Weekends (0400 — 0800) 1,943.94 54.43 7.159 $143.06 Weekends (0800 — 1200) 6,588.34 184.47 9.523 $644.98 Weekends (1200 - 1600) 5,920.26 165.77 9.002 $547.86 Weekends (1600 - 2000) 4,233.14 118.53 9.864 $429.25 Weekends (2000 ~ 2400) 1,020.08 28.56 8.475 $88.87 Energy Totals 66,916.44 1,873.66 $7,031.43 Other Charges Administration Charge 31 Day(s) $1.32 per Day $40.92 Electricity Commission Levies 68,790.00 kWh 0.172c per kWh $118.32 $159.24 (:57 15% 1,657.40 Total Electricity Charges $12,706.76 in (D o o o o E "; scanPageStatus.statusMessage = String.Format("Debug mode, no scan started"); scanPageStatus.rc = 0; scanPageStatus.companyName = "contact"; } else { companyData = ReadInText(); } // Once read, interprit the data and return easily digestable format for persiting to database in calling project if (scanPageStatus.rc == 0) { // Can now interprit the data ExtractCompanyData extractCompanyData = new ExtractCompanyData(scanPageStatus.companyName, companyData); //ScannedRecord scannedRecord = new ScannedRecord(); // Scanned Page Status is not used from this point. Rely on status of returned record to decide if there are issues to report scannedRecord = extractCompanyData.GetKeyData(); } } return(scanPageStatus); // temp -- need to take into account rc != 0 above }
public ScannedRecord GetKeyData() { // I'm sure there is a smarter way to do this... ****GPA ScannedRecord scannedRecord = new ScannedRecord(); switch (_companyName) { case "contact": ContactEnergy companyTools = new ContactEnergy(_companyData); scannedRecord = companyTools.ProcessContactInvoice(); break; case "meridian": break; } return(scannedRecord); }
private void ScanOtherCharges(ref ScannedRecord scannedRecord, ref int failedMatches) { int _unitsField = 0; int _rateField = 1; int _chargeField = 2; int _totalChargeField = 99; string _resultString = ""; Regex _regex = new Regex(@"(Administration).*(Electricity)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.AdminCharge_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField, 0); scannedRecord.AdminCharge_Rate = ReturnDecimal(_resultString, ' ', ref failedMatches, _rateField); scannedRecord.AdminCharge_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Electricity)\s\w*\s(Levies).*$"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.ECLevies_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.ECLevies_Rate = ReturnDecimal(_resultString, ' ', ref failedMatches, _rateField, 3); scannedRecord.ECLevies_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); scannedRecord.TotalCharge = ReturnDecimal(_resultString, ' ', ref failedMatches, _totalChargeField); }
public ScannedRecord ProcessContactInvoice() { int failedMatches = 0; int failedValidations = 0; string failedValidationRecords = string.Empty; ScannedRecord scannedRecord = new ScannedRecord(); // Logic for Contact invoice type. ScanDate(ref scannedRecord, ref failedMatches); ScanFixedData(ref scannedRecord, ref failedMatches); ScanLineCharges(ref scannedRecord, ref failedMatches); ScanEnergyCharges(ref scannedRecord, ref failedMatches); ScanOtherCharges(ref scannedRecord, ref failedValidations); ValidateScannedData(ref scannedRecord, ref failedValidations, ref failedValidationRecords); scannedRecord.CompanyName = "to be advised"; // This is currently a "not null" field. Either scan in or work out from account number? GPA *** scannedRecord.FailedMatches = failedMatches; scannedRecord.FailedValidations = failedValidations; scannedRecord.FailedValidationRecords = failedValidationRecords; return(scannedRecord); }
public ScanPageStatus ReadFile(string filename) { // Look for file in common location // move to in process // scan // move to processed (archive) // Need to have multiple pages available ScanPageStatus scanPageStatus = new ScanPageStatus(); try { // Database connection via DocumentScanningLibrary, this is intermediate table for data loads ScannedRecord scannedRecord = new ScannedRecord(); // { CompanyName = "test", CustomerNumber = 1, InvoiceNumber = 1 }; ////var test = db.ScannedRecords.Count(); ////db.ScannedRecords.InsertOnSubmit(scannedRecord); ////db.SubmitChanges(); if (!String.IsNullOrEmpty(filename)) { // ScanPDF useses the Tesseract public domain OCR tool set acting in PDF via Syncfusion toolset switch (Path.GetExtension(filename).ToLower()) { case ".pdf": ScanPDF scanPDF = new ScanPDF(); scanPageStatus = scanPDF.Process(filename, ref scannedRecord); //ScanPDF.Process(filename); break; case ".jpg": case ".tiff": // Scan Page uses the Accusoft.SmartZoneOCRSdk to process .jpg source files. // Needs to return "scanPageStatus, if used in the future var result = ScanImage.Main(filename); //if (result.ToString().Length > 0) {} break; default: break; } if (scanPageStatus.rc == 0) { // Persist record in the database, note in alert log if there are failed scans if (scannedRecord.FailedMatches == 0) { scanPageStatus.rc = 0; scanPageStatus.statusMessage = String.Format("File {0} scanned and data persisted to database", filename); } else if (scannedRecord.FailedMatches <= GetConstants.ScanErrorLimit()) { scanPageStatus.rc = 1; scanPageStatus.statusMessage = String.Format("Recorded {0} scan failures for source file {1}", scannedRecord.FailedMatches.ToString(), filename); } else { scanPageStatus.rc = -1; scanPageStatus.statusMessage = String.Format("Scan failures of {0} too high. No data saved for source file {1}", scannedRecord.FailedMatches.ToString(), filename); } if (scanPageStatus.rc >= 0) { // Persist data to database //var test = scannedRecord.ScannedFileName. scannedRecord.ScannedFileName = Path.GetFileName(filename); scannedRecord.ScanDate = DateTime.Now; // Will need to ensure this is correct time zone *** GPA db.ScannedRecords.InsertOnSubmit(scannedRecord); db.SubmitChanges(); } } //ss.Dispose(); } else { scanPageStatus.rc = 1; scanPageStatus.statusMessage = String.Format("Source file {0} null or empty", filename); } } catch (Exception ex) { scanPageStatus.rc = -1; scanPageStatus.statusMessage = String.Format("Exception {0} when running OCR on source file {1}", ex, filename); } return(scanPageStatus); }
private void ValidateScannedData(ref ScannedRecord scannedRecord, ref int failedValidations, ref string failedValidationRecords) { // Validate the data based on expected calculations if (!ValueWithinRange(((scannedRecord.Weekday00_04_Units + scannedRecord.Weekday00_04_Losses) * scannedRecord.Weekday00_04_CostPerUnit), (scannedRecord.Weekday00_04_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekday00_04:"; } if (!ValueWithinRange(((scannedRecord.Weekday04_08_Units + scannedRecord.Weekday04_08_Losses) * scannedRecord.Weekday04_08_CostPerUnit), (scannedRecord.Weekday04_08_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekday08_12:"; } if (!ValueWithinRange(((scannedRecord.Weekday08_12_Units + scannedRecord.Weekday08_12_Losses) * scannedRecord.Weekday08_12_CostPerUnit), (scannedRecord.Weekday08_12_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekday08_12:"; } if (!ValueWithinRange(((scannedRecord.Weekday12_16_Units + scannedRecord.Weekday12_16_Losses) * scannedRecord.Weekday12_16_CostPerUnit), (scannedRecord.Weekday12_16_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekday12_16:"; } if (!ValueWithinRange(((scannedRecord.Weekday16_20_Units + scannedRecord.Weekday16_20_Losses) * scannedRecord.Weekday16_20_CostPerUnit), (scannedRecord.Weekday16_20_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekday16_20:"; } if (!ValueWithinRange(((scannedRecord.Weekday20_24_Units + scannedRecord.Weekday20_24_Losses) * scannedRecord.Weekday20_24_CostPerUnit), (scannedRecord.Weekday20_24_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekday20_24:"; } if (!ValueWithinRange(((scannedRecord.Weekend00_04_Units + scannedRecord.Weekend00_04_Losses) * scannedRecord.Weekend00_04_CostPerUnit), (scannedRecord.Weekend00_04_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekend00_04:"; } if (!ValueWithinRange(((scannedRecord.Weekend04_08_Units + scannedRecord.Weekend04_08_Losses) * scannedRecord.Weekend04_08_CostPerUnit), (scannedRecord.Weekend04_08_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekend04_08:"; } if (!ValueWithinRange(((scannedRecord.Weekend08_12_Units + scannedRecord.Weekend08_12_Losses) * scannedRecord.Weekend08_12_CostPerUnit), (scannedRecord.Weekend08_12_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekend08_12:"; } if (!ValueWithinRange(((scannedRecord.Weekend12_16_Units + scannedRecord.Weekend12_16_Losses) * scannedRecord.Weekend12_16_CostPerUnit), (scannedRecord.Weekend12_16_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekend12_16:"; } if (!ValueWithinRange(((scannedRecord.Weekend16_20_Units + scannedRecord.Weekend16_20_Losses) * scannedRecord.Weekend16_20_CostPerUnit), (scannedRecord.Weekend16_20_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekend16_20:"; } if (!ValueWithinRange(((scannedRecord.Weekend20_24_Units + scannedRecord.Weekend20_24_Losses) * scannedRecord.Weekend20_24_CostPerUnit), (scannedRecord.Weekend20_24_Charge * 100), ref failedValidations)) { failedValidationRecords += "Weekend20_24:"; } if (!ValueWithinRange((scannedRecord.LCfixedUnits * scannedRecord.LCfixedCostPerUnit), scannedRecord.LCfixedCharge, ref failedValidations)) // Rounding will result in error here { failedValidationRecords += "LCfixed:"; } if (!ValueWithinRange((scannedRecord.LCmaxDemandUnits * scannedRecord.LCmaxDemandCostPerUnit), (scannedRecord.LCmaxDemandCharge), ref failedValidations)) { failedValidationRecords += "LCmaxDemand:"; } // GPA*** Note that this value (1000) is from the actual bill. May need to scan this in in future if (!ValueWithinRange((scannedRecord.LCassessedCapacityUnits * scannedRecord.LCassessedCapacityPerUnit * 1000), (scannedRecord.LCassessedCapacityCharge * 100), ref failedValidations)) { failedValidationRecords += "LCassessedCapacity:"; } // Other Charges if (!ValueWithinRange((scannedRecord.AdminCharge_Units * scannedRecord.AdminCharge_Rate), (scannedRecord.AdminCharge_Charge), ref failedValidations)) { failedValidationRecords += "AdminCharge:"; } if (!ValueWithinRange((scannedRecord.ECLevies_Units * scannedRecord.ECLevies_Rate), (scannedRecord.ECLevies_Charge * 100), ref failedValidations)) { failedValidationRecords += "ECLevies:"; } //decimal _total = 0.00M; //_total = scannedRecord.Weekday00_04_Charge + scannedRecord.Weekday04_08_Charge; }
private void ScanEnergyCharges(ref ScannedRecord scannedRecord, ref int failedMatches) { int _unitsField = 2; int _lossesField = 3; int costPerUnitField = 4; int _chargeField = 5; string _resultString = ""; Regex _regex = new Regex(@"(Weekdays \x280000).*(Weekdays \x280400)"); //_resultString = _regex.Match(_scannedText).ToString().OnlyDigits().TrimAndReduce(); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekday00_04_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekday00_04_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekday00_04_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekday00_04_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekdays \x280400).*(Weekdays \x280800)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekday04_08_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekday04_08_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekday04_08_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekday04_08_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekdays \x280800).*(Weekdays \x281200)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekday08_12_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekday08_12_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekday08_12_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekday08_12_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekdays \x281200).*(Weekdays \x281600)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekday12_16_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekday12_16_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekday12_16_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekday12_16_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekdays \x281600).*(Weekdays \x282000)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekday16_20_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekday16_20_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekday16_20_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekday16_20_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekdays \x282000).*(Energy Totals)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekday20_24_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekday20_24_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekday20_24_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekday20_24_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); /// Weekend _regex = new Regex(@"(Weekends \x280000).*(Weekends \x280400)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekend00_04_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekend00_04_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekend00_04_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekend00_04_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekends \x280400).*(Weekends \x280800)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekend04_08_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekend04_08_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekend04_08_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekend04_08_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekends \x280800).*(Weekends \x281200)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekend08_12_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekend08_12_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekend08_12_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekend08_12_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekends \x281200).*(Weekends \x281600)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekend12_16_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekend12_16_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekend12_16_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekend12_16_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekends \x281600).*(Weekends \x282000)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekend16_20_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekend16_20_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekend16_20_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekend16_20_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); _regex = new Regex(@"(Weekends \x282000).*(Energy Totals)"); _resultString = _regex.Match(_scannedText).ToString().ReduceForDecimals(); scannedRecord.Weekend20_24_Units = ReturnDecimal(_resultString, ' ', ref failedMatches, _unitsField); scannedRecord.Weekend20_24_Losses = ReturnDecimal(_resultString, ' ', ref failedMatches, _lossesField); scannedRecord.Weekend20_24_CostPerUnit = ReturnDecimal(_resultString, ' ', ref failedMatches, costPerUnitField, 3); scannedRecord.Weekend20_24_Charge = ReturnDecimal(_resultString, ' ', ref failedMatches, _chargeField); }