private static void WriteTapReg(AuditInfo row) { try { // open connection if (con.State == ConnectionState.Closed) con.Open(); sqlRegTAP.Parameters["@filename"].Value = string.Format("{0}{1}{2}{3:00000}", (row.isTest ? "TD" : "CD"), row.sender, row.recepient, row.seqno); sqlRegTAP.Parameters["@creationdate"].Value = row.firstCallDate; sqlRegTAP.Parameters["@firstcalldate"].Value = row.firstCallDate; sqlRegTAP.Parameters["@lastcalldate"].Value = row.lastCallDate; sqlRegTAP.Parameters["@calls"].Value = row.callCount; sqlRegTAP.Parameters["@sdr"].Value = row.totalSDR; sqlRegTAP.ExecuteNonQuery(); } catch (Exception ex) { DB.AsyncWriteLog("Write Tap Reg failed: " + ex.Message); } finally { con.Close(); } }
public static void ImportTap311(XmlDocument xml) { AuditInfo ainfo = new AuditInfo(); ainfo.sender = xml.SelectSingleNode("//Sender").InnerText; ainfo.recepient = xml.SelectSingleNode("//Recipient").InnerText; ainfo.seqno = Convert.ToInt32(xml.SelectSingleNode("//FileSequenceNumber").InnerText); try { ainfo.tapDecPlace = (int)Math.Pow(10, Convert.ToInt32(xml.SelectSingleNode("//AccountingInfo/TapDecimalPlaces").InnerText)); } catch { ainfo.tapDecPlace = 1000; } try { ainfo.callCount = Convert.ToInt32(xml.SelectSingleNode("//CallEventDetailsCount").InnerText); } catch { ainfo.callCount = 0; } try { ainfo.totalSDR = Convert.ToSingle(xml.SelectSingleNode("//AuditControlInfo/TotalCharge").InnerText)/ainfo.tapDecPlace; //ainfo.totalSDR += Convert.ToSingle(xml.SelectSingleNode("//AuditControlInfo/TotalTaxValue").InnerText)/ainfo.tapDecPlace; } catch { ainfo.totalSDR = 0; } try { ainfo.createdDate = ConvertToDate(xml.SelectSingleNode("//BatchControlInfo/FileCreationTimeStamp/LocalTimeStamp").InnerText); ainfo.firstCallDate = ConvertToDate(xml.SelectSingleNode("//AuditControlInfo/EarliestCallTimeStamp/LocalTimeStamp").InnerText); ainfo.lastCallDate = ConvertToDate(xml.SelectSingleNode("//AuditControlInfo/LatestCallTimeStamp/LocalTimeStamp").InnerText); } catch { ainfo.createdDate = new DateTime(1900, 1, 1); ainfo.firstCallDate = new DateTime(1900, 1, 1); ainfo.lastCallDate = new DateTime(1900, 1, 1); } ainfo.isTest = false; if (xml.SelectSingleNode("//FileTypeIndicator") != null) { ainfo.isTest = xml.SelectSingleNode("//FileTypeIndicator").InnerText.Equals("T"); } try { WriteTapReg(ainfo); } catch { } CDRecord row = new CDRecord(); XmlNodeList nodes = null; // import MO calls nodes = xml.SelectNodes("//MobileOriginatedCall"); foreach (XmlNode node in nodes) { try { row.callType = 'O'; switch (node.SelectSingleNode(".//TeleServiceCode").InnerText) { case "22": row.division = 'S'; break; //case "11": row.division = 'R'; default: row.division = 'R'; break; } // string strDate = node.SelectSingleNode(".//CallEventStartTimeStamp/LocalTimeStamp").InnerText; row.date = Convert.ToDateTime(strDate.Substring(0, 4) + "-" + strDate.Substring(4, 2) + "-" + strDate.Substring(6, 2) + " " + strDate.Substring(8, 2) + ":" + strDate.Substring(10, 2) + ":" + strDate.Substring(12, 2)); row.duration = Convert.ToInt32(node.SelectSingleNode(".//TotalCallEventDuration").InnerText); row.locA = ainfo.sender; row.locB = ""; row.imsi = node.SelectSingleNode(".//SimChargeableSubscriber/Imsi").InnerText; try { row.isdn = node.SelectSingleNode(".//SimChargeableSubscriber/Msisdn").InnerText; } catch { row.isdn = ""; } try { row.partner = node.SelectSingleNode(".//Destination/CalledNumber").InnerText; } catch { row.partner = ""; } int charge = 0; XmlNodeList charges = node.SelectNodes(".//ChargeDetail/Charge"); foreach (XmlNode chargeNode in charges) { int val = Convert.ToInt32(chargeNode.InnerText); if (val > charge) charge = val; } int tax = 0; XmlNodeList taxes = node.SelectNodes(".//TaxInformation/TaxValue"); foreach (XmlNode taxNode in taxes) { int val = Convert.ToInt32(taxNode.InnerText); if (val > tax) tax = val; } row.sdr = (float)((charge + tax))/(float)ainfo.tapDecPlace; row.seqno = ainfo.seqno; row.error = 'L'; // write to dest WriteUDF(row); } catch (Exception ex) { // write to log DB.AsyncWriteLog("TAP Import error: MOC import failed: " + ex.Message); } } // import MT calls nodes = xml.SelectNodes("//MobileTerminatedCall"); foreach (XmlNode node in nodes) { try { row.callType = 'I'; switch (node.SelectSingleNode(".//TeleServiceCode").InnerText) { case "21": row.division = 'S'; break; //case "11": row.division = 'R'; default: row.division = 'R'; break; } row.date = ConvertToDate(node.SelectSingleNode(".//CallEventStartTimeStamp/LocalTimeStamp").InnerText); row.duration = Convert.ToInt32(node.SelectSingleNode(".//TotalCallEventDuration").InnerText); row.locA = ainfo.sender; row.locB = ""; row.imsi = node.SelectSingleNode(".//SimChargeableSubscriber/Imsi").InnerText; try { row.isdn = node.SelectSingleNode(".//SimChargeableSubscriber/Msisdn").InnerText; } catch { row.isdn = ""; } try { row.partner = node.SelectSingleNode(".//CallOriginator/CallingNumber").InnerText; } catch { row.partner = ""; } int charge = 0; XmlNodeList charges = node.SelectNodes(".//ChargeDetail/Charge"); foreach (XmlNode chargeNode in charges) { int val = Convert.ToInt32(chargeNode.InnerText); if (val > charge) charge = val; } int tax = 0; XmlNodeList taxes = node.SelectNodes(".//TaxInformation/TaxValue"); foreach (XmlNode taxNode in taxes) { int val = Convert.ToInt32(taxNode.InnerText); if (val > tax) tax = val; } row.sdr = (float)((charge + tax))/(float)ainfo.tapDecPlace; row.error = 'L'; // write to dest WriteUDF(row); } catch (Exception ex) { // write to log DB.AsyncWriteLog("MO: " + ex.Message); } } }