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 }; }
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); } } }
internal static void MoveDialCode(Rbr_Db pDb, DialCodeDto pDialCode, RouteRow pToRouteRow) { //NOTE: no more TermChoices deletion on DialCode change/delete, //we will run BG process to show/mark PartialCovarage and NoCovarage TermChoces in the GUI var _dialCodeRow = mapToDialCodeRow(pDialCode); _dialCodeRow.Route_id = pToRouteRow.Route_id; UpdateDialCode(pDb, _dialCodeRow); }
public static void DeleteDialCode(DialCodeDto pDialCode) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pDialCode)) { CallingPlanManager.DeleteDialCode(_db, pDialCode); _tx.Commit(); } } }
void importRouteDialCodes(RouteRecord pRouteRecord) { Host.ReportStatus(string.Format("Importing Dial Codes for Route: {0}", pRouteRecord.FullName)); using (var _db = new Rbr_Db()) { _db.BeginTransaction(); try { int _countryId = getCountryId(_db, pRouteRecord.CountryName, pRouteRecord.CountryCode); int _routeId = getRouteId(_db, _countryId, pRouteRecord); int _indexDialCode = 0; foreach (long _dialCode in pRouteRecord.DialCodes.Values) { if (Host.CancellationPending) { throw new Exception("Import canceled"); } if (!_dialCode.ToString().StartsWith(pRouteRecord.CountryCode.ToString())) { throw new Exception(string.Format("Invalid Dial Code={0}, CCode={1}", _dialCode, pRouteRecord.CountryCode)); } var _dialCodeDto = new DialCodeDto(); _dialCodeDto.Code = _dialCode; _dialCodeDto.BaseRouteId = _routeId; _dialCodeDto.CallingPlanId = args.CallingPlanId; _dialCodeDto.Version = 0; try { CallingPlanManager.AddDialCode(_db, _dialCodeDto); } catch (Exception _ex) { TimokLogger.Instance.LogRbr(LogSeverity.Debug, "", string.Format("Error inserting dial code: {0}\r\n{1}", _dialCodeDto.Code, _ex)); } if (++_indexDialCode % 10 == 0) { Host.ReportProgress(_indexDialCode * 100 / pRouteRecord.DialCodes.Values.Count); } } Host.ReportStatus(string.Format("Imported total of {0} Dial Codes for Route: {1}", pRouteRecord.DialCodes.Values.Count, pRouteRecord.FullName)); _db.CommitTransaction(); } catch (Exception _ex) { _db.RollbackTransaction(); reportStatus(LogSeverity.Error, "DialPlanImporter.importRouteDialCodes", _ex.Message); throw; } } }
static DialCodeDto mapToDialCode(DialCodeRow_Base pDialCodeRow) { if (pDialCodeRow == null) { return(null); } var _dialCode = new DialCodeDto(); _dialCode.CallingPlanId = pDialCodeRow.Calling_plan_id; _dialCode.Code = pDialCodeRow.Dial_code; _dialCode.BaseRouteId = pDialCodeRow.Route_id; _dialCode.Version = pDialCodeRow.Version; return(_dialCode); }
internal static void DeleteDialCode(Rbr_Db pDb, DialCodeDto pDialCode) { pDb.DialCodeCollection.Delete(mapToDialCodeRow(pDialCode)); //pDb.AddChangedObject(new BaseRouteKey(TxType.Delete, 0, 0, pDialCode.BaseRouteId)); }
internal static void AddDialCode(Rbr_Db pDb, DialCodeDto pDialCode) { pDb.DialCodeCollection.Insert(mapToDialCodeRow(pDialCode)); }