Ejemplo n.º 1
0
        internal static RatedRouteDto Get(Rbr_Db pDb, CarrierAcctDto pCarrierAcct, CarrierRouteRow pCarrierRouteRow)
        {
            if (pCarrierRouteRow == null)
            {
                return(null);
            }
            var _activeCarrierRouteEPMapCount = pDb.CarrierAcctEPMapCollection.GetActiveCountByCarrierRouteId(pCarrierRouteRow.Carrier_route_id);
            var _carrierRouteState            = (_activeCarrierRouteEPMapCount > 0) ? RouteState.Valid : RouteState.NoActiveEndpoints;

            if (pCarrierAcct.IsRatingEnabled)
            {
                //get Rates status
                bool _allRatesValid;
                CarrierRateHistoryRow _carrierRateHistoryRow = pDb.CarrierRateHistoryCollection.GetByCarrierRouteIdDate(pCarrierRouteRow.Carrier_route_id, DateTime.Today);
                if (_carrierRateHistoryRow == null)
                {
                    _allRatesValid = false;
                }
                else
                {
                    _allRatesValid = pDb.RateCollection.HasAllValidRates(_carrierRateHistoryRow.Rate_info_id);
                }
                _carrierRouteState = (_allRatesValid) ? _carrierRouteState | RouteState.Valid : _carrierRouteState | RouteState.NoRates;
            }
            var _baseRoute = RoutingManager.GetBaseRoute(pDb, pCarrierRouteRow.Route_id);
            var _route     = mapToRoute(pCarrierRouteRow, pCarrierAcct, _baseRoute, _carrierRouteState);

            return(_route);
        }
Ejemplo n.º 2
0
        internal static RatedRouteDto GetDefaultRoute(Rbr_Db pDb, CarrierAcctDto pCarrierAcct, RouteState pValid)
        {
            var _defaultCarrierRouteRow = pDb.CarrierRouteCollection.GetByPrimaryKey(-pCarrierAcct.CarrierAcctId);
            //if (pCarrierAcctRow.IsRatingEnabled) {
            //NOTE: DefaultRatingInfo is always created no metter what
            //and it should be loaded as well no metter what
            //}
            var _baseRoute = RoutingManager.GetBaseRoute(pDb, _defaultCarrierRouteRow.Route_id);

            return(mapToRoute(_defaultCarrierRouteRow, pCarrierAcct, _baseRoute, pValid));
        }
Ejemplo n.º 3
0
 internal static void AddCountriesToCallingPlan(Rbr_Db pDb, CallingPlanDto pCallingPlan, CountryDto[] pSelectedCountries)
 {
     foreach (var _country in pSelectedCountries)
     {
         var _properBaseRoute = new BaseRouteDto
         {
             BaseStatus  = Status.Active,
             CallingPlan = pCallingPlan,
             Country     = _country,
             Name        = string.Concat(_country.Name, AppConstants.SubRouteSeparator, AppConstants.ProperNameSuffix),
             Version     = 0
         };
         RoutingManager.AddBaseRoute(pDb, _properBaseRoute);
     }
 }
Ejemplo n.º 4
0
        internal static void DeleteCountry(Rbr_Db pDb, CountryDto pCountry)
        {
            //NOTE: no delete, just archive for Country and Routes
            pCountry.Status = Status.Archived;

            var _countryRow = mapToCountryRow(pCountry);
            var _routeRows  = pDb.RouteCollection.GetByCountry_id(_countryRow.Country_id);

            foreach (var _routeRow in _routeRows)
            {
                _routeRow.RouteStatus = Status.Archived;
                RoutingManager.UpdateBaseRoute(pDb, RoutingManager.MapToBaseRoute(pDb, _routeRow));
            }
            pDb.CountryCollection.Update(_countryRow);
            //pDb.AddChangedObject(new BaseRouteKey(TxType.Delete, 0, _countryRow.Country_id, 0));
        }
Ejemplo n.º 5
0
        internal static void UpdateCountry(Rbr_Db pDb, CountryDto pCountry)
        {
            var _original   = pDb.CountryCollection.GetByPrimaryKey(pCountry.CountryId);
            var _countryRow = mapToCountryRow(pCountry);

            pDb.CountryCollection.Update(_countryRow);

            if (_countryRow.IsNameChanged(_original))
            {
                //update names for All Country Routes (for ALL Services)
                var _routeRows = RoutingManager.GetByCountryId(pDb, _countryRow.Country_id);
                foreach (var _routeRow in _routeRows)
                {
                    _routeRow.Name = _countryRow.Name + AppConstants.SubRouteSeparator + _routeRow.BreakoutName;
                    RoutingManager.UpdateBaseRoute(pDb, RoutingManager.MapToBaseRoute(pDb, _routeRow));
                }
            }
            //pDb.AddChangedObject(new BaseRouteKey(TxType.Delete, 0, _countryRow.Country_id, 0));
        }
