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); } } }
//NOTE: no more TermChoices deletion on DialCode change/delete, //we will run BG process to show/mark PartialCovarage and NoCovarage TermChoces in the GUI internal static void UpdateBaseRoute(Rbr_Db pDb, BaseRouteDto pBaseRoute) { var _routeRow = MapToRouteRow(pBaseRoute); pDb.RouteCollection.Update(_routeRow); //pDb.AddChangedObject(new BaseRouteKey(TxType.Delete, 0, 0, _routeRow.Route_id)); }
public void DeleteBaseRoute(BaseRouteDto pBaseRoute) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pBaseRoute)) { RoutingManager.DeleteBaseRoute(_db, pBaseRoute); _tx.Commit(); } } }
//internal static void Add(Rbr_Db pDb, RouteRow pRouteRow/*, DialCodeRow[] pDialCodeRows*/) { // pDb.RouteCollection.Insert(pRouteRow); //} //internal static void Update(Rbr_Db pDb, RouteRow pRouteRow/*, DialCodeRow[] pDialCodeRows*/) { // pDb.RouteCollection.Update(pRouteRow); //} internal static void AddBaseRoute(Rbr_Db pDb, BaseRouteDto pBaseRoute) { var _routeRow = MapToRouteRow(pBaseRoute); pDb.RouteCollection.Insert(_routeRow); pBaseRoute.BaseRouteId = _routeRow.Route_id; if (pBaseRoute.IsProper) { addDialCodeForProperBaseRoute(pDb, pBaseRoute); } }
//public static void AddDialCodes(DialCodeDto[] pDialCodes) { // using (var _db = new Rbr_Db()) { // using (var _tx = new Transaction(_db, pDialCodes)) { // foreach (DialCodeDto _dialCode in pDialCodes) { // CallingPlanManager.AddDialCode(_db, _dialCode); // } // _tx.Commit(); // } // } //} public static void MoveDialCodes(DialCodeDto[] pDialCodes, BaseRouteDto pFromRoute, BaseRouteDto pToRoute) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pDialCodes, pFromRoute, pToRoute)) { //NOTE: not used? RouteRow _fromRouteRow = RoutingManager.MapToRouteRow(pFromRoute); RouteRow _toRouteRow = RoutingManager.MapToRouteRow(pToRoute); foreach (DialCodeDto _dialCode in pDialCodes) { CallingPlanManager.MoveDialCode(_db, _dialCode, _toRouteRow); } _tx.Commit(); } } }
internal static void AddCountriesToCallingPlan(Rbr_Db pDb, CallingPlanDto pCallingPlan, CountryDto[] pSelectedCountries) { foreach (var _country in pSelectedCountries) { var _properBaseRoute = new BaseRouteDto { BaseStatus = Status.Active, CallingPlan = pCallingPlan, Country = _country, Name = string.Concat(_country.Name, AppConstants.SubRouteSeparator, AppConstants.ProperNameSuffix), Version = 0 }; RoutingManager.AddBaseRoute(pDb, _properBaseRoute); } }
//static RouteRow[] mapToRouteRows(BaseRouteDto[] pBaseRoutes) { // ArrayList _list = new ArrayList(); // if (pBaseRoutes != null) { // foreach (BaseRouteDto _route in pBaseRoutes) { // RouteRow _routeRow = MapToRouteRow(_route); // _list.Add(_routeRow); // } // } // return (RouteRow[])_list.ToArray(typeof(RouteRow)); //} internal static RouteRow MapToRouteRow(BaseRouteDto pBaseRoute) { if (pBaseRoute == null) { return(null); } var _routeRow = new RouteRow(); _routeRow.Route_id = pBaseRoute.BaseRouteId; _routeRow.Name = pBaseRoute.Name; _routeRow.RouteStatus = pBaseRoute.BaseStatus; _routeRow.Calling_plan_id = pBaseRoute.CallingPlanId; _routeRow.Country_id = pBaseRoute.CountryId; _routeRow.Routing_number = pBaseRoute.RoutingNumber; _routeRow.Version = pBaseRoute.Version; return(_routeRow); }
static BaseRouteDto mapToBaseRoute(RouteRow pRouteRow, CountryDto pCountry, CallingPlanDto pCallingPlan, 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 = pCallingPlan; _baseRoute.Country = pCountry; _baseRoute.RoutingNumber = pRouteRow.Routing_number; _baseRoute.Version = pRouteRow.Version; _baseRoute.RouteState = pRouteState; return(_baseRoute); }
//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); }
void getRouteAndDialCode(int pRouteId, int pRoutingNumber, long pDialedNumber, out BaseRouteDto pRoute, out DialCodeDto pDialCode) { pRoute = RoutingControllerFactory.Create().GetRoute(pRouteId); if (pRoute == null) { throw new Exception(string.Format("RouteId NOT found, {0}", pRouteId)); } if (pRoute.RoutingNumber > 0 && pRoute.RoutingNumber != pRoutingNumber) { throw new Exception(string.Format("Routing Numbers different, {0} != {1}", pRoute.RoutingNumber, pRoutingNumber)); } if (pRoute.RoutingNumber == 0) { // set Routing number and insert pDialed Number, duplicate error is Ok, log and swallow pRoute.RoutingNumber = pRoutingNumber; RoutingControllerFactory.Create().UpdateBaseRoute(pRoute); } pDialCode = new DialCodeDto { BaseRouteId = pRoute.BaseRouteId, CallingPlanId = pRoute.CallingPlanId, Code = pDialedNumber, Version = 0 }; }
public static bool ValidateDialCode(BaseRouteDto pRoute, int pCountryCode, long pDialCode, out string pMsg) { pMsg = string.Empty; if (pCountryCode == 1) { // Canada, USA, ??? //not true anymore // //has to be 3 digits fixed // if (pDialCode.ToString().Length != 4) { // pMsg = "Please enter a 3 digits code."; // return false; // } } else { //other countries if (pRoute.IsProper) { //allow any code } else { //min 1 digit if (pDialCode.ToString().Length - pCountryCode.ToString().Length < 1) { pMsg = "Please enter a minimum 1 digit code."; return(false); } } } using (var _db = new Rbr_Db()) { if (_db.DialCodeCollection.Exists(pRoute.CallingPlanId, pDialCode)) { pMsg = "Dial Code already exists"; return(false); } } DialCodeRow[] _existing; using (var _db = new Rbr_Db()) { _existing = _db.DialCodeCollection.GetIsCovered(pRoute.CallingPlanId, pRoute.BaseRouteId, pCountryCode, pDialCode); } if (_existing != null && _existing.Length > 0) { pMsg = "Dial Code already covered by existing Dial Code [" + _existing[0].Dial_code + "]"; return(false); } if (pRoute.IsProper && pCountryCode == pDialCode) { //allow to add CountryCode as DialCode for Proper } else { using (var _db = new Rbr_Db()) { _existing = _db.DialCodeCollection.GetWillCover(pRoute.CallingPlanId, pRoute.BaseRouteId, pDialCode); } if (_existing != null && _existing.Length > 0) { pMsg = "Dial Code covers at least one existing Dial Code [" + _existing[0].Dial_code + "]"; return(false); } } return(true); }
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 RatedRouteDto mapToRoute(WholesaleRouteRow pWholesaleRouteRow, int pRoutingPlanId, RoutingAlgorithmType pRoutingAlgorithmType, ServiceDto pService, BaseRouteDto pBaseRoute, RouteState pRouteState) { if (pWholesaleRouteRow == null) { return(null); } var _route = new RatedRouteDto { RatedRouteId = pWholesaleRouteRow.Wholesale_route_id, AccountId = pService.ServiceId, AccountName = pService.Name, AccountStatus = pService.Status, RoutingPlanId = pRoutingPlanId, Algorithm = pRoutingAlgorithmType, Status = pWholesaleRouteRow.RouteStatus, BaseRoute = pBaseRoute, RouteState = pRouteState, DefaultRatingInfo = pService.DefaultRatingInfo }; return(_route); }
static RoutingPlanDetailDto mapToRoutingPlanDetail(RoutingPlanDetailRow pRoutingPlanDetailRow, BaseRouteDto pBaseRoute, RoutingPlanDto pRoutingPlan, RouteState pRoutingPlanDetailRouteState) { if (pRoutingPlanDetailRow == null) { return(null); } var _routingPlanDetail = new RoutingPlanDetailDto(); _routingPlanDetail.RoutingPlan = pRoutingPlan; _routingPlanDetail.BaseRoute = pBaseRoute; _routingPlanDetail.Algorithm = pRoutingPlanDetailRow.Algorithm; _routingPlanDetail.RouteState = pRoutingPlanDetailRouteState; return(_routingPlanDetail); }
internal static void DeleteBaseRoute(Rbr_Db pDb, BaseRouteDto pBaseRoute) { //NOTE: NO DELETE, Archice only pBaseRoute.BaseStatus = Status.Archived; UpdateBaseRoute(pDb, pBaseRoute); }