예제 #1
0
        internal static void Add(Rbr_Db pDb, CarrierAcctDto pCarrierAcct, int pBaseRouteId, out int pCarrierRouteId)
        {
            var _carrierRouteRow = new CarrierRouteRow();

            _carrierRouteRow.Carrier_acct_id = pCarrierAcct.CarrierAcctId;
            _carrierRouteRow.Acd_target      = pCarrierAcct.DefaultRoute.ACDTarget;
            _carrierRouteRow.Acd_time_window = pCarrierAcct.DefaultRoute.ACDTimeWindow;
            _carrierRouteRow.Asr_target      = pCarrierAcct.DefaultRoute.ASRTarget;
            _carrierRouteRow.Asr_time_window = pCarrierAcct.DefaultRoute.ASRTimeWindow;
            _carrierRouteRow.Next_ep         = pCarrierAcct.DefaultRoute.NextEP;

            if (pBaseRouteId > 0)
            {
                //Regular ServiceRoute
                _carrierRouteRow.Route_id    = pBaseRouteId;
                _carrierRouteRow.RouteStatus = Status.Active;
            }
            else
            {
                //Default CarrierRoute, set CarrierRouteId = -CarrierAcctId, NO Base RouteId
                pCarrierAcct.DefaultRoute.RatedRouteId = -pCarrierAcct.CarrierAcctId;
                _carrierRouteRow.Carrier_route_id      = pCarrierAcct.DefaultRoute.RatedRouteId;
                _carrierRouteRow.RouteStatus           = Status.Blocked;       //for Default ServiceRoute
            }

            pDb.CarrierRouteCollection.Insert(_carrierRouteRow);

            if (pCarrierAcct.IsRatingEnabled || pBaseRouteId == 0)
            {
                //always add Def RatingInfo for Def Route
                RatingManager.AddDefaultRatingInfo(pDb, _carrierRouteRow.Carrier_route_id, pCarrierAcct.DefaultRatingInfo, RouteType.Carrier);
            }
            pCarrierRouteId = _carrierRouteRow.Carrier_route_id;
        }
예제 #2
0
        internal static void Add(Rbr_Db pDb, short pServiceId, int pBaseRouteId, out int pRouteId)
        {
            pRouteId = 0;

            if (pBaseRouteId == 0)
            {
                throw new ArgumentException("BaseRouteId cannot be 0.", "pBaseRouteId");
            }

            var _service           = ServiceManager.GetService(pDb, pServiceId);
            var _wholesaleRouteRow = new WholesaleRouteRow();

            _wholesaleRouteRow.Service_id  = _service.ServiceId;
            _wholesaleRouteRow.Route_id    = pBaseRouteId;
            _wholesaleRouteRow.RouteStatus = Status.Active;

            pDb.WholesaleRouteCollection.Insert(_wholesaleRouteRow);

            if (_service.IsRatingEnabled)
            {
                RatingManager.AddDefaultRatingInfo(pDb, _wholesaleRouteRow.Wholesale_route_id, _service.DefaultRatingInfo, RouteType.Wholesale);
            }

            pRouteId = _wholesaleRouteRow.Wholesale_route_id;
        }
