public static void DeleteAcct(CustomerAcctDto pCustomerAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pCustomerAcct)) { //TODO: HasCDRs should become CustomerAcct property !!! if (CDRController.HasCDRsByCustomerAcctId(pCustomerAcct.CustomerAcctId)) { pCustomerAcct.Status = Status.Archived; CustomerAcctManager.UpdateAcct(_db, pCustomerAcct); return; } LoadBalancingMapManager.Delete(_db, pCustomerAcct); if (pCustomerAcct.ServiceType == ServiceType.Retail) { int _retailAcctsCount = RetailAccountManager.Instance.GetCount(_db, pCustomerAcct.CustomerAcctId); if (_retailAcctsCount > 0) { throw new Exception("Cannot delete Customer Account, it has Retail Accounts."); } ServiceManager.SaveAccessNumbers(_db, pCustomerAcct); //delete/unassign CustomerAcct's AccessNumbers... } CustomerAcctManager.DeleteResellAccountByCustomerAcctId(_db, pCustomerAcct.CustomerAcctId); CustomerAcctManager.DeleteDialPeersByCustomerAcctId(_db, pCustomerAcct.CustomerAcctId); CustomerAcctManager.DeleteAcct(_db, pCustomerAcct.CustomerAcctId); //if (pCustomerAcct.ServiceDto.IsDedicated) { // ServiceManager.DeleteService(_db, pCustomerAcct.ServiceDto); //} _tx.Commit(); } } }
public static void Update(ServiceDto pService) { using (Rbr_Db _db = new Rbr_Db()) { using (Transaction _tx = new Transaction(_db, pService)) { ServiceRow _originalServiceRow = ServiceManager.Get(_db, pService.ServiceId); ServiceManager.UpdateService(_db, pService); //TODO: NEW DAL - !!! check the logic if (pService.IsShared && pService.DefaultRoutingPlanId != _originalServiceRow.Default_routing_plan_id) { //NOTE: RoutingPlan changed - set same RoutingPlan for Customers using this Shared Service, //BUT ONLY for those Customers that did NOT overwrote the RoutingPlan CustomerAcctRow[] _customerAcctRows = _db.CustomerAcctCollection.GetByService_id(pService.ServiceId); foreach (CustomerAcctRow _customerAcctRow in _customerAcctRows) { if (_customerAcctRow.Routing_plan_id == _originalServiceRow.Default_routing_plan_id) { _customerAcctRow.Routing_plan_id = pService.DefaultRoutingPlanId; CustomerAcctManager.UpdateAcct(_db, _customerAcctRow); } } } _tx.Commit(); } } }
public static void DeleteCabina(short pEndPointId, short pCustomerAcctId, string pPrefix) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndPointId, pCustomerAcctId, pPrefix)) { CustomerAcctManager.DeleteDialPeer(_db, pEndPointId, pPrefix); _tx.Commit(); } } }
public static void DeleteSelectedDialPeersForCustomer(EndPointRow[] pEndpointRows, CustomerAcctDto pCustomerAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointRows, pCustomerAcct)) { foreach (var _endPointRow in pEndpointRows) { CustomerAcctManager.DeleteDialPeer(_db, _endPointRow.End_point_id, pCustomerAcct.PrefixIn); } _tx.Commit(); } } }
public static void UpdateAcct(CustomerAcctDto pCustomerAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pCustomerAcct)) { CustomerAcctRow _original = CustomerAcctManager.Get(_db, pCustomerAcct.CustomerAcctId); if (pCustomerAcct.ServiceDto.IsDedicated) { //-- Dedicated, make sure dp's name is created by cust's name pCustomerAcct.ServiceDto.Name = AppConstants.CustomerServiceNamePrefix + pCustomerAcct.Name; //-- Make sure RoutingPlan is the same for Dedicated Service pCustomerAcct.ServiceDto.DefaultRoutingPlan = pCustomerAcct.RoutingPlan; ServiceManager.UpdateService(_db, pCustomerAcct.ServiceDto); } ServiceManager.SaveAccessNumbers(_db, pCustomerAcct); CustomerAcctManager.UpdateAcct(_db, pCustomerAcct); if (pCustomerAcct.PrefixIn != _original.Prefix_in) { CustomerAcctManager.UpdateCustomerDialPeers(_db, pCustomerAcct.CustomerAcctId, pCustomerAcct.PrefixIn, _original.Prefix_in); } if (pCustomerAcct.ResellAccount != null) { CustomerAcctManager.UpdateResellAccount(_db, pCustomerAcct.ResellAccount); } #region TODO: for the next rev //if (CurrentNode.Instance.BelongsToStandalonePlatform) { // //add LB Map for the actual acct only, not the resell one // LoadBalancingMapManager.Add(_db, CurrentNode.Instance.Id, pCustomerAcct.CustomerAcctId); //} //else { // //TODO: !!!!! review it // // if ( ! _original.IsPrepaid && pCustomerAcct.CustomerAcctRow.IsPrepaid) { // // //TODO: check the logic // // //if changed to Prepaid - delete all LB Maps // // //user will need to pick Node manually // // _db.LoadBalancingMapCollection.DeleteByCustomer_acct_id(pCustomerAcct.CustomerAcctRow.Customer_acct_id); // // } //} #endregion for the next rev _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 DeleteDialPeer(EndPointRow pEndpointRow, CustomerAcctDto pCustomerAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointRow, pCustomerAcct)) { CustomerAcctManager.DeleteDialPeer(_db, pEndpointRow.End_point_id, pCustomerAcct.PrefixIn); if (pCustomerAcct.ServiceDto.ServiceType == ServiceType.Retail) { foreach (var _accessNumberDto in pCustomerAcct.ServiceDto.AccessNumbers) { CustomerAcctManager.DeleteDialPeer(_db, pEndpointRow.End_point_id, _accessNumberDto.Number.ToString()); } } _tx.Commit(); } } }
public static void Credit(PersonDto pPerson, CustomerAcctPaymentDto pCustomerAcctPayment) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pPerson, pCustomerAcctPayment)) { pCustomerAcctPayment.DateTime = DateTime.Now; //NOTE: make sure we got prev amnt CustomerAcctRow _customerAcctRow = CustomerAcctManager.Get(_db, pCustomerAcctPayment.CustomerAcctId); pCustomerAcctPayment.PreviousAmount = _customerAcctRow.Current_amount; pCustomerAcctPayment.Person = pPerson; CustomerAcctManager.Credit(_db, pCustomerAcctPayment); _tx.Commit(); PartnerDto _partner = PartnerManager.Get(_db, _customerAcctRow.Partner_id); ContactInfoDto _contactInfo = ContactInfoManager.Get(_db, _partner.ContactInfo.ContactInfoId); sendNotification(pPerson, pCustomerAcctPayment, _customerAcctRow, _partner, _contactInfo); } } }
public static CustomerAcctDto[] GetActivePrepaidResellCustomerAccts(int pPartnerId) { CustomerAcctDto[] _customerAccts; using (var _db = new Rbr_Db()) { _customerAccts = CustomerAcctManager.GetAllResellAcctsByPartnerId(_db, pPartnerId); } if (_customerAccts != null && _customerAccts.Length > 0) { var _customerAcctList = new List <CustomerAcctDto>(); foreach (CustomerAcctDto _customerAcctDto in _customerAccts) { if (_customerAcctDto.IsPrepaid && _customerAcctDto.Status == Status.Active) { _customerAcctList.Add(_customerAcctDto); } } return(_customerAcctList.ToArray()); } return(null); }
public static void AddDialPeersForEndpoint(short pEndpointId, string pPrefix, short pCustomerAcctId, RetailType pRetailType) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointId, pPrefix, pCustomerAcctId, pRetailType)) { var _endpointRow = EndpointManager.Get(_db, pEndpointId); if (_endpointRow == null) { throw new Exception(string.Format("Endpoint NOT FOUND, EndpointId={0}", pEndpointId)); } var _dialPeerRow = CustomerAcctManager.GetDialPeerRow(_db, pEndpointId, pPrefix); if (_dialPeerRow == null) { _dialPeerRow = new DialPeerRow { End_point_id = pEndpointId, Prefix_in = pPrefix, Customer_acct_id = pCustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _dialPeerRow, _endpointRow); } //-- If Retail, add accessNumber DialPeers if (pRetailType == RetailType.PhoneCard || pRetailType == RetailType.Residential) { var _accessNumberRows = ServiceManager.GetAccessNumbers(_db, pCustomerAcctId); foreach (var _accessNumberRow in _accessNumberRows) { _dialPeerRow = new DialPeerRow { End_point_id = pEndpointId, Prefix_in = _accessNumberRow.Access_number.ToString(), Customer_acct_id = pCustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _dialPeerRow, _endpointRow); } } _tx.Commit(); } } }
public static void DeleteEndpoint(EndPointRow pEndPointRow) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndPointRow)) { CustomerAcctManager.DeleteDialPeersByEndpointId(_db, pEndPointRow.End_point_id); //- Delete Carrier Dialpeers var _dialPeers = _db.CarrierAcctEPMapCollection.GetByEnd_point_id(pEndPointRow.End_point_id); if (_dialPeers != null && _dialPeers.Length > 0) { foreach (var _carrierAcctEPMapRow in _dialPeers) { CarrierAcctManager.DeleteDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); } } EndpointManager.Delete(_db, pEndPointRow); _tx.Commit(); } } }
public static void AddDialPeers(EndPointRow[] pEndpointRows, CustomerAcctDto pCustomerAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointRows, pCustomerAcct)) { foreach (var _endPointRow in pEndpointRows) { if (pCustomerAcct != null) { var _newDialPeer = new DialPeerRow { End_point_id = _endPointRow.End_point_id, Prefix_in = pCustomerAcct.PrefixIn, Customer_acct_id = pCustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, _endPointRow); } } _tx.Commit(); } } }
public static void ReassignDialPeer(EndPointRow pEndpointRow, CustomerAcctDto pFromCustomerAcct, CustomerAcctDto pToCustomerAcct) { if (pEndpointRow.WithInPrefixes || pFromCustomerAcct.WithPrefixes || pToCustomerAcct.WithPrefixes) { throw new Exception("Invalid operation: expecting Endpoint and Customer without Prefixes ONLY."); } using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointRow, pFromCustomerAcct, pToCustomerAcct)) { CustomerAcctManager.DeleteDialPeer(_db, pEndpointRow.End_point_id, pFromCustomerAcct.PrefixIn); var _newDialPeerRow = new DialPeerRow { End_point_id = pEndpointRow.End_point_id, Prefix_in = pToCustomerAcct.PrefixIn, Customer_acct_id = pToCustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeerRow, pEndpointRow); _tx.Commit(); } } }
public static void Delete(PartnerDto pPartner) { using (Rbr_Db _db = new Rbr_Db()) { using (Transaction _tx = new Transaction(_db, pPartner)) { if (CustomerAcctManager.Exist(_db, pPartner.PartnerId)) { throw new ApplicationException("Partner has Customer Account(s).\r\nCannot delete."); } if (CarrierAcctManager.Exist(_db, pPartner.PartnerId)) { throw new ApplicationException("Partner has Carrier Account(s).\r\nCannot delete."); } //TODO: NEW DAL !!! //ResellAcctManager.DeleteByPartnerId(_db, pPartner.PartnerId); PersonManager.DeleteByPartnerId(_db, pPartner.PartnerId); PartnerManager.Delete(_db, pPartner); _tx.Commit(); } } }
public static void AddChangingEndpointPrefixType(EndPointRow pEndpointRow, CustomerAcctDto pCustomerAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointRow, pCustomerAcct)) { EndpointManager.UpdatePrefixType(_db, pEndpointRow, pCustomerAcct.PrefixInTypeId); var _endpointContext = new EndpointContext { CustomerAcct = pCustomerAcct }; if (_endpointContext.CustomerAcct != null) { var _newDialPeer = new DialPeerRow { End_point_id = pEndpointRow.End_point_id, Prefix_in = _endpointContext.CustomerAcct.PrefixIn, Customer_acct_id = _endpointContext.CustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndpointRow); } _tx.Commit(); } } }
public static List <CabinaDto> GetCabinas(CustomerAcctDto pCustomerAcct) { var _cabinas = new List <CabinaDto>(); using (var _db = new Rbr_Db()) { DialPeerRow[] _dialPeerRows = CustomerAcctManager.GetDialPeersByAcctId(_db, pCustomerAcct.CustomerAcctId); if (_dialPeerRows != null && _dialPeerRows.Length > 0) { EndPointRow[] _endPointRows = EndpointManager.GetAllByCustomerAcct(_db, pCustomerAcct.CustomerAcctId); if (_endPointRows != null && _endPointRows.Length > 0) { foreach (DialPeerRow _dialpeerRow in _dialPeerRows) { if (_dialpeerRow.Prefix_in != string.Empty && _dialpeerRow.Prefix_in != "#") { var _cabina = new CabinaDto(_dialpeerRow.End_point_id, getIP(_endPointRows, _dialpeerRow.End_point_id), _dialpeerRow.Prefix_in, _dialpeerRow.Customer_acct_id); _cabinas.Add(_cabina); } } } } } return(_cabinas); }
public static void AddAcctAndRoutes(CustomerAcctDto pCustomerAcct, int[] pSelectedBaseRouteIds) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pCustomerAcct, pSelectedBaseRouteIds)) { try { CustomerAcctManager.AddCustomerAcctsAndRoutes(_db, pCustomerAcct, pSelectedBaseRouteIds); _tx.Commit(); } catch { pCustomerAcct.CustomerAcctId = 0; if (pCustomerAcct.ServiceDto != null && pCustomerAcct.ServiceDto.IsDedicated) { pCustomerAcct.ServiceDto.ServiceId = 0; } if (pCustomerAcct.ResellAccount != null) { pCustomerAcct.ResellAccount.ResellAccountId = 0; } throw; } } } }
public static CustomerAcctDto[] GetAcctsByPartnerId(int pPartnerId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetAcctsByPartnerId(_db, pPartnerId)); } }
public static CustomerAcctDto[] GetAccts() { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetAccts(_db)); } }
public static int GetDialPeerCountByEndpointId(short pEndpointId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetDialPeerCountByEndpointId(_db, pEndpointId)); } }
public static DialPeerRow[] GetDialPeersByAcctId(short pCustomerAcctId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetDialPeersByAcctId(_db, pCustomerAcctId)); } }
public static PrefixInTypeDto[] GetPrefixInTypes() { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetPrefixInTypes(_db)); } }
public static PrefixInTypeDto[] GetPrefixInTypes(short pExcludePrefixInTypeId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetPrefixInTypes(_db, pExcludePrefixInTypeId)); } }
public static int GetCabinasCount(short pCustomerAcctId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetDialPeerCountByAcctId(_db, pCustomerAcctId) - 1); } }
public static string GetPrefixTypeDescription(short pPrefixInTypeId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetPrefixInTypeDescription(_db, pPrefixInTypeId)); } }
public static PrefixInTypeDto GetPrefixType(short pPrefixInTypeId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetPrefixInType(_db, pPrefixInTypeId)); } }
public static CustomerAcctDto GetAcct(short pCustomerAcctId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetAcct(_db, pCustomerAcctId)); } }
public static DialPeerViewRow GetDialPeer(short pEndpointId, string pPrefix) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetDialPeer(_db, pEndpointId, pPrefix)); } }
public static CustomerAcctDto[] GetAcctsByRoutingPlanId(int pRoutingPlanId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetAcctsByRoutingPlanId(_db, pRoutingPlanId)); } }
public static OutDialPeerViewRow[] GetAllOutDialPeers(short pEndpointId) { using (var _db = new Rbr_Db()) { return(CustomerAcctManager.GetDialPeerViewsByEndPointId(_db, pEndpointId)); } }