예제 #1
0
파일: DB.cs 프로젝트: ubs121/roamer
		private static void WriteUDF(CDRecord row) {
			try {
				// open connection
				if (con.State == ConnectionState.Closed) con.Open();

				udfWriter.Parameters["@calltype"].Value = row.callType;
				udfWriter.Parameters["@division"].Value = row.division;
				udfWriter.Parameters["@date"].Value = row.date;
				udfWriter.Parameters["@duration"].Value = row.duration;
				udfWriter.Parameters["@loca"].Value = row.locA;
				udfWriter.Parameters["@imsi"].Value = row.imsi;
				udfWriter.Parameters["@isdn"].Value = row.isdn;
				udfWriter.Parameters["@locb"].Value = row.locB;
				udfWriter.Parameters["@partner"].Value = row.partner;
				udfWriter.Parameters["@sdr"].Value = row.sdr;
				udfWriter.Parameters["@seqno"].Value = row.seqno;
				udfWriter.Parameters["@error"].Value = row.error;

				udfWriter.ExecuteNonQuery();
			}
			catch (Exception ex) {
				DB.AsyncWriteLog("Write UDF failed: " + ex.Message);
			}
			finally {
				con.Close();
			}
		}
예제 #2
0
파일: DB.cs 프로젝트: ubs121/roamer
		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);
				}
			}
		}