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; }
public static void AddDialPeerByCountry(CarrierAcctDto pCarrierAcct, EndPointRow pEndPointRow, CountryDto pCountry) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pCarrierAcct, pEndPointRow, pCountry)) { var _countryCarrierRoutes = CarrierAcctManager.GetByCarrierAcctIdCountryId(_db, pCarrierAcct.CarrierAcctId, pCountry.CountryId); var _list = new ArrayList(); foreach (var _carrierRouteRow in _countryCarrierRoutes) { var _carrierAcctEPMapRow = new CarrierAcctEPMapRow { Carrier_acct_id = pCarrierAcct.CarrierAcctId, Carrier_route_id = _carrierRouteRow.Carrier_route_id, End_point_id = pEndPointRow.End_point_id, Priority = 0 }; if (!_list.Contains(_carrierAcctEPMapRow)) { _list.Add(_carrierAcctEPMapRow); } } if (_list.Count > 0) { var _carrierAcctEPMapRows = (CarrierAcctEPMapRow[])_list.ToArray(typeof(CarrierAcctEPMapRow)); foreach (var _carrierAcctEPMapRow in _carrierAcctEPMapRows) { CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); } } _tx.Commit(); } } }
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); }
static RatedRouteDto mapToRoute(CarrierRouteRow pCarrierRouteRow, CarrierAcctDto pCarrierAcct, BaseRouteDto pBaseRoute, RouteState pCarrierRouteState) { if (pCarrierRouteRow == null) { return(null); } var _route = new RatedRouteDto(); _route.RatedRouteId = pCarrierRouteRow.Carrier_route_id; _route.Status = pCarrierRouteRow.RouteStatus; _route.ACDTarget = pCarrierRouteRow.Acd_target; _route.ACDTimeWindow = pCarrierRouteRow.Acd_time_window; _route.ASRTarget = pCarrierRouteRow.Asr_target; _route.ASRTimeWindow = pCarrierRouteRow.Asr_time_window; _route.NextEP = pCarrierRouteRow.Next_ep; _route.AccountId = pCarrierAcct.CarrierAcctId; _route.AccountName = pCarrierAcct.Name; _route.AccountStatus = pCarrierAcct.Status; _route.BaseRoute = pBaseRoute; _route.RouteState = pCarrierRouteState; _route.DefaultRatingInfo = pCarrierAcct.DefaultRatingInfo; return(_route); }
static CarrierAcctDto mapToCarrierAcct(CarrierAcctRow pCarrierAcctRow, PartnerDto pPartner, CallingPlanDto pCallingPlan) { if (pCarrierAcctRow == null) { return(null); } if (pPartner == null) { return(null); } if (pCallingPlan == null) { return(null); } var _carrierAcct = new CarrierAcctDto { CarrierAcctId = pCarrierAcctRow.Carrier_acct_id, IntlDialCode = pCarrierAcctRow.Intl_dial_code, Name = pCarrierAcctRow.Name, Strip1Plus = pCarrierAcctRow.Strip1plus, PrefixOut = pCarrierAcctRow.Prefix_out, Status = pCarrierAcctRow.AccountStatus, RatingType = pCarrierAcctRow.RatingType, MaxCallLength = pCarrierAcctRow.MaxCallLength, Partner = pPartner, CallingPlan = pCallingPlan }; return(_carrierAcct); }
//-------------------- Carrier Acct -------------------------------------------- internal static void AddCarrierAcct(Rbr_Db pDb, CarrierAcctDto pCarrierAcct) { var _carrierAcctRow = mapToCarrierAcctRow(pCarrierAcct); pDb.CarrierAcctCollection.Insert(_carrierAcctRow); pCarrierAcct.CarrierAcctId = _carrierAcctRow.Carrier_acct_id; }
public static void UpdateAcct(CarrierAcctDto pCarrierAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pCarrierAcct)) { CarrierAcctManager.UpdateCarrierAcct(_db, pCarrierAcct); _tx.Commit(); } } }
public static void DeleteDialPeerByRoute(CarrierAcctDto pCarrierAcct, EndPointRow pEndPointRow, RatedRouteDto pCarrierRoute) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pCarrierAcct, pEndPointRow, pCarrierRoute)) { var _carrierAcctEPMapRow = CarrierAcctManager.GetDialPeer(_db, pCarrierAcct.CarrierAcctId, pEndPointRow.End_point_id, pCarrierRoute.RatedRouteId); CarrierAcctManager.DeleteDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); _tx.Commit(); } } }
protected CarrierAcctDto getCarrierAcct(Rbr_Db _db) { CarrierAcctDto _carrierAcct = CarrierAcctManager.GetAcct(_db, args.AccountId); if (_carrierAcct == null) { throw new Exception("CarrierAcct not found [Id: " + args.AccountId + "]"); } return(_carrierAcct); }
internal static void Add(Rbr_Db pDb, CarrierAcctDto pCarrierAcct, int[] pSelectedBaseRouteIds) { if (pCarrierAcct != null && pSelectedBaseRouteIds != null && pSelectedBaseRouteIds.Length > 0) { foreach (int _baseRouteId in pSelectedBaseRouteIds) { int _carrierRouteId; Add(pDb, pCarrierAcct, _baseRouteId, out _carrierRouteId); } } }
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)); }
public static void DeleteDialPeerByCountry(CarrierAcctDto pCarrierAcct, EndPointRow pEndPointRow, CountryDto pCountry) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pCarrierAcct, pEndPointRow, pCountry)) { //CarrierAcctManager.DeleteDialPeerByCountry(_db, pCarrierAcct, pCountry, pEndPointRow); var _countryCarrierRoutes = CarrierAcctManager.GetByCarrierAcctIdCountryId(_db, pCarrierAcct.CarrierAcctId, pCountry.CountryId); var _carrierAcctEPMapRows = CarrierAcctManager.GetByCountry(_db, _countryCarrierRoutes, pCarrierAcct.CarrierAcctId, pEndPointRow.End_point_id); foreach (var _carrierAcctEPMapRow in _carrierAcctEPMapRows) { CarrierAcctManager.DeleteDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); } _tx.Commit(); } } }
public static void AddDialPeerByRoute(CarrierAcctDto pCarrierAcct, EndPointRow pEndPointRow, RatedRouteDto pCarrierRoute) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pCarrierAcct, pEndPointRow, pCarrierRoute)) { var _carrierAcctEPMapRow = new CarrierAcctEPMapRow { Carrier_acct_id = pCarrierAcct.CarrierAcctId, Carrier_route_id = pCarrierRoute.RatedRouteId, End_point_id = pEndPointRow.End_point_id, Priority = 0 }; CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); _tx.Commit(); } } }
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(); } } }
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)); }
static CarrierAcctRow mapToCarrierAcctRow(CarrierAcctDto pCarrierAcct) { if (pCarrierAcct == null) { return(null); } var _carrierAcctRow = new CarrierAcctRow(); _carrierAcctRow.Carrier_acct_id = pCarrierAcct.CarrierAcctId; _carrierAcctRow.Intl_dial_code = pCarrierAcct.IntlDialCode; _carrierAcctRow.Name = pCarrierAcct.Name; _carrierAcctRow.Strip1plus = pCarrierAcct.Strip1Plus; _carrierAcctRow.Prefix_out = pCarrierAcct.PrefixOut; _carrierAcctRow.AccountStatus = pCarrierAcct.Status; _carrierAcctRow.RatingType = pCarrierAcct.RatingType; _carrierAcctRow.MaxCallLength = pCarrierAcct.MaxCallLength; _carrierAcctRow.Partner_id = pCarrierAcct.PartnerId; _carrierAcctRow.Calling_plan_id = pCarrierAcct.CallingPlan.CallingPlanId; return(_carrierAcctRow); }
void exportCarrierRates() { try { countries = new SortedList <string, CountryRecord>(); using (var _db = new Rbr_Db()) { CarrierAcctDto _carrierAcct = getCarrierAcct(_db); RouteRow[] _baseRouteRows = _db.RouteCollection.GetByCalling_plan_id(_carrierAcct.CallingPlan.CallingPlanId); if (_baseRouteRows == null || _baseRouteRows.Length <= 0) { reportStatus(LogSeverity.Status, "DialPlanExporter.exportCarrierRates", "WARNING: No Routes to Process..."); return; } _baseRouteRows = RoutingManager.SortRouteRows(_baseRouteRows); string _filePath = getFilePath(); using (var _sw = new StreamWriter(_filePath, false)) { _sw.WriteLine(args.PerMinute ? RatesFileHeaderCostPerMinute : RatesFileHeaderCostPerIncrements); int _index = 0; CountryRecord _countryRecord = null; foreach (RouteRow _baseRouteRow in _baseRouteRows) { host.ReportProgress(_index++ *100 / _baseRouteRows.Length); CarrierRouteRow _carrierRouteRow = _db.CarrierRouteCollection.GetByCarrierAcctIdRouteId(_carrierAcct.CarrierAcctId, _baseRouteRow.Route_id); if (_carrierRouteRow == null) { continue; } if (_countryRecord == null || _countryRecord.Name != _baseRouteRow.Name) { _countryRecord = getCountryRecord(_db, _baseRouteRow); } RouteRecord _routeRecord = getRouteRecord(_baseRouteRow, _countryRecord); _countryRecord.Routes.Add(_routeRecord.FullName, _routeRecord); CarrierRateHistoryRow _carrierRateHistoryRow = _db.CarrierRateHistoryCollection.GetByCarrierRouteIdDate(_carrierRouteRow.Carrier_route_id, DateTime.Today); if (_carrierRateHistoryRow != null) { RatingInfoDto _ratingInfo = RatingManager.GetRatingInfo(_db, _carrierRateHistoryRow.Rate_info_id, false); if (_ratingInfo == null) { reportStatus(LogSeverity.Critical, "DialPlanExporter.exportCarrierRates", string.Format("RatingInfo == null, {0}", _carrierRateHistoryRow.Rate_info_id)); continue; } _routeRecord.RatingInfo = _ratingInfo; reportStatus(LogSeverity.Status, "DialPlanExporter.exportCarrierRates", string.Format("Exporting Rates for Route: {0}", _routeRecord.FullName)); _sw.Write(_routeRecord.GetRatesAsString(args.PerMinute)); } } } } } catch (Exception _ex) { TimokLogger.Instance.LogRbr(LogSeverity.Critical, "DialPlanExporter.exportCarrierRates", _ex.ToString()); throw; } }
public CarrierCdrExportInfo(CarrierAcctDto pCarrierAcct, string pExportDirectory, DateTime pDateStart, DateTime pDateEnd, CdrExportMapDto pCdrExportMap, string pDecimalFormatString, ViewContext pContext, bool pWithRerating) : base(pExportDirectory, pDateStart, pDateEnd, pCdrExportMap, pDecimalFormatString, pContext, pWithRerating) { CarrierAcctDto = pCarrierAcct; }