예제 #3
0
        internal static void UpdateService(Rbr_Db pDb, ServiceDto pService)
        {
            if (pService.IsRatingEnabled)
            {
                //Update Service's Default RatingInfo
                //NOTE: DefaultRatingInfo is always created on Add, no metter is RatingEnabled or not
                RatingManager.UpdateRatingInfo(pDb, pService.DefaultRatingInfo);

                //check RatingInfo for all others WholesaleRoutes, if they have no RatingInfo - create it
                //if WholesaleRoute already have Rates, just leave it as is
                WholesaleRouteRow[] _wholesaleRouteRows = pDb.WholesaleRouteCollection.GetByService_id(pService.ServiceId);
                foreach (WholesaleRouteRow _wholesaleRouteRow in _wholesaleRouteRows)
                {
                    WholesaleRateHistoryRow[] _wholesaleRateHistoryRows = pDb.WholesaleRateHistoryCollection.GetByWholesale_route_id(_wholesaleRouteRow.Wholesale_route_id);
                    if (_wholesaleRateHistoryRows.Length == 0)
                    {
                        //route has no rates, create them using Default
                        RatingManager.AddDefaultRatingInfo(pDb, _wholesaleRouteRow.Wholesale_route_id, pService.DefaultRatingInfo, RouteType.Wholesale);
                    }
                }

                if (pService.PayphoneSurcharge != null)
                {
                    if (pService.PayphoneSurcharge.PayphoneSurchargeId == 0)
                    {
                        pService.PayphoneSurcharge.PayphoneSurchargeId = RetailAccountManager.AddPayphoneSurcharge(pDb, pService.PayphoneSurcharge);
                    }
                    else
                    {
                        RetailAccountManager.UpdatePayphoneSurcharge(pDb, pService);
                    }
                }
            }
            CustomerRouteManager.Update(pDb, pService.DefaultRoute);

            ServiceRow _serviceRow = mapToServiceRow(pService);

            Update(pDb, _serviceRow);
            //pDb.AddChangedObject(new ServiceKey(TxType.Delete, pService.ServiceId));

            ServiceRow _originalServiceRow = Get(pDb, pService.ServiceId);

            if (pService.PayphoneSurcharge == null && !_originalServiceRow.IsPayphone_surcharge_idNull)
            {
                pDb.PayphoneSurchargeCollection.DeleteByPrimaryKey(_originalServiceRow.Payphone_surcharge_id);
            }
        }
예제 #4
0
        internal static void AddDefault(Rbr_Db pDb, ServiceDto pService, out int pDefaultWholesaleRouteId)
        {
            var _wholesaleRouteRow = new WholesaleRouteRow();

            _wholesaleRouteRow.Service_id = pService.ServiceId;

            //DefaultWholesaleRoute, set WholesaleRouteId = -ServiceId, NO Base RouteId
            pService.DefaultRoute.RatedRouteId    = -pService.ServiceId;
            _wholesaleRouteRow.IsRoute_idNull     = true;
            _wholesaleRouteRow.Wholesale_route_id = pService.DefaultRoute.RatedRouteId;
            _wholesaleRouteRow.RouteStatus        = Status.Blocked;      //for Default WholesaleServiceRoute

            pDb.WholesaleRouteCollection.Insert(_wholesaleRouteRow);

            //always add Def RatingInfo for Def WholesaleRoute
            RatingManager.AddDefaultRatingInfo(pDb, _wholesaleRouteRow.Wholesale_route_id, pService.DefaultRatingInfo, RouteType.Wholesale);

            pDefaultWholesaleRouteId = _wholesaleRouteRow.Wholesale_route_id;
        }
예제 #5
0
        internal static void UpdateCarrierAcct(Rbr_Db pDb, CarrierAcctDto pCarrierAcct)
        {
            if (pCarrierAcct.IsRatingEnabled)
            {
                //Update RatingInfo for CarrierAcct's DefaltRoute
                //NOTE: DefaultRatingInfo is always created on Add, no metter is RatingEnabled or not
                RatingManager.UpdateRatingInfo(pDb, pCarrierAcct.DefaultRatingInfo);

                //check RatingInfo for all others Routes, if they have no Rates - create it using DefaultrateInfo, if Route already have Rates, just leave it as is
                var _carrierRouteRows = pDb.CarrierRouteCollection.GetByCarrier_acct_id(pCarrierAcct.CarrierAcctId);
                foreach (var _carrierRouteRow in _carrierRouteRows)
                {
                    var _carrierRateHistoryRows = pDb.CarrierRateHistoryCollection.GetByCarrier_route_id(_carrierRouteRow.Carrier_route_id);
                    if (_carrierRateHistoryRows.Length == 0)
                    {
                        RatingManager.AddDefaultRatingInfo(pDb, _carrierRouteRow.Carrier_route_id, pCarrierAcct.DefaultRatingInfo, RouteType.Carrier);
                    }
                }
            }
            pDb.CarrierAcctCollection.Update(mapToCarrierAcctRow(pCarrierAcct));
            //pDb.AddChangedObject(new CarrierAcctKey(TxType.Delete, pCarrierAcct.CarrierAcctId));
        }