private Strata8.Wireless.Cdr.Rating.Record22 ProcessRecordType22(string line) { // construct the record Record22 r = new Record22(line); return(r); }
/// <summary> /// method used to create a CDR based on the MSC/OMC CDR and the /// CIBER record type 22. /// </summary> /// <param name="oCdr"></param> /// <param name="r22"></param> /// <returns></returns> public Bcdr CreateCdr(OmcCdr oCdr, Record22 r22) { // populate the bworks cdr here and return it Bcdr bCdr = new Bcdr(oCdr); return(bCdr); }
}// private void LogFileMsg(string msg) private void UpdateDb(Record22 r22) { //add code for the update db method here // update the database with the following parameters // r22.CalledNumberDigits, r22.CallDate, r22.ServingPlace, r22.ServingStateProvince, r22.CallerId, r22.AirConnectTime, // r22.AirChargeableTime, r22.InitialCellSite, r22.TollChargeableTime, r22.Msid, r22.MsisdnMdn, r22.CallDirection, r22.EsnUimidImeiMeid m_dbMgr.InsertMafRecord(r22); }
public void AddSidBidRecord(string sidBid, Record22 r22) { // if our sidbid exists, add to the list if (m_sidBidRecords.ContainsKey(sidBid)) { List <Record22> rList = (System.Collections.Generic.List <Record22>)m_sidBidRecords[sidBid]; rList.Add(r22); } else { List <Record22> rList = new List <Record22>(); rList.Add(r22); m_sidBidRecords.Add(sidBid, rList); } }
private static Hashtable m_picoCiberData = new Hashtable(); // ( [servingcarrier], ( hashtable[homecarrier], r22 ] )) public void AddRecordForServingSidBid(string servingCarrierSidBid, string homeCarrierSidBid, CiberRecordInfo cri, Record22 r22) { // is there already data for this servingCarrierSidBid if (m_picoCiberData.ContainsKey(servingCarrierSidBid)) { // grab the hashtable and add the data for this serving carrier sid bid SidBidData sidBidData = (SidBidData)m_picoCiberData[servingCarrierSidBid]; sidBidData.AddSidBidRecord(homeCarrierSidBid, r22); sidBidData.AddSidBidFileInfo(homeCarrierSidBid, cri); // no need to do this: hashtable is updated from above // m_picoCiberData.Add(servingCarrierSidBid, data); } else { // create a new hashtable and list for the data SidBidData data = new SidBidData(); data.AddSidBidRecord(homeCarrierSidBid, r22); data.AddSidBidFileInfo(homeCarrierSidBid, cri); // add the hashtable with data to our site/pico hashtable m_picoCiberData.Add(servingCarrierSidBid, data); } }
/// <summary> /// method to convert the OMC CDR to a CIBER Type 22 record /// need to keep track of the total charges and taxes here /// </summary> /// <param name="cdr"></param> public void ProcessCallRecord(OmcCdr cdr) { // 22 0 00 000 01151 2 912223280900000 10 912223280900000 1 0610328563400000000 33333 0000000099 0 00000000000000000000000705022220000000000000000010912223280900000000000000000000000000000000000000001 029000000000189900000000000212127000100000051021000000009900000000000000 000J INCOMING CLUSAJACKSON OHUSA00000000000000000000000000000000000000000000000000000000000000000000000000208040784PIKE 0188 // 220000000115129122232809000001091222328090000010610328563400000000333330000000099000000000000000000000000705022220000000000000000010912223280900000000000000000000000000000000000000001 // record type : 22 // return code : 0 // ciber return reason code 2N : 00 // invalidfieldidentifier 3N : 000 // homecarriersidbid 5N : 01151 // msid indicator 1N = 2 // msid 15N : 912223280900000 // MSISDN/MDN length 2N : 10 // MSISDN/MDN 15N : 912223280900000 // ESN/UIMID/EIMIE/MEID indicator 1N :1 // ESN/UIMID/EIMIE/MEID 19N : 0610328563400000000 // ServingCarrierSidBid 5N :33333 // TotalChargesAndTaxes 10N : 0000000099 /// system reserved filler1 1N : BlankFILL /// total state province taxes 10N // update our running total // cri.BatchTotalChargesAndTaxes // create a CIBER record // for now it is a type 22 record Record22 r22 = new Record22(); r22.ReturnCode = "0"; r22.CiberRecordReturnReasonCode = "00"; r22.InvalidFieldIndentifier = "000"; r22.MsidIndicator = "2"; // MIN baby // if 911 call, don't process it if (cdr.A_Feature_Bits.Equals("EMERGENCY")) { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + "OmcToCiberCdrConverter::ConvertToCiber():911CallDetectedForCDRSeqNum:" + cdr.SequenceNumber + "\r\n"); return; } try { // if we have a *good* call, then create the CIBER record and for now if it is *bad* call // we log it to the log file. Figure out what to do with it, create the CIBER or not. if ((cdr.disc_code.Equals("201")) || (cdr.disc_code.Equals("202"))) { r22.CallCompletionIndicator = "2"; r22.CallTerminationIndicator = "2"; // 2 = Normal } else { // double check this r22.CallCompletionIndicator = "1"; r22.CallTerminationIndicator = "3"; // 3 = unknown, 4=incomplete call cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + "OmcToCiberCdrConverter::ConvertToCiber():InvalidDisconnectCode-CallNotTerminatedForCDRSeqNum:" + cdr.SequenceNumber + "\r\n"); return; } // look for the mobile party in our scenario we will always have one mobile unit and one // landline, we always grab mobile unit parameters. // MO Case: if (cdr.a_party_type.Equals("1")) { // grab the a party mobile params // MIN r22.Msid = cdr.a_party_num; // MDN ** double check this and might change it to be the cdr.ocpn field ** r22.MsisdnMdnLength = cdr.o_msisdn.Length.ToString(); r22.MsisdnMdn = cdr.o_msisdn; if (cdr.OriginatingEsn.Length == 0) { // ESN/UIMID/IMEI/MEID // If the ESN/IMEI/MEID Indicator equals “0,” // then the ESN/IMEI/MEID field must be zero filled. // If the ESN/IMEI/MEID Indicator equals 1, 2, or 3, then the // ESN/IMEI/MEID field must contain a value within the range of accepted values specified above. r22.EsnUimidImeiMeidIndicator = "0"; // ESN r22.EsnUimidImeiMeid = "000000"; } else { r22.EsnUimidImeiMeidIndicator = "1"; // ESN // add code to convert this according to Appendix B UInt32 starEsn = Convert.ToUInt32(cdr.OriginatingEsn, 16); string esn = CalculateEsnValue(starEsn); r22.EsnUimidImeiMeid = esn; } //The value of the Caller ID is dependent on the call direction. //•For Mobile Originated Calls (Call Direction equals “1”), the Caller ID is equal to the Mobile Directory Number. // which in our case is the following field in the type 22 record r22.CallerIdLength = r22.MsisdnMdnLength; r22.CallerId = r22.MsisdnMdn; // For Mobile Originated Calls, the Called Number Digits represents the Dialed Digits. r22.CalledNumberLength = cdr.b_party_digits.Length.ToString(); r22.CalledNumberDigits = cdr.b_party_digits; // MO no TLDN in our scenario r22.TldnLength = "0"; r22.Tldn = "0"; // set our call direction : mobile roamer originated = 1, mobile roamer terminated = 2 r22.CallDirection = "1"; } else { // MT Case: // assume that b party is the mobile party and we grab the b party mobile params // grab the b party mobile params // MIN r22.Msid = cdr.b_party_num; // MDN r22.MsisdnMdnLength = cdr.t_msisdn.Length.ToString(); r22.MsisdnMdn = cdr.t_msisdn; if (cdr.TerminatingEsn.Length == 0) { // ESN/UIMID/IMEI/MEID // If the ESN/IMEI/MEID Indicator equals “0,” // then the ESN/IMEI/MEID field must be zero filled. // If the ESN/IMEI/MEID Indicator equals 1, 2, or 3, then the // ESN/IMEI/MEID field must contain a value within the range of accepted values specified above. r22.EsnUimidImeiMeidIndicator = "0"; // ESN r22.EsnUimidImeiMeid = "000000"; } else { r22.EsnUimidImeiMeidIndicator = "1"; // ESN // add code to convert this according to Appendix B UInt32 starEsn = Convert.ToUInt32(cdr.TerminatingEsn, 16); string esn = CalculateEsnValue(starEsn); r22.EsnUimidImeiMeid = esn; } //•For Mobile Terminated Calls (Call Direction equals “2”), the Caller ID is the number of the calling party. r22.CallerIdLength = cdr.a_party_num.Length.ToString(); r22.CallerId = cdr.a_party_num; // For Mobile Terminated Calls (Call Direction equals “2”), the Called Number Digits value MUST equal // the Mobile Directory Number value. r22.CalledNumberLength = r22.MsisdnMdnLength; //cdr.t_msisdn.Length.ToString(); r22.CalledNumberDigits = r22.MsisdnMdn; // ** when we have Verizon phones it should be :** cdr.t_msisdn; // landline to Mobile, MT r22.TldnLength = cdr.a_party_digits.Length.ToString(); r22.Tldn = cdr.A_Party_Digits; // set our call direction : mobile roamer originated = 1, mobile roamer terminated = 2 r22.CallDirection = "2"; } // this field is used to indicate the home carrier of the roaming mobile as indicated by the MSID. // The MSID must be valid for the specified home carrier SID/BID. // look up the HomeCarrierSIDBID based on the MSID CarrierInfo ci = GetHomeCarrierSidBid(r22.Msid); if (ci.SidBid.Equals(TechDataEnums.SIDBID_NOT_FOUND.ToString())) { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + "OmcToCiberCdrConverter::ProcessCallRecord():SIDBIDNotFoundForMSID: " + r22.Msid); return; } else { r22.HomeCarrierSidBid = ci.SidBid; } // this is the On-Wave SID/BID, use the same one that is in our header r22.ServingCarrierSidBid = cri.SendingCarrierSidBid; // yymmdd r22.CallDate = cdr.answer.Substring(2, 2) + cdr.answer.Substring(5, 2) + cdr.answer.Substring(8, 2); // This field is used to record the routing number associated with a ported or pooled MDN. r22.LocationRoutingNumberLengthIndicator = "0"; r22.LocationRoutingNumber = "0"; r22.CurrencyType = "1"; // original Batch Sequence Number r22.OriginalBatchSequenceNumber = cri.BatchSequenceNumber; r22.InitialCellSite = cdr.cell_id; r22.TimeZoneIndicator = "99"; //=08 Pacific, for this test use the unknown value of "99"; r22.DaylightSavingIndicator = "0"; r22.MessageAccountingDigits = "0"; // This field is used to record the time that the mobile unit successfully connected to a wireless system. // HHMMSS: HH = 00-23, MM = 00-59, SS = 00-59 r22.AirConnectTime = cdr.answer.Substring(11, 2) + cdr.answer.Substring(14, 2) + cdr.answer.Substring(17, 2); // fill these in : ( disc time - seize time ) // This field is used to record the billable elapsed time used to calculate air time charges string ChargeableTime = CalculateAirChargeTime(cdr.DisconnectTime, cdr.SeizeTime); r22.AirChargeableTime = ChargeableTime; // "0001030"; // contains the billable elapsed time in MMMM=0000-9999, SS=00-59 // This field is used to record the elapsed time associated with a call. // MMMMSS: MMMM = 0000-9999, SS = 00-59 r22.AirElapsedTime = ChargeableTime; // "000545"; // this should be disconnect - answer // this needs to be determined r22.AirRatePeriod = "02"; r22.AirMultiRatePeriod = "1";// 1 = single rate period // This field is used to record the charges associated with the air time portion of a call. // This field must not contain any taxes; $$$$$$$$¢¢ format. string rAirChargeTime = cr.CalculateAirTimeChargeAmount(r22.AirChargeableTime, ci.Carrier); r22.AirCharge = rAirChargeTime; // "99"; // ** calculate this as well r22.OtherChargeNumberOneIndicator = "0"; r22.OtherChargeNumberOne = "0"; r22.PrintedCall = "0"; // determine how we determine if it is fraudulent or not r22.FraudIndicator = "00"; r22.FraudSubIndicator = "0"; // special condition when it is a zero, properties get/set take care of this r22.SpecialFeaturesUsed = "0"; // ** fix this to the following // this field contains the service call descriptor, section 8 table 18 OR the geographic name of the // called place. // called place depends on the call direction // for MO, calledDirection=1, the called place is the place that the mobile sub // is calling // for MT, calledDirection=2, the called place is the place where the mobile sub answered the call if (r22.CallDirection.Equals("2")) { // MT CALLs // Mobile terminated calls all MT calls are airtime only charges Rate = 1.49 r22.CalledPlace = "INCOMING"; r22.CalledStateProvince = "CL"; r22.CalledCountry = "USA"; // **check to see if we are going to make this International r22.SpecialFeaturesUsed = "J"; // no toll r22.TollTariffDescriptor = "00"; // na r22.TollRateClass = "0"; // 0-when no toll associated with this call // No TOLL CHARGES for MT r22.TollConnectTime = "000000"; r22.TollElapsedTime = "000000"; r22.TollChargeableTime = r22.TollElapsedTime; r22.TollRatePeriod = "00"; // not applicable r22.TollMultiRatePeriod = "0"; // not applicable r22.TollRatingPointLengthIndicator = "0"; r22.TollRatingPoint = "0"; r22.TollCharge = "00"; // } else if (r22.CallDirection.Equals("1")) { // MO CALLs // check for 411 call ** add others here or in separate function // see section 8 table 18 if (r22.CalledNumberDigits.Equals("411000000000000")) { // MO:411 r22.CalledPlace = "DIR ASST"; r22.CalledStateProvince = "CL"; r22.CalledCountry = "USA"; r22.SpecialFeaturesUsed = "0"; // shows no toll charges applied r22.PrintedCall = "411"; // rated as local/ld call including toll r22.TollTariffDescriptor = "02"; // interstate interlata r22.TollRateClass = "1"; // 0-when no toll associated with this call r22.TollConnectTime = r22.AirConnectTime; r22.TollElapsedTime = r22.AirElapsedTime; r22.TollChargeableTime = r22.AirChargeableTime; r22.TollRatePeriod = "01";// day, 02=evening, 03=night, 05=latenight, 06 =weekend r22.TollMultiRatePeriod = "1"; r22.TollRatingPointLengthIndicator = "00"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 string rTollChargeTime = cr.CalculateLocalLdTollChargeAmount(r22.TollChargeableTime); r22.TollCharge = rTollChargeTime; } else if (r22.CalledNumberDigits.StartsWith("8")) { // MO:TOLL FREE r22.CalledPlace = "TOLL FREE"; r22.CalledStateProvince = "CL"; r22.CalledCountry = "USA"; r22.SpecialFeaturesUsed = "J"; r22.PrintedCall = "TOLL FREE"; r22.TollTariffDescriptor = "00"; // interstate interlata r22.TollRateClass = "0"; // 0-when no toll associated with this call // *** figure out charges for TOLL FREE r22.TollConnectTime = "000000"; r22.TollElapsedTime = "000000"; r22.TollChargeableTime = r22.TollElapsedTime; // no toll r22.TollRatePeriod = "00"; // not applicable r22.TollMultiRatePeriod = "0"; // not applicable r22.TollRatingPointLengthIndicator = "0"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 r22.TollCharge = "00"; // no toll } else { // MO : International or Local/LD case // this should map to table 31 State/Province mapping NpaNxxData n = npaNxxRdr.GetNpaNxxInfo(r22.CalledNumberDigits.Substring(0, 6)); // check International scenario if (n.NpaNxx.Equals(String.Empty)) { // MO:International Rate = 1.49 AirTime + 0.80 Toll // International Call Scenario // add the international tables mapped to table 32 if (r22.CalledNumberDigits.Contains("0118522810")) { r22.CalledPlace = "Hong Kong"; r22.CalledStateProvince = "ZZ"; r22.CalledCountry = "HKG"; r22.SpecialFeaturesUsed = "D"; // International, but not required. // 01 = International : Originating from a NANP and terminating to Non-NANP // 15 = International : Originating from a NANP and terminating to NANP // 17 = International : Originating from a Non-NANP and terminating to NANP // 18 = International : Originating from and terminating to Non-NANP r22.TollTariffDescriptor = "01"; // see above r22.TollRateClass = "1"; // dial station, normal completed, 0-when no toll associated with this call // toll charges r22.TollConnectTime = r22.AirConnectTime; r22.TollElapsedTime = r22.AirElapsedTime; r22.TollChargeableTime = r22.AirChargeableTime; r22.TollRatePeriod = "01";// day, 02=evening, 03=night, 05=latenight, 06 =weekend r22.TollMultiRatePeriod = "1"; r22.TollRatingPointLengthIndicator = "00"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 string rTollChargeTime = cr.CalculateInternationalTollChargeAmount(r22.TollChargeableTime); r22.TollCharge = rTollChargeTime; } else if (r22.CalledNumberDigits.Contains("01181354")) { r22.CalledPlace = "Tokyo"; r22.CalledStateProvince = "ZZ"; r22.CalledCountry = "JPN"; r22.SpecialFeaturesUsed = "D"; // International, but not required. // 01 = International : Originating from a NANP and terminating to Non-NANP // 15 = International : Originating from a NANP and terminating to NANP // 17 = International : Originating from a Non-NANP and terminating to NANP // 18 = International : Originating from and terminating to Non-NANP r22.TollTariffDescriptor = "01"; // see above r22.TollRateClass = "1"; // dial station, normal completed, 0-when no toll associated with this call // toll charges r22.TollConnectTime = r22.AirConnectTime; r22.TollElapsedTime = r22.AirElapsedTime; r22.TollChargeableTime = r22.AirChargeableTime; r22.TollRatePeriod = "01";// day, 02=evening, 03=night, 05=latenight, 06 =weekend r22.TollMultiRatePeriod = "1"; r22.TollRatingPointLengthIndicator = "00"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 string rTollChargeTime = cr.CalculateInternationalTollChargeAmount(r22.TollChargeableTime); r22.TollCharge = rTollChargeTime; } else { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + "OmcToCiberCdrConverter::ProcessCallRecord():NPANXXNotFoundFor: " + r22.CalledNumberDigits); return; } } else { // MO:Local/LD case : Rate = 1.49 AirTime + 0.50 Toll r22.CalledPlace = n.City; r22.CalledStateProvince = n.State; r22.CalledCountry = "USA"; r22.SpecialFeaturesUsed = "0"; // none r22.TollTariffDescriptor = "02"; // interstate interlata r22.TollRateClass = "1"; // 0-when no toll associated with this call // toll charges r22.TollConnectTime = r22.AirConnectTime; r22.TollElapsedTime = r22.AirElapsedTime; r22.TollChargeableTime = r22.AirChargeableTime; r22.TollRatePeriod = "01";// day, 02=evening, 03=night, 05=latenight, 06 =weekend r22.TollMultiRatePeriod = "1"; r22.TollRatingPointLengthIndicator = "00"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 string rTollChargeTime = cr.CalculateLocalLdTollChargeAmount(r22.TollChargeableTime); r22.TollCharge = rTollChargeTime; } } } // description designed by the serving carrier and may range from a city name to a cell site or a trunk/circuit name. r22.ServingPlace = "Strata8"; // for MO , called direction =1, this is the state that is providing service to the mobile subscriber // for MT, this is the state/province providing service to the called party // must contain a value given in section 8 , table 31 r22.ServingStateProvince = "WA"; r22.ServingCountry = "USA"; r22.TollStateProvinceTaxes = "0"; r22.TollLocalTaxes = "0"; r22.TollNetworkCarrierId = "00000"; // this is other ** TBD ** see section 8, table 10, and appendix H // let's get the total state/province taxes associated with this record r22.TotalStateProvinceTaxes = r22.TollStateProvinceTaxes; r22.TotalLocalTaxes = r22.TollLocalTaxes; // total charges is the sum of all the charge fields and taxes in this ciber record // r22.TotalChargesAndTaxes = r22.TotalLocalTaxes + r22.TotalStateProvinceTaxes + r22.AirCharge + r22.TollCharge; // need to convert to an int int intTotalLocalTaxes = Convert.ToInt32(r22.TotalLocalTaxes); int intTotalStateProvinceTaxes = Convert.ToInt32(r22.TotalStateProvinceTaxes); int intAirCharge = Convert.ToInt32(r22.AirCharge); int intTollCharge = Convert.ToInt32(r22.TollCharge); int totalChargesAndTaxesThisRecord = intTotalLocalTaxes + intTotalStateProvinceTaxes + intAirCharge + intTollCharge; // calculate new charges for this file and maintain the total // cri.BatchTotalChargesAndTaxes = cri.BatchTotalChargesAndTaxes + ... for out trailer // increment the record count if a valid record cri.TotalNumberOfRecordsInBatch++; //cri.BatchTotalChargesAndTaxes = cri.BatchTotalChargesAndTaxes + r22. cri.BatchTotalChargesAndTaxes = cri.BatchTotalChargesAndTaxes + totalChargesAndTaxesThisRecord; r22.TotalChargesAndTaxes = totalChargesAndTaxesThisRecord.ToString(); // finally write this cdr to the file // cfw.WriteToFile(r22.ToCiberStringFormat()); } catch (ApplicationException ae) { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + ae.Message + "\r\n" + ae.StackTrace); } catch (IOException ioe) { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + ioe.Message + "\r\n" + ioe.StackTrace); } }
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 LogFileError(string msg) public void InsertMafRecord(Record22 r22) { //FileWriter.Instance.WriteToLogFile("-NFORMATIONAL::MAFDbMgr::InsertMafRecord()Entering"); StringBuilder commandStr = new StringBuilder("INSERT INTO SprintMafRecord "); commandStr.Append(" ( HomeCarrierSidBid, CalledNumber, CallDate, ServingPlace, ServingStateProvince, CallerId, AirConnectTime,"); commandStr.Append(" AirChargeableTime, InitialCellSite, TollChargeableTime, MsidIndicator, Msid, MsisdnMdnLength, Msisdn, EsnImeiIndicator,"); commandStr.Append(" CallDirection, EsnImei, ServingCarrierSidBid, CallCompletionIndicator, CallTerminationIndicator, CallerIdLength,"); commandStr.Append(" CalledNumberLength, Tldn, TldnLength, LocRoutingNumber, LocRoutingNumberLength, TimeZoneIndicator, DaylightSavingsIndicator,"); commandStr.Append(" AirElapsedTime, SpecialFeaturesUsed, TollConnectTime, TollNetworkCarrierId, TollElapsedTime, TollRatingPointLengthIndicator,"); commandStr.Append(" TollRatingPoint ) VALUES("); try { using (SqlConnection dataConnection = new SqlConnection(_connectionString)) { // add try catch block around setting up the command StringBuilder sb = new StringBuilder(); DateTime dt = new DateTime(DateTime.Now.Year, Convert.ToInt16(r22.CallDate.Substring(2, 2)), Convert.ToInt16(r22.CallDate.Substring(4, 2)), Convert.ToInt16(r22.AirConnectTime.Substring(0, 2)), Convert.ToInt16(r22.AirConnectTime.Substring(2, 2)), Convert.ToInt16(r22.AirConnectTime.Substring(4, 2))); // get the call direction String theCallDirection = GetCallDirection(r22.CallDirection); String theSpecialFeature = GetSpecialFeatures(r22.SpecialFeaturesUsed); // for now going to log the air connect time to find out why not converting time right (AM time, 00:00:00 AM ) //FileWriter.Instance.WriteToLogFile("MAFDbMgr::InsertMafRecord():CallDate:AirConnectTime:AirConnectTime(0,2):" + r22.CallDate + " : " + // r22.AirConnectTime + " : " + r22.AirConnectTime.Substring(0, 2) + " : " + " DateTime::" + dt.ToString()); sb.Append("'" + r22.HomeCarrierSidBid + "'"); sb.Append(",'" + r22.CalledNumberDigits + "'"); sb.Append(",'" + dt.ToString() + "'"); sb.Append(",'" + r22.ServingPlace + "'"); sb.Append(",'" + r22.ServingStateProvince + "'"); sb.Append(",'" + r22.CallerId + "'"); sb.Append(",'" + r22.AirConnectTime + "'"); sb.Append(",'" + r22.AirChargeableTime + "'"); sb.Append(",'" + r22.InitialCellSite + "'"); sb.Append(",'" + r22.TollChargeableTime + "'"); sb.Append(",'" + r22.MsidIndicator + "'"); sb.Append(",'" + r22.Msid + "'"); sb.Append(",'" + r22.MsisdnMdnLength + "'"); sb.Append(",'" + r22.MsisdnMdn + "'"); sb.Append(",'" + r22.EsnUimidImeiMeidIndicator + "'"); sb.Append(",'" + theCallDirection + "'"); sb.Append(",'" + r22.EsnUimidImeiMeid + "'"); sb.Append(",'" + r22.ServingCarrierSidBid + "'"); sb.Append(",'" + r22.CallCompletionIndicator + "'"); sb.Append(",'" + r22.CallTerminationIndicator + "'"); sb.Append(",'" + r22.CallerIdLength + "'"); sb.Append(",'" + r22.CalledNumberLength + "'"); sb.Append(",'" + r22.Tldn + "'"); sb.Append(",'" + r22.TldnLength + "'"); sb.Append(",'" + r22.LocationRoutingNumber + "'"); sb.Append(",'" + r22.LocationRoutingNumberLengthIndicator + "'"); sb.Append(",'" + r22.TimeZoneIndicator + "'"); sb.Append(",'" + r22.DaylightSavingIndicator + "'"); sb.Append(",'" + r22.AirElapsedTime + "'"); sb.Append(",'" + theSpecialFeature + "'"); sb.Append(",'" + r22.TollConnectTime + "'"); sb.Append(",'" + r22.TollNetworkCarrierId + "'"); sb.Append(",'" + r22.TollElapsedTime + "'"); sb.Append(",'" + r22.TollRatingPointLengthIndicator + "'"); sb.Append(",'" + r22.TollRatingPoint + "'" + ")"); // write the CDR to the database string tc = commandStr.ToString() + sb.ToString(); try { dataConnection.Open(); SqlCommand sqlCommand = new SqlCommand(tc, dataConnection); sqlCommand.CommandType = CommandType.Text; sqlCommand.ExecuteNonQuery(); } catch (Exception ex) { FileWriter.Instance.WriteToLogFile("MAFDbMgr::InsertMafRecord():ECaught:" + ex.Message + ex.StackTrace); } } //using } //try catch (Exception ex) { FileWriter.Instance.WriteToLogFile("MAFDbMgr::InsertMafRecord():ECaught:" + ex.Message + ex.StackTrace); } // FileWriter.Instance.WriteToLogFile("-NFORMATIONAL::MAFDbMgr::InsertMafRecord()Exiting"); }
} // 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 to convert the OMC CDR to a CIBER Type 22 record /// need to keep track of the total charges and taxes here /// </summary> /// <param name="cdr"></param> public void ProcessCallRecord(OmcCdr cdr ) { // 22 0 00 000 01151 2 912223280900000 10 912223280900000 1 0610328563400000000 33333 0000000099 0 00000000000000000000000705022220000000000000000010912223280900000000000000000000000000000000000000001 029000000000189900000000000212127000100000051021000000009900000000000000 000J INCOMING CLUSAJACKSON OHUSA00000000000000000000000000000000000000000000000000000000000000000000000000208040784PIKE 0188 // 220000000115129122232809000001091222328090000010610328563400000000333330000000099000000000000000000000000705022220000000000000000010912223280900000000000000000000000000000000000000001 // record type : 22 // return code : 0 // ciber return reason code 2N : 00 // invalidfieldidentifier 3N : 000 // homecarriersidbid 5N : 01151 // msid indicator 1N = 2 // msid 15N : 912223280900000 // MSISDN/MDN length 2N : 10 // MSISDN/MDN 15N : 912223280900000 // ESN/UIMID/EIMIE/MEID indicator 1N :1 // ESN/UIMID/EIMIE/MEID 19N : 0610328563400000000 // ServingCarrierSidBid 5N :33333 // TotalChargesAndTaxes 10N : 0000000099 /// system reserved filler1 1N : BlankFILL /// total state province taxes 10N // update our running total // cri.BatchTotalChargesAndTaxes // create a CIBER record // for now it is a type 22 record Record22 r22 = new Record22(); r22.ReturnCode = "0"; r22.CiberRecordReturnReasonCode = "00"; r22.InvalidFieldIndentifier = "000"; r22.MsidIndicator = "2"; // MIN baby // if 911 call, don't process it if (cdr.A_Feature_Bits.Equals("EMERGENCY")) { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + "OmcToCiberCdrConverter::ConvertToCiber():911CallDetectedForCDRSeqNum:" + cdr.SequenceNumber + "\r\n"); return; } try { // if we have a *good* call, then create the CIBER record and for now if it is *bad* call // we log it to the log file. Figure out what to do with it, create the CIBER or not. if ((cdr.disc_code.Equals("201")) || (cdr.disc_code.Equals("202"))) { r22.CallCompletionIndicator = "2"; r22.CallTerminationIndicator = "2"; // 2 = Normal } else { // double check this r22.CallCompletionIndicator = "1"; r22.CallTerminationIndicator = "3"; // 3 = unknown, 4=incomplete call cfw.WriteToLogFile(DateTime.Now.ToShortDateString()+"OmcToCiberCdrConverter::ConvertToCiber():InvalidDisconnectCode-CallNotTerminatedForCDRSeqNum:" + cdr.SequenceNumber + "\r\n"); return; } // look for the mobile party in our scenario we will always have one mobile unit and one // landline, we always grab mobile unit parameters. // MO Case: if (cdr.a_party_type.Equals("1")) { // grab the a party mobile params // MIN r22.Msid = cdr.a_party_num; // MDN ** double check this and might change it to be the cdr.ocpn field ** r22.MsisdnMdnLength = cdr.o_msisdn.Length.ToString(); r22.MsisdnMdn = cdr.o_msisdn; if (cdr.OriginatingEsn.Length == 0) { // ESN/UIMID/IMEI/MEID // If the ESN/IMEI/MEID Indicator equals “0,” // then the ESN/IMEI/MEID field must be zero filled. // If the ESN/IMEI/MEID Indicator equals 1, 2, or 3, then the // ESN/IMEI/MEID field must contain a value within the range of accepted values specified above. r22.EsnUimidImeiMeidIndicator = "0"; // ESN r22.EsnUimidImeiMeid = "000000"; } else { r22.EsnUimidImeiMeidIndicator = "1"; // ESN // add code to convert this according to Appendix B UInt32 starEsn = Convert.ToUInt32(cdr.OriginatingEsn, 16); string esn = CalculateEsnValue(starEsn); r22.EsnUimidImeiMeid = esn; } //The value of the Caller ID is dependent on the call direction. //•For Mobile Originated Calls (Call Direction equals “1”), the Caller ID is equal to the Mobile Directory Number. // which in our case is the following field in the type 22 record r22.CallerIdLength = r22.MsisdnMdnLength; r22.CallerId = r22.MsisdnMdn; // For Mobile Originated Calls, the Called Number Digits represents the Dialed Digits. r22.CalledNumberLength = cdr.b_party_digits.Length.ToString(); r22.CalledNumberDigits = cdr.b_party_digits; // MO no TLDN in our scenario r22.TldnLength = "0"; r22.Tldn = "0"; // set our call direction : mobile roamer originated = 1, mobile roamer terminated = 2 r22.CallDirection = "1"; } else { // MT Case: // assume that b party is the mobile party and we grab the b party mobile params // grab the b party mobile params // MIN r22.Msid = cdr.b_party_num; // MDN r22.MsisdnMdnLength = cdr.t_msisdn.Length.ToString(); r22.MsisdnMdn = cdr.t_msisdn; if (cdr.TerminatingEsn.Length == 0) { // ESN/UIMID/IMEI/MEID // If the ESN/IMEI/MEID Indicator equals “0,” // then the ESN/IMEI/MEID field must be zero filled. // If the ESN/IMEI/MEID Indicator equals 1, 2, or 3, then the // ESN/IMEI/MEID field must contain a value within the range of accepted values specified above. r22.EsnUimidImeiMeidIndicator = "0"; // ESN r22.EsnUimidImeiMeid = "000000"; } else { r22.EsnUimidImeiMeidIndicator = "1"; // ESN // add code to convert this according to Appendix B UInt32 starEsn = Convert.ToUInt32(cdr.TerminatingEsn, 16); string esn = CalculateEsnValue(starEsn); r22.EsnUimidImeiMeid = esn; } //•For Mobile Terminated Calls (Call Direction equals “2”), the Caller ID is the number of the calling party. r22.CallerIdLength = cdr.a_party_num.Length.ToString(); r22.CallerId = cdr.a_party_num; // For Mobile Terminated Calls (Call Direction equals “2”), the Called Number Digits value MUST equal // the Mobile Directory Number value. r22.CalledNumberLength = r22.MsisdnMdnLength; //cdr.t_msisdn.Length.ToString(); r22.CalledNumberDigits = r22.MsisdnMdn; // ** when we have Verizon phones it should be :** cdr.t_msisdn; // landline to Mobile, MT r22.TldnLength = cdr.a_party_digits.Length.ToString(); r22.Tldn = cdr.A_Party_Digits; // set our call direction : mobile roamer originated = 1, mobile roamer terminated = 2 r22.CallDirection = "2"; } // this field is used to indicate the home carrier of the roaming mobile as indicated by the MSID. // The MSID must be valid for the specified home carrier SID/BID. // look up the HomeCarrierSIDBID based on the MSID CarrierInfo ci = GetHomeCarrierSidBid(r22.Msid); if (ci.SidBid.Equals(TechDataEnums.SIDBID_NOT_FOUND.ToString() )) { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + "OmcToCiberCdrConverter::ProcessCallRecord():SIDBIDNotFoundForMSID: " + r22.Msid); return; } else { r22.HomeCarrierSidBid = ci.SidBid; } // this is the On-Wave SID/BID, use the same one that is in our header r22.ServingCarrierSidBid = cri.SendingCarrierSidBid; // yymmdd r22.CallDate = cdr.answer.Substring(2, 2) + cdr.answer.Substring(5, 2) + cdr.answer.Substring(8, 2); // This field is used to record the routing number associated with a ported or pooled MDN. r22.LocationRoutingNumberLengthIndicator = "0"; r22.LocationRoutingNumber = "0"; r22.CurrencyType = "1"; // original Batch Sequence Number r22.OriginalBatchSequenceNumber = cri.BatchSequenceNumber; r22.InitialCellSite = cdr.cell_id; r22.TimeZoneIndicator = "99"; //=08 Pacific, for this test use the unknown value of "99"; r22.DaylightSavingIndicator = "0"; r22.MessageAccountingDigits = "0"; // This field is used to record the time that the mobile unit successfully connected to a wireless system. // HHMMSS: HH = 00-23, MM = 00-59, SS = 00-59 r22.AirConnectTime = cdr.answer.Substring(11, 2) + cdr.answer.Substring(14, 2) + cdr.answer.Substring(17, 2); // fill these in : ( disc time - seize time ) // This field is used to record the billable elapsed time used to calculate air time charges string ChargeableTime = CalculateAirChargeTime(cdr.DisconnectTime, cdr.SeizeTime); r22.AirChargeableTime = ChargeableTime; // "0001030"; // contains the billable elapsed time in MMMM=0000-9999, SS=00-59 // This field is used to record the elapsed time associated with a call. // MMMMSS: MMMM = 0000-9999, SS = 00-59 r22.AirElapsedTime = ChargeableTime; // "000545"; // this should be disconnect - answer // this needs to be determined r22.AirRatePeriod = "02"; r22.AirMultiRatePeriod = "1";// 1 = single rate period // This field is used to record the charges associated with the air time portion of a call. // This field must not contain any taxes; $$$$$$$$¢¢ format. string rAirChargeTime = cr.CalculateAirTimeChargeAmount( r22.AirChargeableTime, ci.Carrier ); r22.AirCharge = rAirChargeTime; // "99"; // ** calculate this as well r22.OtherChargeNumberOneIndicator = "0"; r22.OtherChargeNumberOne = "0"; r22.PrintedCall = "0"; // determine how we determine if it is fraudulent or not r22.FraudIndicator = "00"; r22.FraudSubIndicator = "0"; // special condition when it is a zero, properties get/set take care of this r22.SpecialFeaturesUsed = "0"; // ** fix this to the following // this field contains the service call descriptor, section 8 table 18 OR the geographic name of the // called place. // called place depends on the call direction // for MO, calledDirection=1, the called place is the place that the mobile sub // is calling // for MT, calledDirection=2, the called place is the place where the mobile sub answered the call if ( r22.CallDirection.Equals("2") ) { // MT CALLs // Mobile terminated calls all MT calls are airtime only charges Rate = 1.49 r22.CalledPlace = "INCOMING"; r22.CalledStateProvince = "CL"; r22.CalledCountry = "USA"; // **check to see if we are going to make this International r22.SpecialFeaturesUsed = "J"; // no toll r22.TollTariffDescriptor = "00"; // na r22.TollRateClass = "0"; // 0-when no toll associated with this call // No TOLL CHARGES for MT r22.TollConnectTime = "000000"; r22.TollElapsedTime = "000000"; r22.TollChargeableTime = r22.TollElapsedTime; r22.TollRatePeriod = "00"; // not applicable r22.TollMultiRatePeriod = "0"; // not applicable r22.TollRatingPointLengthIndicator = "0"; r22.TollRatingPoint = "0"; r22.TollCharge = "00"; // } else if ( r22.CallDirection.Equals("1") ) { // MO CALLs // check for 411 call ** add others here or in separate function // see section 8 table 18 if (r22.CalledNumberDigits.Equals("411000000000000")) { // MO:411 r22.CalledPlace = "DIR ASST"; r22.CalledStateProvince = "CL"; r22.CalledCountry = "USA"; r22.SpecialFeaturesUsed = "0"; // shows no toll charges applied r22.PrintedCall = "411"; // rated as local/ld call including toll r22.TollTariffDescriptor = "02"; // interstate interlata r22.TollRateClass = "1"; // 0-when no toll associated with this call r22.TollConnectTime = r22.AirConnectTime; r22.TollElapsedTime = r22.AirElapsedTime; r22.TollChargeableTime = r22.AirChargeableTime; r22.TollRatePeriod = "01";// day, 02=evening, 03=night, 05=latenight, 06 =weekend r22.TollMultiRatePeriod = "1"; r22.TollRatingPointLengthIndicator = "00"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 string rTollChargeTime = cr.CalculateLocalLdTollChargeAmount(r22.TollChargeableTime); r22.TollCharge = rTollChargeTime; } else if (r22.CalledNumberDigits.StartsWith("8")) { // MO:TOLL FREE r22.CalledPlace = "TOLL FREE"; r22.CalledStateProvince = "CL"; r22.CalledCountry = "USA"; r22.SpecialFeaturesUsed = "J"; r22.PrintedCall = "TOLL FREE"; r22.TollTariffDescriptor = "00"; // interstate interlata r22.TollRateClass = "0"; // 0-when no toll associated with this call // *** figure out charges for TOLL FREE r22.TollConnectTime = "000000"; r22.TollElapsedTime = "000000"; r22.TollChargeableTime = r22.TollElapsedTime; // no toll r22.TollRatePeriod = "00"; // not applicable r22.TollMultiRatePeriod = "0"; // not applicable r22.TollRatingPointLengthIndicator = "0"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 r22.TollCharge = "00"; // no toll } else { // MO : International or Local/LD case // this should map to table 31 State/Province mapping NpaNxxData n = npaNxxRdr.GetNpaNxxInfo(r22.CalledNumberDigits.Substring(0, 6)); // check International scenario if (n.NpaNxx.Equals(String.Empty)) { // MO:International Rate = 1.49 AirTime + 0.80 Toll // International Call Scenario // add the international tables mapped to table 32 if (r22.CalledNumberDigits.Contains("0118522810")) { r22.CalledPlace = "Hong Kong"; r22.CalledStateProvince = "ZZ"; r22.CalledCountry = "HKG"; r22.SpecialFeaturesUsed = "D"; // International, but not required. // 01 = International : Originating from a NANP and terminating to Non-NANP // 15 = International : Originating from a NANP and terminating to NANP // 17 = International : Originating from a Non-NANP and terminating to NANP // 18 = International : Originating from and terminating to Non-NANP r22.TollTariffDescriptor = "01"; // see above r22.TollRateClass = "1"; // dial station, normal completed, 0-when no toll associated with this call // toll charges r22.TollConnectTime = r22.AirConnectTime; r22.TollElapsedTime = r22.AirElapsedTime; r22.TollChargeableTime = r22.AirChargeableTime; r22.TollRatePeriod = "01";// day, 02=evening, 03=night, 05=latenight, 06 =weekend r22.TollMultiRatePeriod = "1"; r22.TollRatingPointLengthIndicator = "00"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 string rTollChargeTime = cr.CalculateInternationalTollChargeAmount(r22.TollChargeableTime); r22.TollCharge = rTollChargeTime; } else if (r22.CalledNumberDigits.Contains("01181354")) { r22.CalledPlace = "Tokyo"; r22.CalledStateProvince = "ZZ"; r22.CalledCountry = "JPN"; r22.SpecialFeaturesUsed = "D"; // International, but not required. // 01 = International : Originating from a NANP and terminating to Non-NANP // 15 = International : Originating from a NANP and terminating to NANP // 17 = International : Originating from a Non-NANP and terminating to NANP // 18 = International : Originating from and terminating to Non-NANP r22.TollTariffDescriptor = "01"; // see above r22.TollRateClass = "1"; // dial station, normal completed, 0-when no toll associated with this call // toll charges r22.TollConnectTime = r22.AirConnectTime; r22.TollElapsedTime = r22.AirElapsedTime; r22.TollChargeableTime = r22.AirChargeableTime; r22.TollRatePeriod = "01";// day, 02=evening, 03=night, 05=latenight, 06 =weekend r22.TollMultiRatePeriod = "1"; r22.TollRatingPointLengthIndicator = "00"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 string rTollChargeTime = cr.CalculateInternationalTollChargeAmount(r22.TollChargeableTime); r22.TollCharge = rTollChargeTime; } else { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + "OmcToCiberCdrConverter::ProcessCallRecord():NPANXXNotFoundFor: " + r22.CalledNumberDigits); return; } } else { // MO:Local/LD case : Rate = 1.49 AirTime + 0.50 Toll r22.CalledPlace = n.City; r22.CalledStateProvince = n.State; r22.CalledCountry = "USA"; r22.SpecialFeaturesUsed = "0"; // none r22.TollTariffDescriptor = "02"; // interstate interlata r22.TollRateClass = "1"; // 0-when no toll associated with this call // toll charges r22.TollConnectTime = r22.AirConnectTime; r22.TollElapsedTime = r22.AirElapsedTime; r22.TollChargeableTime = r22.AirChargeableTime; r22.TollRatePeriod = "01";// day, 02=evening, 03=night, 05=latenight, 06 =weekend r22.TollMultiRatePeriod = "1"; r22.TollRatingPointLengthIndicator = "00"; r22.TollRatingPoint = "0"; // when TollRatingPointLengthIndicator=0, this = 0 string rTollChargeTime = cr.CalculateLocalLdTollChargeAmount(r22.TollChargeableTime); r22.TollCharge = rTollChargeTime; } } } // description designed by the serving carrier and may range from a city name to a cell site or a trunk/circuit name. r22.ServingPlace = "Strata8"; // for MO , called direction =1, this is the state that is providing service to the mobile subscriber // for MT, this is the state/province providing service to the called party // must contain a value given in section 8 , table 31 r22.ServingStateProvince = "WA"; r22.ServingCountry = "USA"; r22.TollStateProvinceTaxes = "0"; r22.TollLocalTaxes = "0"; r22.TollNetworkCarrierId = "00000"; // this is other ** TBD ** see section 8, table 10, and appendix H // let's get the total state/province taxes associated with this record r22.TotalStateProvinceTaxes = r22.TollStateProvinceTaxes; r22.TotalLocalTaxes = r22.TollLocalTaxes; // total charges is the sum of all the charge fields and taxes in this ciber record // r22.TotalChargesAndTaxes = r22.TotalLocalTaxes + r22.TotalStateProvinceTaxes + r22.AirCharge + r22.TollCharge; // need to convert to an int int intTotalLocalTaxes = Convert.ToInt32(r22.TotalLocalTaxes); int intTotalStateProvinceTaxes = Convert.ToInt32(r22.TotalStateProvinceTaxes); int intAirCharge = Convert.ToInt32(r22.AirCharge); int intTollCharge = Convert.ToInt32(r22.TollCharge); int totalChargesAndTaxesThisRecord = intTotalLocalTaxes + intTotalStateProvinceTaxes + intAirCharge + intTollCharge; // calculate new charges for this file and maintain the total // cri.BatchTotalChargesAndTaxes = cri.BatchTotalChargesAndTaxes + ... for out trailer // increment the record count if a valid record cri.TotalNumberOfRecordsInBatch++; //cri.BatchTotalChargesAndTaxes = cri.BatchTotalChargesAndTaxes + r22. cri.BatchTotalChargesAndTaxes = cri.BatchTotalChargesAndTaxes + totalChargesAndTaxesThisRecord; r22.TotalChargesAndTaxes = totalChargesAndTaxesThisRecord.ToString(); // finally write this cdr to the file // cfw.WriteToFile(r22.ToCiberStringFormat()); } catch (ApplicationException ae) { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + ae.Message + "\r\n" + ae.StackTrace); } catch (IOException ioe) { cfw.WriteToLogFile(DateTime.Now.ToShortDateString() + ioe.Message + "\r\n" + ioe.StackTrace); } }