コード例 #1
0
        static void addDialCodeForProperBaseRoute(Rbr_Db pDb, BaseRouteDto pBaseRoute)
        {
            if (pBaseRoute.IsProper)
            {
                if (pBaseRoute.Country.CountryCode == 1)
                {
                    //no default code for countries with country code 1 (Canada, USA, ???)
                }
                else
                {
                    //TODO: should we try to find existing, and if found reassign to Proper Route
                    var _properDialCode = CallingPlanManager.GetDialCode(pDb, pBaseRoute.CallingPlanId, pBaseRoute.Country.CountryCode);
                    if (_properDialCode == null)
                    {
                        _properDialCode = new DialCodeDto();
                    }
                    else
                    {
                        CallingPlanManager.DeleteDialCode(pDb, _properDialCode);
                    }
                    _properDialCode.CallingPlanId = pBaseRoute.CallingPlanId;
                    _properDialCode.Code          = pBaseRoute.Country.CountryCode;
                    _properDialCode.BaseRouteId   = pBaseRoute.BaseRouteId;

                    CallingPlanManager.AddDialCode(pDb, _properDialCode);
                }
            }
        }
コード例 #2
0
        internal static BaseRouteDto[] GetUnusedBaseRoutes(Rbr_Db pDb, short pAccountId, int pCallingPlanId, ViewContext pContext, int pRoutingPlanId)
        {
            var _callingPlan = CallingPlanManager.GetCallingPlan(pDb, pCallingPlanId);

            RouteRow[] _routeRows = null;
            if (pContext == ViewContext.Carrier)
            {
                _routeRows = pDb.RouteCollection.GetUnusedByCallingPlanIdCarrierAcctId(pCallingPlanId, pAccountId);
            }
            else if (pContext == ViewContext.Service)
            {
                _routeRows = pDb.RouteCollection.GetUnusedByCallingPlanIdRoutingPlanIdServiceId(pCallingPlanId, pRoutingPlanId, pAccountId);
            }

            if (_routeRows == null || _routeRows.Length == 0)
            {
                return(null);
            }

            var _baseRoutes = new List <BaseRouteDto>();

            foreach (var _routeRow in _routeRows)
            {
                var _country = CallingPlanManager.GetCountry(pDb, _routeRow.Country_id);

                var _dialCodeCount = CallingPlanManager.GetDialCodeCount(pDb, _routeRow.Route_id);
                var _routeState    = (_dialCodeCount > 0) ? RouteState.Valid : RouteState.NoDialCodes;

                _baseRoutes.Add(mapToBaseRoute(_routeRow, _country, _callingPlan, _routeState));
            }
            return(sortBaseRoutes(_baseRoutes.ToArray()));
        }
コード例 #3
0
        internal static RoutingPlanDto GetRoutingPlan(Rbr_Db pDb, int pRoutingPlanId)
        {
            var _routingPlanRow = pDb.RoutingPlanCollection.GetByPrimaryKey(pRoutingPlanId);
            var _callingPlan    = CallingPlanManager.GetCallingPlan(pDb, _routingPlanRow.Calling_plan_id);

            return(mapToRoutingPlan(_routingPlanRow, _callingPlan));
        }
コード例 #4
0
        internal static BaseRouteDto[] GetUnusedByCallingPlanIdRoutingPlanId(Rbr_Db pDb, int pCallingPlanId, int pRoutingPlanId)
        {
            var _routeRows   = pDb.RouteCollection.GetUnusedByCallingPlanIdRoutingPlanId(pCallingPlanId, pRoutingPlanId);
            var _callingPlan = CallingPlanManager.GetCallingPlan(pDb, pCallingPlanId);
            var _routeList   = getBaseRouteList(pDb, _callingPlan, _routeRows);

            return(sortBaseRoutes(_routeList.ToArray()));
        }
