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(); } } }
public static void UpdateEndpoint(EndPointRow pEndPointRow, EndpointContext pEndpointContext) { //pEndpointContext.TransactionType = TxType.Delete; using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndPointRow, pEndpointContext)) { var _original = EndpointManager.Get(_db, pEndPointRow.End_point_id); EndpointManager.Update(_db, _original, pEndPointRow); if (pEndpointContext.CarrierAcctEPMapRowToDelete != null) { foreach (var _carrierAcctEPMapRow in pEndpointContext.CarrierAcctEPMapRowToDelete) { CarrierAcctManager.DeleteDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); } } if (pEndpointContext.CarrierAcctEPMapRowToAdd != null) { foreach (var _carrierAcctEPMapRow in pEndpointContext.CarrierAcctEPMapRowToAdd) { if (_carrierAcctEPMapRow.Carrier_acct_EP_map_id <= 0) { _carrierAcctEPMapRow.End_point_id = pEndPointRow.End_point_id; CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); } } } _tx.Commit(); } } }
public static void AddEndpoint(EndPointRow pEndPointRow, EndpointContext pEndpointContext) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndPointRow, pEndpointContext)) { //TODO: NEW DAL - VirtualSwitch pEndPointRow.Virtual_switch_id = AppConstants.DefaultVirtualSwitchId; EndpointManager.Add(_db, pEndPointRow, pEndpointContext); //CarrierAcctManager.AddDialPeer(_db, pEndPointRow, pEndpointContext); if (pEndpointContext.CarrierAcctEPMapRowToAdd != null && pEndpointContext.CarrierAcctEPMapRowToAdd.Length > 0) { foreach (var _carrierAcctEPMapRow in pEndpointContext.CarrierAcctEPMapRowToAdd) { _carrierAcctEPMapRow.End_point_id = pEndPointRow.End_point_id; CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); } } if (pEndpointContext.CustomerAcct != null) { if (pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers != null && pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers.Length > 0) { foreach (var _accessNumber in pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers) { var _newDialPeer = new DialPeerRow { End_point_id = pEndPointRow.End_point_id, Prefix_in = _accessNumber.Number.ToString(), Customer_acct_id = pEndpointContext.CustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndPointRow); } } else { var _newDialPeer = new DialPeerRow { End_point_id = pEndPointRow.End_point_id, Prefix_in = pEndpointContext.CustomerAcct.PrefixIn, Customer_acct_id = pEndpointContext.CustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, 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(); } } }