int parseCarrier(Cdr pCdr, out CarrierAcct pCarrierAcct, out CarrierRoute pCarrierRoute) { pCarrierAcct = null; pCarrierRoute = null; if (pCdr.CarrierAcctId == 0) { T.LogRbr(LogSeverity.Error, "BillingService.parseCarrier:", "Carrier NOT FOUND, CarrierAcctId=0"); return(1); } try { pCarrierAcct = CarrierAcct.Get(pCdr.CarrierAcctId); if (pCarrierAcct == null) { return(1); } if (CarrierAcct.NumberOfCallsCounter.ContainsKey(pCarrierAcct.Id)) { if (CarrierAcct.NumberOfCallsCounter[pCarrierAcct.Id] > 0) { T.LogRbr(LogSeverity.Debug, "BillingService.parseCarrier:", string.Format("Calls LIMIT stat, CarrierAcct={0}, NumberOfCalls={1}", pCarrierAcct.Id, CustomerAcct.NumberOfCallsCounter[pCarrierAcct.Id])); CarrierAcct.NumberOfCallsCounter[pCarrierAcct.Id] -= 1; } } //-- get carrier route pCarrierRoute = CarrierRoute.Get(pCdr.CarrierAcctId, pCdr.CarrierBaseRouteId); if (pCarrierRoute == null) { T.LogRbr(LogSeverity.Error, "BillingService.parseCarrier:", string.Format("Route NOT FOUND, CarrierAcctId={0}, CarrierBaseRouteId={1}, DestNumber={2}", pCarrierAcct.Id, pCdr.CarrierBaseRouteId, pCdr.DestNumber)); return(1); } pCdr.CarrierRouteName = pCarrierRoute.Name; //-- get term ep var _termEP = (new RoutingService()).GetTermEP(pCdr.TermIP, pCdr.Duration); if (_termEP == null) { T.LogRbr(LogSeverity.Error, "BillingService.parseCarrier:", string.Format("TermEP NOT FOUND={0}", pCdr)); pCdr.TermEPId = 0; return(1); } pCdr.TermEPId = _termEP.Id; } catch (Exception _ex) { T.LogRbr(LogSeverity.Error, "BillingService.parseCarrier:", string.Format("Exception:\r\n{0}", _ex)); return(1); } return(0); }
static bool rerateCDR(CDRViewRow_Base pCdrViewRow, IBackgroundWorker pBackgroundWorker) { try { var _customerAcct = CustomerAcct.Get(pCdrViewRow.Customer_acct_id); if (_customerAcct == null) { pBackgroundWorker.ReportStatus(string.Format("ERROR! CustomerAcct NOT FOUND, {0}", pCdrViewRow.Customer_acct_id)); return(false); } var _customerRoute = CustomerRoute.Get(_customerAcct.ServiceId, _customerAcct.RoutingPlanId, pCdrViewRow.Customer_route_id); if (_customerRoute == null) { pBackgroundWorker.ReportStatus(string.Format("ERROR! CustomerRoute NOT FOUND, {0}", pCdrViewRow.Customer_route_id)); return(false); } var _carrierAcct = CarrierAcct.Get(pCdrViewRow.Carrier_acct_id); if (_carrierAcct == null) { pBackgroundWorker.ReportStatus(string.Format("ERROR! CarrierAcct NOT FOUND, {0}", pCdrViewRow.Carrier_acct_id)); return(false); } var _carrierRoute = CarrierRoute.Get(_carrierAcct.Id, pCdrViewRow.Carrier_route_id); if (_carrierRoute == null) { pBackgroundWorker.ReportStatus(string.Format("ERROR! CarrierRoute NOT FOUND, {0}", pCdrViewRow.Carrier_route_id)); return(false); } var _cdr = new Cdr(pCdrViewRow); _customerAcct.RateCall(_customerRoute, ref _cdr); pCdrViewRow.Customer_duration = _cdr.CustomerDuration; pCdrViewRow.Price = _cdr.CustomerPrice; _carrierAcct.RateCall(_carrierRoute, ref _cdr); pCdrViewRow.Carrier_duration = _cdr.CarrierDuration; pCdrViewRow.Cost = _cdr.CarrierCost; } catch (Exception _ex) { pBackgroundWorker.ReportStatus(string.Format("Exception! {0}", _ex.Message)); TimokLogger.Instance.LogRbr(LogSeverity.Critical, "CdrExportController.rerate", string.Format("Exception:\r\n{0}", _ex)); return(false); } return(true); }