コード例 #5
0
        internal static RoutingPlanDto[] GetRoutingPlans(Rbr_Db pDb, int pCallingPlanId)
        {
            var _list            = new List <RoutingPlanDto>();
            var _callingPlan     = CallingPlanManager.GetCallingPlan(pDb, pCallingPlanId);
            var _routingPlanRows = pDb.RoutingPlanCollection.GetByCalling_plan_id(pCallingPlanId);

            foreach (var _routingPlanRow in _routingPlanRows)
            {
                _list.Add(mapToRoutingPlan(_routingPlanRow, _callingPlan));
            }
            return(_list.ToArray());
        }
コード例 #6
0
        static List <BaseRouteDto> getBaseRouteList(Rbr_Db pDb, CallingPlanDto pCallingPlan, IEnumerable <RouteRow> pRouteRows)
        {
            var _routeList = new List <BaseRouteDto>();

            foreach (var _routeRow in pRouteRows)
            {
                var _country = CallingPlanManager.GetCountry(pDb, _routeRow.Country_id);

                var _dialCodeCount = CallingPlanManager.GetDialCodeCount(pDb, _routeRow.Route_id);
                var _routeState    = (_dialCodeCount > 0) ? RouteState.Valid : RouteState.NoDialCodes;

                var _route = mapToBaseRoute(_routeRow, _country, pCallingPlan, _routeState);
                _routeList.Add(_route);
            }
            return(_routeList);
        }
コード例 #7
0
        internal static BaseRouteDto GetProperRoute(Rbr_Db pDb, int pCallingPlanId, int pCountryId)
        {
            var _properRouteRow = GetProper(pDb, pCallingPlanId, pCountryId);

            if (_properRouteRow == null)
            {
                return(null);
            }

            var _callingPlan   = CallingPlanManager.GetCallingPlan(pDb, pCallingPlanId);
            var _country       = CallingPlanManager.GetCountry(pDb, pCountryId);
            var _dialCodeCount = CallingPlanManager.GetDialCodeCount(pDb, _properRouteRow.Route_id);
            var _routeState    = (_dialCodeCount > 0) ? RouteState.Valid : RouteState.NoDialCodes;

            return(mapToBaseRoute(_properRouteRow, _country, _callingPlan, _routeState));
        }
コード例 #8
0
        internal static BaseRouteDto[] GetBaseRoutesByRoutingPlanId(Rbr_Db pDb, int pCallingPlanId, int pRoutingPlanId)
        {
            RouteRow[] _routeRows;
            if (pRoutingPlanId > 0)
            {
                _routeRows = GetByCallingPlanIdRoutingPlanId(pDb, pCallingPlanId, pRoutingPlanId);
            }
            else
            {
                _routeRows = GetByCallingPlanId(pDb, pCallingPlanId);
            }

            var _callingPlan = CallingPlanManager.GetCallingPlan(pDb, pCallingPlanId);
            var _routeList   = getBaseRouteList(pDb, _callingPlan, _routeRows);

            return(sortBaseRoutes(_routeList.ToArray()));
        }
コード例 #9
0
        //internal static BaseRouteDto[] MapToBaseRoutes(Rbr_Db pDb, RouteRow[] pRouteRows, CountryRow[] pCountryRows, CallingPlanRow pCallingPlanRow) {
        //  ArrayList _list = new ArrayList();
        //  if (pRouteRows != null) {
        //    foreach (RouteRow _routeRow in pRouteRows) {
        //      CountryRow _countryRow = getCountry(_routeRow.Country_id, pCountryRows);
        //      int _dialCodeCount = pDb.DialCodeCollection.GetCount( /*_routeRow.Calling_plan_id,*/ _routeRow.Route_id);
        //      RouteState _routeState = ( _dialCodeCount > 0 ) ? RouteState.Valid : RouteState.NoDialCodes;
        //      BaseRouteDto _baseRoute = MapToBaseRoute(_routeRow, _countryRow, pCallingPlanRow, _routeState);
        //      _list.Add(_baseRoute);
        //    }
        //  }
        //  return (BaseRouteDto[])_list.ToArray(typeof(BaseRouteDto));
        //}

        public static BaseRouteDto MapToBaseRoute(Rbr_Db pDb, RouteRow pRouteRow)          //}, CountryRow pCountryRow, CallingPlanRow pCallingPlanRow, RouteState pRouteState) {
        {
            if (pRouteRow == null)
            {
                return(null);
            }

            var _baseRoute = new BaseRouteDto();

            _baseRoute.BaseRouteId   = pRouteRow.Route_id;
            _baseRoute.Name          = pRouteRow.Name;
            _baseRoute.BaseStatus    = pRouteRow.RouteStatus;
            _baseRoute.CallingPlan   = CallingPlanManager.GetCallingPlan(pDb, pRouteRow.Calling_plan_id);
            _baseRoute.Country       = CallingPlanManager.GetCountry(pDb, pRouteRow.Country_id);
            _baseRoute.RoutingNumber = pRouteRow.Routing_number;
            _baseRoute.Version       = pRouteRow.Version;
            _baseRoute.RouteState    = RouteState.Valid;

            return(_baseRoute);
        }
