示例#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 Result DeleteRoutingPlanDetail(RoutingPlanDetailDto pRoutingPlanDetail)
        {
            var _result = new Result(true, string.Empty);

            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pRoutingPlanDetail)) {
                    try {
                        var _wholesaleRouteCount = CustomerRouteManager.GetCount(_db, pRoutingPlanDetail.BaseRouteId);
                        if (_wholesaleRouteCount > 0)
                        {
                            throw new Exception("Cannot delete Routing Plan Route, it's used in one or more Wholesale Dial Plans");
                        }
                        var _retailRouteCount = 0;                         //TODO: X_Controller.GetRetailRouteCount(_db, pRoutingPlanDetail.BaseRouteId);
                        if (_retailRouteCount > 0)
                        {
                            throw new Exception("Cannot delete Routing Plan Route, it's used in one or more Retail Dial Plans");
                        }

                        RoutingManager.DeleteRoutingPlanDetail(_db, pRoutingPlanDetail);
                        _tx.Commit();
                    }
                    catch (Exception _ex) {
                        _result.Success      = false;
                        _result.ErrorMessage = _ex.Message;
                        TimokLogger.Instance.LogRbr(LogSeverity.Critical, "RoutingController.DeleteRoutingPlanDetail", string.Format("Exception:\r\n{0}", _ex));
                    }
                }
            }
            return(_result);
        }
示例#3
0
 protected int getWholesaleRouteId(Rbr_Db pDb, short pServiceId, int pBaseRouteId, int pRoutingPlanId)
 {
     try {
         RatedRouteDto _wholesaleRoute = CustomerRouteManager.GetRouteByServiceIdBaseRouteId(pDb, pServiceId, pBaseRouteId, pRoutingPlanId);
         if (_wholesaleRoute == null)
         {
             string _msg = string.Format("Skipping Route, doesn't exists in DialPlan. {0}, {1}, {2}.", pServiceId, pBaseRouteId, pRoutingPlanId);
             TimokLogger.Instance.LogRbr(LogSeverity.Error, "ServiceController.importRatesOnly", string.Format("{0}", _msg));
             Host.ReportStatus(_msg);
             return(0);
         }
         if (_wholesaleRoute.RoutingPlanId <= 0)
         {
             string _msg = string.Format("Skipping Route, doesn't exists in RoutingPlan. {0}, {1}, {2}.", pServiceId, pBaseRouteId, pRoutingPlanId);
             TimokLogger.Instance.LogRbr(LogSeverity.Error, "ServiceController.importRatesOnly", string.Format("ServiceController.importRatesOnly | {0}", _msg));
             Host.ReportStatus(_msg);
             return(0);
         }
         return(_wholesaleRoute.RatedRouteId);
     }
     catch (Exception _ex) {
         string _msg = string.Format("ERROR: {0}, Retreiving WholesaleRoute: {1}, {2}, {3}", pServiceId, pBaseRouteId, pRoutingPlanId, _ex.Message);
         Host.ReportStatus(_msg);
         TimokLogger.Instance.LogRbr(LogSeverity.Error, "RatesImporter.getWholesaleRoute", string.Format("{0}\r\n{1}", _msg, _ex));
         throw;
     }
 }
示例#4
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);
            }
        }
示例#5
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);
            }
        }
示例#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();
         }
     }
 }