private Strata8.Wireless.Cdr.Rating.Record98 ProcessRecordType98(string line) { // construct the record Record98 r = new Record98(line); return(r); }
/// <summary> /// method used to create the CIBER trailer Record type 98 /// </summary> /// <param name="r1"></param> /// <param name="cri"></param> /// <returns></returns> public Record98 CreateBatchTrailerRecord( ) { /// example = "9807052102906358854930002000000000399031015200 0002000000000399 01208040784 C0000100"; /// RecordType = 98 /// CreationDate = 070521 /// BatchSequenceNumber = 029 /// SendingCarrierSID/BID : 10789 //OnWaves SID/BID /// ReceivingCarrierSID/BID : 00133 /// Total Records in batch : 0002 /// Batch total charges & taxes : 000000000399 /// SettlePeriod : 031015 /// clearinghouseid : 0 // from a Billing Vendor or a Carrier /// Batch total charges and taxes sign: 0 /// original total charges and taxes sign : 0 /// system reserved filler: 3N : Blank fill /// original total number of records: 4N : 0002 /// original total charges and taxes: 12N : 000000000399 /// system reserved filler : 66-73 8N : CIBERNET USE Blank fill /// currency type : 74-75 2N : 01 /// local carrier reserved : 20N ( OPTIONAL ) /// System reserved filler : 105N ( OPTIONAL ) /// // create our filler here string carrierFiller = String.Empty.PadRight(20, this.blank_pad); string systemFiller = String.Empty.PadRight(105, this.blank_pad); string filler = carrierFiller + systemFiller; StringBuilder sb = new StringBuilder("98" + cri.BatchCreationDate + cri.BatchSequenceNumber + cri.SendingCarrierSidBid + cri.ReceivingCarrierSidBid); sb.Append(cri.TotalNumberOfRecordsInBatchString + cri.BatchTotalChargesAndTaxesString + cri.SettlementPeriod + cri.ClearinghouseId); // note the blanks have to be in here, need to make these constants and add them here sb.Append("00 " + cri.TotalNumberOfRecordsInBatchString + cri.BatchTotalChargesAndTaxesString + " 01"); sb.Append(filler); Ciber.Record98 r98 = new Record98(sb.ToString()); //write it to a file for now //cfw.WriteToFile( r98.ToCiberStringFormat() ); return(r98); }
public void ProcessTheFile(string fileName) { // MAF only supports type01, 22 and 98. m_logger.WriteToLogFile("-NFORMATIONAL::MAFFileReader::ProcessTheFile():Entered"); string type01 = "01"; string type02 = "02"; string type22 = "22"; string type32 = "32"; string type97 = "97"; string type98 = "98"; try { using (StreamReader sr = new StreamReader(fileName)) { char[] buff = new char[2]; int recordCount = 1; //string str = sr.ReadToEnd(); while ((sr.Read(buff, 0, 2) != 0)) { string recordType = buff[0].ToString() + buff[1].ToString(); if (recordType.Equals(type01)) { // type 01, 02 record length = 200 // read the rest of the type 01 record char[] buff1 = new char[200]; // first two elements are 01 sr.Read(buff1, 2, 198); buff1[0] = buff[0]; buff1[1] = buff[1]; StringBuilder sb = new StringBuilder(); // process type 01 record foreach (char c in buff1) { sb.Append(c.ToString()); } Record01 r01 = new Record01(sb.ToString()); //WriteToFile(@"d:\apps\data\test.dat", sb.ToString() ); } else if (recordType.Equals(type22)) { // type 22, record length = 547 // read the rest of the type 01 record char[] buff22 = new char[547]; sr.Read(buff22, 2, 545); buff22[0] = buff[0]; buff22[1] = buff[1]; StringBuilder sb = new StringBuilder(); // process type 22 record foreach (char c in buff22) { sb.Append(c.ToString()); } Record22 r22 = new Record22(sb.ToString()); // update the database with the following parameters for reporting UpdateDb(r22); // FileWriter.Instance.WriteToLogFile( sb.ToString() ); } else if (recordType.Equals(type32)) { // type 32, record length = 567 } else if (recordType.Equals(type02)) { // type 22, record length = 200 } else if (recordType.Equals(type97)) { // type 97, record length = 200 } else if (recordType.Equals(type98)) { // type 98, record length = 200 // read the rest of the type 01 record char[] buff98 = new char[200]; sr.Read(buff98, 2, 198); buff98[0] = buff[0]; buff98[1] = buff[1]; StringBuilder sb = new StringBuilder(); // process type 22 record foreach (char c in buff98) { sb.Append(c.ToString()); } Record98 r98 = new Record98(sb.ToString()); // WriteToFile( "test", sb.ToString() ); break; } else { // } // increment our record count recordCount++; } // while loop - end of file } //using sr } //try catch (SystemException se) { m_logger.WriteToLogFile("-NEXCEPTION::MAFFileReader::ProcessTheFile():ECaught:" + se.Message + se.StackTrace); } m_logger.WriteToLogFile("-NFORMATIONAL::MAFFileReader::ProcessTheFile()Exiting"); }// ReadTheFile
} // public void CloseDataConn( ref SqlConnection dataConnection ) /// <summary> /// private method to parse the dids in the file /// </summary> /// <param name="fileName"></param> /// <returns></returns> private ArrayList ReadTheFile(string fileName) { // make the array size (number of cdrs per file ) configurable System.Collections.ArrayList theControls = new System.Collections.ArrayList(1000); char[] sep = new char[] { ',' }; char[] trim = new char[] { ' ' }; int lineNumber = 1; try { using (StreamReader sr = new StreamReader(fileName)) { String line; bool callHit = false; while ((line = sr.ReadLine()) != null) { try { //// parse the line //string[] controls = line.Split(sep); //if (controls.GetLength(0) < 0) //{ // // we have a non-data line -- header or footer... so skip it // continue; //} //string did = controls[0].Trim().Replace(" ", String.Empty); //// cache the record //theControls.Add( did ); string recordType = line.Substring(0, 2); switch (recordType) { case ("01"): { Console.WriteLine("Type 01 RecordType : Batch Header Record"); Record01 r = ProcessRecordType01(line); // let us look and see Console.WriteLine(r.ToString()); break; } case ("02"): { Console.WriteLine("Type 01 RecordType : ClearingHouse Batch Header Record"); Record02 r = ProcessRecordType02(line); // let us look and see Console.WriteLine(r.ToString()); break; } case ("22"): { Record22 r = new Record22(line); if (r.CallDate.Equals("110816")) { Console.WriteLine("Type 22 RecordType : Air and Toll Charges Record"); Console.WriteLine(r.ToString()); callHit = true; } //look and see for now //Console.WriteLine(r.ToString()); break; } case ("52"): { Console.WriteLine("Type 52 RecordType : Billing OCC Charge Record"); //Record52 r = new Record52(line); ////look and see for now //Console.WriteLine(r.ToString()); break; } case ("98"): { Console.WriteLine("Type 98 RecordType : Batch Trailer Record"); Record98 r = ProcessRecordType98(line); // let us look and see if (callHit) { Console.WriteLine(r.ToString()); callHit = false; } break; } default: { break; } } //Console.WriteLine(line.ToString()); lineNumber++; } catch (System.Exception ex) { string errorMsg = "Error in File>" + fileName + " Line>" + lineNumber; if (line != null) {// add the line information if available errorMsg += "Line>" + line; } LogFileError(errorMsg + "\r\n" + ex.Message + "\r\n" + ex.StackTrace); } } } }// try catch (Exception e) { LogFileError(e.Message + "\r\n" + e.StackTrace); }// catch return(theControls); }// private void ParseTheDIDs()
/// <summary> /// method used to create the CIBER trailer Record type 98 /// </summary> /// <param name="r1"></param> /// <param name="cri"></param> /// <returns></returns> public Record98 CreateBatchTrailerRecord( ) { /// example = "9807052102906358854930002000000000399031015200 0002000000000399 01208040784 C0000100"; /// RecordType = 98 /// CreationDate = 070521 /// BatchSequenceNumber = 029 /// SendingCarrierSID/BID : 10789 //OnWaves SID/BID /// ReceivingCarrierSID/BID : 00133 /// Total Records in batch : 0002 /// Batch total charges & taxes : 000000000399 /// SettlePeriod : 031015 /// clearinghouseid : 0 // from a Billing Vendor or a Carrier /// Batch total charges and taxes sign: 0 /// original total charges and taxes sign : 0 /// system reserved filler: 3N : Blank fill /// original total number of records: 4N : 0002 /// original total charges and taxes: 12N : 000000000399 /// system reserved filler : 66-73 8N : CIBERNET USE Blank fill /// currency type : 74-75 2N : 01 /// local carrier reserved : 20N ( OPTIONAL ) /// System reserved filler : 105N ( OPTIONAL ) /// // create our filler here string carrierFiller = String.Empty.PadRight(20, this.blank_pad); string systemFiller = String.Empty.PadRight(105, this.blank_pad); string filler = carrierFiller + systemFiller; StringBuilder sb = new StringBuilder( "98" + cri.BatchCreationDate + cri.BatchSequenceNumber + cri.SendingCarrierSidBid + cri.ReceivingCarrierSidBid); sb.Append( cri.TotalNumberOfRecordsInBatchString + cri.BatchTotalChargesAndTaxesString + cri.SettlementPeriod + cri.ClearinghouseId ); // note the blanks have to be in here, need to make these constants and add them here sb.Append("00 " + cri.TotalNumberOfRecordsInBatchString + cri.BatchTotalChargesAndTaxesString + " 01"); sb.Append(filler); Ciber.Record98 r98 = new Record98( sb.ToString() ); //write it to a file for now //cfw.WriteToFile( r98.ToCiberStringFormat() ); return r98; }