コード例 #1
0
 public void AddRoutes(short pAccountId, int[] pBaseRouteIds, ViewContext pContext)
 {
     using (var _db = new Rbr_Db()) {
         using (var _tx = new Transaction(_db, pAccountId, pBaseRouteIds, pContext)) {
             if (pContext == ViewContext.Carrier)
             {
                 var _carrierAcct = CarrierAcctManager.GetAcct(_db, pAccountId);
                 CarrierRouteManager.Add(_db, _carrierAcct, pBaseRouteIds);
             }
             else if (pContext == ViewContext.Customer)
             {
                 //NOTE: same as ServiceDialPlan
                 CustomerRouteManager.Add(_db, pAccountId, pBaseRouteIds);
             }
             else if (pContext == ViewContext.Service)
             {
                 //NOTE: same as CustomerDialPlan
                 CustomerRouteManager.Add(_db, pAccountId, pBaseRouteIds);
             }
             else
             {
                 throw new NotImplementedException("ViewContext: " + pContext);
             }
             _tx.Commit();
         }
     }
 }
コード例 #2
0
        //public static RatingInfoDto[] GetRates(short pAcctId, int pCountryId, RouteType pRouteType, DateTime pDate) {
        //  using (var _db = new Rbr_Db()) {
        //    if (pRouteType == RouteType.Carrier) {
        //      throw new NotImplementedException();
        //    }
        //    if (pRouteType == RouteType.Wholesale) {
        //      return getWholesaleRates(_db, pAcctId, pRouteType, pCountryId, pDate);
        //    }
        //    //else if (pRouteType == RouteType.Retail) {
        //    //  //TODO:
        //    //}
        //    throw new ArgumentException(string.Format("UNSUPPORTED Type : {0}", pRouteType), "pRouteType");
        //  }
        //}

        public static RatingHistoryEntry GetNewRatingHistoryEntry(int pRatedRouteId, RouteType pRouteType)
        {
            using (var _db = new Rbr_Db()) {
                RatedRouteDto _route = null;
                if (pRouteType == RouteType.Carrier)
                {
                    _route = CarrierRouteManager.Get(_db, pRatedRouteId);
                }
                else if (pRouteType == RouteType.Wholesale)
                {
                    _route = CustomerRouteManager.Get(_db, pRatedRouteId);
                }
                else if (pRouteType == RouteType.Retail)
                {
                }
                if (_route != null)
                {
                    var _ratingInfo = _route.DefaultRatingInfo.Clone();
                    if (_ratingInfo != null)
                    {
                        var _ratingHistoryEntry = new RatingHistoryEntry(pRouteType, pRatedRouteId, DateTime.Today, Configuration.Instance.Db.SqlSmallDateTimeMaxValue, _ratingInfo.Clone());
                        _ratingHistoryEntry.HasChanged = true;
                        return(_ratingHistoryEntry);
                    }
                }
                return(null);
            }
        }
コード例 #3
0
        public RatedRouteDto[] GetByAccountIdCountryId(short pAccountId, int pCountryId, ViewContext pContext)
        {
            using (var _db = new Rbr_Db()) {
                if (pContext == ViewContext.Carrier)
                {
                    return(CarrierRouteManager.GetByCarrierAcctIdCountryId(_db, pAccountId, pCountryId));
                }

                if (pContext == ViewContext.Customer || pContext == ViewContext.Service)
                {
                    return(CustomerRouteManager.Get(_db, pAccountId, pCountryId));
                }

                throw new NotImplementedException("ViewContext: " + pContext);
            }
        }
コード例 #4
0
        public static void AddAcct(CarrierAcctDto pCarrierAcct, int[] pSelectedBaseRouteIds)
        {
            using (Rbr_Db _db = new Rbr_Db()) {
                using (Transaction _tx = new Transaction(_db, pCarrierAcct, pSelectedBaseRouteIds)) {
                    CarrierAcctManager.AddCarrierAcct(_db, pCarrierAcct);

                    //Create Default Route
                    int _defaultCarrierRouteId;
                    CarrierRouteManager.Add(_db, pCarrierAcct, 0, out _defaultCarrierRouteId);
                    pCarrierAcct.DefaultRoute.RatedRouteId = _defaultCarrierRouteId;
                    CarrierRouteManager.Add(_db, pCarrierAcct, pSelectedBaseRouteIds);

                    _tx.Commit();
                }
            }
        }
コード例 #5
0
 protected int getCarrierRouteId(Rbr_Db pDb, short pCarrierAcctId, int pBaseRouteId)
 {
     try {
         RatedRouteDto _carrierRoute = CarrierRouteManager.Get(pDb, pCarrierAcctId, pBaseRouteId);
         if (_carrierRoute == null)
         {
             string _msg = string.Format("Skipping Route, doesn't exists in DialPlan. {0}, {1}.", pCarrierAcctId, pBaseRouteId);
             TimokLogger.Instance.LogRbr(LogSeverity.Error, "ServiceController.getCarrierRouteId", string.Format("ServiceController.importRatesOnly | {0}", _msg));
             Host.ReportStatus(_msg);
             return(0);
         }
         return(_carrierRoute.RatedRouteId);
     }
     catch (Exception _ex) {
         string _msg = string.Format("ERROR: {0}, getCarrierRouteId: {1}, {2}", pCarrierAcctId, pBaseRouteId, _ex.Message);
         Host.ReportStatus(_msg);
         TimokLogger.Instance.LogRbr(LogSeverity.Error, "RatesImporter.getCarrierRouteId", string.Format("{0}\r\n{1}", _msg, _ex));
         throw;
     }
 }
コード例 #6
0
        public RatedRouteDto Get(int pRouteId, ViewContext pContext)
        {
            using (var _db = new Rbr_Db()) {
                if (pContext == ViewContext.Carrier)
                {
                    return(CarrierRouteManager.Get(_db, pRouteId));
                }

                if (pContext == ViewContext.Customer)
                {
                    //NOTE: same as ServiceDialPlan
                    return(CustomerRouteManager.Get(_db, pRouteId));
                }

                if (pContext == ViewContext.Service)
                {
                    //NOTE: same as CustomerDialPlan
                    return(CustomerRouteManager.Get(_db, pRouteId));
                }

                throw new NotImplementedException("ViewContext: " + pContext);
            }
        }
コード例 #7
0
 public void DeleteRoute(RatedRouteDto pRoute, ViewContext pContext)
 {
     using (var _db = new Rbr_Db()) {
         using (var _tx = new Transaction(_db, pRoute, pContext)) {
             if (pContext == ViewContext.Carrier)
             {
                 CarrierRouteManager.Delete(_db, pRoute);
             }
             else if (pContext == ViewContext.Customer)
             {
                 CustomerRouteManager.Delete(_db, pRoute);
             }
             else if (pContext == ViewContext.Service)
             {
                 CustomerRouteManager.Delete(_db, pRoute);
             }
             else
             {
                 throw new NotImplementedException("ViewContext: " + pContext);
             }
             _tx.Commit();
         }
     }
 }