Example #1
0
        // Get Carrier Route
        private void button2_Click(object sender, EventArgs e)
        {
            List <string> userInput = new List <string>();

            userInput.Clear();

            // Get User Input
            string Street  = textBox2.Text;
            string City    = textBox1.Text;
            string State   = textBox3.Text;
            string ZipCode = textBox4.Text;

            // Make list of User Input
            userInput.Add(Street);
            userInput.Add(City);
            userInput.Add(State);
            userInput.Add(ZipCode);

            // Create object for AddressValidation() and CarrierRoute()
            API_abstractHandler addValid  = new AddressValidation();
            API_abstractHandler carrRoute = new CarrierRoute();

            addValid.SetNextObject(carrRoute);                                               //create chain link
            carrRoute = new add_API_Name(carrRoute);                                         //add decorator

            string output = ClientRequest.ClientInput(carrRoute, "carrierRoute", userInput); //get results of address validation + decorator

            textBox6.Text = string.Empty;                                                    //clear textbox
            textBox6.AppendText(output);                                                     //output to textbox
        }
Example #2
0
        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);
        }
Example #4
0
        SortedList <int, List <CarrierRoute> > sort(IEnumerable <CarrierRouteRow> pCarrierRouteRows)
        {
            var _sortedCarrierRouteList = new SortedList <int, List <CarrierRoute> >();

            foreach (var _carrierRouteRow in pCarrierRouteRows)
            {
                var _carrierRoute = new CarrierRoute(_carrierRouteRow);
                var _costRank     = _carrierRoute.GetLCRCostRank();
                if (!_sortedCarrierRouteList.ContainsKey(_costRank))
                {
                    _sortedCarrierRouteList.Add(_costRank, new List <CarrierRoute>());
                }
                _sortedCarrierRouteList[_costRank].Add(_carrierRoute);
            }

            if (_sortedCarrierRouteList.Count == 0)
            {
                throw new RbrException(RbrResult.Carrier_RouteNotFound, "RoutingService.sort", "NOT Ranked Routes");
            }
            return(_sortedCarrierRouteList);
        }
Example #5
0
 public TerminationInfo(CarrierAcct pCarrierAcct, CarrierRoute pCarrierRoute, Endpoint pTermEP)
 {
     TermCarrier = pCarrierAcct;
     TermRoute   = pCarrierRoute;
     TermEP      = pTermEP;
 }
Example #6
0
        /// <summary>
        /// ----------------------------------------------------------------------------------------
        /// </summary>
        public int ProcessCallComplete(Cdr pCdr)
        {
            //-- Get OrigEP
            var _origEP = Endpoint.Get(pCdr.OrigIP);

            if (_origEP == null)
            {
                T.LogRbr(LogSeverity.Critical, "ProcessCallComplete:", string.Format("Endpoint NOT FOUND, IP={0}", pCdr.OrigIP));
                return(1);
            }
            pCdr.OrigEPId = _origEP.Id;

            //-- Remove prefix and '011' from destination number
            if (_origEP.WithPrefixes)
            {
                pCdr.PrefixIn = _origEP.GetPrefixIn(pCdr.DestNumber);
                if (pCdr.PrefixIn.Length > 0)
                {
                    pCdr.DestNumber = pCdr.DestNumber.Substring(pCdr.PrefixIn.Length);
                }
            }
            pCdr.LocalNumber = pCdr.DestNumber;

            if (pCdr.DestNumber.StartsWith(AppConstants.ZeroOneOne))
            {
                pCdr.DestNumber = pCdr.DestNumber.Substring(3);
            }

            //-- get carrier acct, termEp and route
            int          _result       = 0;
            CarrierRoute _carrierRoute = null;
            CarrierAcct  _carrierAcct  = null;

            if (_result == 0)
            {
                _result = parseCarrier(pCdr, out _carrierAcct, out _carrierRoute);
            }

            //-- Get CustomerAcct and route
            CustomerRoute _customerRoute = null;
            CustomerAcct  _customerAcct  = null;

            if (pCdr.CustomerAcctId > 0 || pCdr.DNIS > 0)
            {
                _result = parseCustomer(pCdr, out _customerAcct, out _customerRoute);
                if (_customerRoute != null)
                {
                    pCdr.CountryCode       = _customerRoute.CountryCode;
                    pCdr.CustomerRouteName = _customerRoute.Name;
                    pCdr.LocalNumber       = pCdr.DestNumber.Substring(_customerRoute.CountryCode.ToString().Length);
                }
            }
            else
            {
                _result++;
            }

            //-- extract prefix-out
            if (_carrierAcct != null && !string.IsNullOrEmpty(_carrierAcct.PrefixOut))
            {
                pCdr.PrefixOut = _carrierAcct.PrefixOut;
            }
            else if (_customerAcct != null && !string.IsNullOrEmpty(_customerAcct.PrefixOut))
            {
                pCdr.PrefixOut = _customerAcct.PrefixOut;
            }

            //-- do rating, debiting
            if (_carrierAcct != null && _customerAcct != null && pCdr.Duration > 0 && _result == 0)
            {
                _result += _carrierAcct.RateCall(_carrierRoute, ref pCdr);
                _result += _customerAcct.RateCall(_customerRoute, ref pCdr);
                if (_customerAcct.IsPrepaid)
                {
                    _customerAcct.Debit(pCdr.CustomerPrice);
                }
            }

            //-- always do Retail RetailAcct and SubAcct status needs to be reset to 'Active'
            var _retailAcct = RetailAccount.Get(_customerAcct, pCdr, configuration, T);

            if (_retailAcct != null && _customerRoute != null)
            {
                _result += _retailAcct.Rate(_customerRoute, ref pCdr);
                if (_retailAcct.IsPrepaid && pCdr.RetailPrice > decimal.Zero)
                {
                    _retailAcct.Debit(pCdr.RetailPrice, pCdr.UsedBonusMinutes);
                }
            }

            //-- Write to text file
            if (configuration.Main.LogCdrToFile)
            {
                _result += dualFileWriter.WriteLine(pCdr.Export());
            }

            return(_result);
        }