コード例 #10
0
        internal static BaseRouteDto GetBaseRoute(Rbr_Db pDb, int pBaseRouteId)
        {
            if (pBaseRouteId == 0)
            {
                return(null);
            }

            var _routeRow = Get(pDb, pBaseRouteId);

            if (_routeRow == null)
            {
                return(null);
            }
            var _callingPlan = CallingPlanManager.GetCallingPlan(pDb, _routeRow.Calling_plan_id);
            var _country     = CallingPlanManager.GetCountry(pDb, _routeRow.Country_id);

            var _dialCodeCount = pDb.DialCodeCollection.GetCount(_routeRow.Route_id);
            var _routeState    = (_dialCodeCount > 0) ? RouteState.Valid : RouteState.NoDialCodes;

            return(mapToBaseRoute(_routeRow, _country, _callingPlan, _routeState));
        }
コード例 #11
0
        //-------------------- Private ----------------------------------------------

        static CarrierAcctDto getAcct(Rbr_Db pDb, CarrierAcctRow pCarrierAcctRow)
        {
            if (pCarrierAcctRow == null)
            {
                return(null);
            }
            var _partner = PartnerManager.Get(pDb, pCarrierAcctRow.Partner_id);

            if (_partner == null)
            {
                return(null);
            }
            var _callingPlan = CallingPlanManager.GetCallingPlan(pDb, pCarrierAcctRow.Calling_plan_id);

            if (_callingPlan == null)
            {
                return(null);
            }
            var _carrierAcct = mapToCarrierAcct(pCarrierAcctRow, _partner, _callingPlan);

            _carrierAcct.DefaultRoute = CarrierRouteManager.GetDefaultRoute(pDb, _carrierAcct, RouteState.Valid);

            //-- GetDefaultCarrierRatingInfo
            if (_carrierAcct.IsRatingEnabled)
            {
                var _defaultCarrierRouteRow = pDb.CarrierRouteCollection.GetByPrimaryKey(-pCarrierAcctRow.Carrier_acct_id);
                var _carrierRateHistoryRows = pDb.CarrierRateHistoryCollection.GetByCarrier_route_id(_defaultCarrierRouteRow.Carrier_route_id);
                if (_carrierRateHistoryRows.Length < 1)
                {
                    TimokLogger.Instance.LogRbr(LogSeverity.Critical, "CarrierAcctManager.GetDefaultCarrierRatingInfo", string.Format("Unexpected: _carrierRateHistoryRows.Length = {0}", _carrierRateHistoryRows.Length));
                    throw new Exception(string.Format("CarrierAcctManager.GetDefaultCarrierRatingInfo, Unexpected: _carrierRateHistoryRows.Length = {0}", _carrierRateHistoryRows.Length));
                }
                _carrierAcct.DefaultRatingInfo = RatingManager.GetRatingInfo(pDb, _carrierRateHistoryRows[0].Rate_info_id, false);
            }

            return(_carrierAcct);
        }