Ejemplo n.º 6
0
        internal static RatedRouteDto[] Get(Rbr_Db pDb, short pServiceId, int pCountryId)
        {
            var _wholesaleRouteRows = pDb.WholesaleRouteCollection.GetByService_idCountry_id(pServiceId, pCountryId);

            var _list = new List <RatedRouteDto>();

            foreach (var _wholesaleRouteRow in _wholesaleRouteRows)
            {
                var _service = ServiceManager.GetService(pDb, _wholesaleRouteRow.Service_id);
                var _route   = Get(pDb, _service, _service.DefaultRoutingPlanId, _wholesaleRouteRow);
                _list.Add(_route);
            }

            var _routes = _list.ToArray();

            if (_routes.Length > 1)
            {
                _routes = RoutingManager.SortRatedRoutes(_routes);
            }
            return(_routes);
        }
Ejemplo n.º 7
0
        public static RatedRouteDto Get(Rbr_Db pDb, ServiceDto pService, int pRoutingPlanId, WholesaleRouteRow pWholesaleRouteRow)
        {
            try {
                if (pWholesaleRouteRow == null)
                {
                    return(null);
                }
                var _routingPlanDetailRow = pDb.RoutingPlanDetailCollection.GetByPrimaryKey(pRoutingPlanId, pWholesaleRouteRow.Route_id);
                var _routingPlanId        = 0;
                var _routingAlgorithmType = RoutingAlgorithmType.Unknown;
                if (_routingPlanDetailRow != null)
                {
                    _routingPlanId        = _routingPlanDetailRow.Routing_plan_id;
                    _routingAlgorithmType = _routingPlanDetailRow.Algorithm;
                }
                var _routeState = (_routingPlanDetailRow != null) ? RouteState.Valid : RouteState.NotInRoutingPlan;

                if (pService.IsRatingEnabled)
                {
                    //get Rates status
                    bool _allRatesValid;
                    var  _wholesaleRateHistoryRow = pDb.WholesaleRateHistoryCollection.GetByWholesaleRouteIdDate(pWholesaleRouteRow.Wholesale_route_id, DateTime.Today);
                    if (_wholesaleRateHistoryRow == null)
                    {
                        _allRatesValid = false;
                    }
                    else
                    {
                        _allRatesValid = pDb.RateCollection.HasAllValidRates(_wholesaleRateHistoryRow.Rate_info_id);
                    }
                    _routeState = (_allRatesValid) ? _routeState | RouteState.Valid : _routeState | RouteState.NoRates;
                }
                var _baseRoute = RoutingManager.GetBaseRoute(pDb, pWholesaleRouteRow.Route_id);
                return(mapToRoute(pWholesaleRouteRow, _routingPlanId, _routingAlgorithmType, pService, _baseRoute, _routeState));
            }
            catch (Exception _ex) {
                var _exc = _ex;
            }
            return(null);
        }
Ejemplo n.º 8
0
        static ServiceDto getService(Rbr_Db pDb, ServiceRow pServiceRow, short pCustomerAcctId)
        {
            if (pServiceRow == null)
            {
                return(null);
            }
            AccessNumberListRow[] _accessNumberRows;
            if (pCustomerAcctId > 0)
            {
                _accessNumberRows = pDb.AccessNumberListCollection.GetByCustomer_acct_id(pCustomerAcctId);
            }
            else
            {
                _accessNumberRows = pDb.AccessNumberListCollection.GetByService_id(pServiceRow.Service_id);
            }

            var _defaultRoutingPlan = RoutingManager.GetRoutingPlan(pDb, pServiceRow.Default_routing_plan_id);

            PayphoneSurchargeRow _payphoneSurchargeRow = null;

            if (!pServiceRow.IsPayphone_surcharge_idNull)
            {
                _payphoneSurchargeRow = pDb.PayphoneSurchargeCollection.GetByPrimaryKey(pServiceRow.Payphone_surcharge_id);
            }

            //if (pServiceRow.IsRatingEnabled) {
            //NOTE: DefaultRatingInfo is always created no metter what
            //and it should be loaded as well no metter what
            var _defaultRatingInfo = getDefaultServiceRatingInfo(pDb, pServiceRow.Service_id);
            //}

            var _service = mapToService(pServiceRow, _defaultRoutingPlan, _payphoneSurchargeRow, _accessNumberRows, _defaultRatingInfo);

            //NOTE: DefaultServiceRoute's ID = [negative] -ServiceId
            var _defaultWholesaleRouteRow = pDb.WholesaleRouteCollection.GetByPrimaryKey(-pServiceRow.Service_id);

            _service.DefaultRoute = CustomerRouteManager.Get(pDb, _service, _service.DefaultRoutingPlanId, _defaultWholesaleRouteRow);
            return(_service);
        }