예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        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();
                }
            }
        }
예제 #3
0
 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();
         }
     }
 }
예제 #4
0
 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();
         }
     }
 }
예제 #5
0
        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();
                }
            }
        }
예제 #6
0
        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();
                }
            }
        }
예제 #7
0
 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();
         }
     }
 }
예제 #8
0
        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);
                }
            }
        }
예제 #9
0
 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);
 }
예제 #10
0
        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();
                }
            }
        }
예제 #11
0
        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();
                }
            }
        }
예제 #12
0
 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();
         }
     }
 }
예제 #13
0
        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();
                }
            }
        }
예제 #14
0
        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();
                }
            }
        }
예제 #15
0
        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();
                }
            }
        }
예제 #16
0
        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);
        }
예제 #17
0
        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;
                    }
                }
            }
        }
예제 #18
0
 public static CustomerAcctDto[] GetAcctsByPartnerId(int pPartnerId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetAcctsByPartnerId(_db, pPartnerId));
     }
 }
예제 #19
0
 public static CustomerAcctDto[] GetAccts()
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetAccts(_db));
     }
 }
예제 #20
0
 public static int GetDialPeerCountByEndpointId(short pEndpointId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetDialPeerCountByEndpointId(_db, pEndpointId));
     }
 }
예제 #21
0
 public static DialPeerRow[] GetDialPeersByAcctId(short pCustomerAcctId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetDialPeersByAcctId(_db, pCustomerAcctId));
     }
 }
예제 #22
0
 public static PrefixInTypeDto[] GetPrefixInTypes()
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetPrefixInTypes(_db));
     }
 }
예제 #23
0
 public static PrefixInTypeDto[] GetPrefixInTypes(short pExcludePrefixInTypeId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetPrefixInTypes(_db, pExcludePrefixInTypeId));
     }
 }
예제 #24
0
 public static int GetCabinasCount(short pCustomerAcctId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetDialPeerCountByAcctId(_db, pCustomerAcctId) - 1);
     }
 }
예제 #25
0
 public static string GetPrefixTypeDescription(short pPrefixInTypeId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetPrefixInTypeDescription(_db, pPrefixInTypeId));
     }
 }
예제 #26
0
 public static PrefixInTypeDto GetPrefixType(short pPrefixInTypeId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetPrefixInType(_db, pPrefixInTypeId));
     }
 }
예제 #27
0
 public static CustomerAcctDto GetAcct(short pCustomerAcctId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetAcct(_db, pCustomerAcctId));
     }
 }
예제 #28
0
 public static DialPeerViewRow GetDialPeer(short pEndpointId, string pPrefix)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetDialPeer(_db, pEndpointId, pPrefix));
     }
 }
예제 #29
0
 public static CustomerAcctDto[] GetAcctsByRoutingPlanId(int pRoutingPlanId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetAcctsByRoutingPlanId(_db, pRoutingPlanId));
     }
 }
예제 #30
0
 public static OutDialPeerViewRow[] GetAllOutDialPeers(short pEndpointId)
 {
     using (var _db = new Rbr_Db()) {
         return(CustomerAcctManager.GetDialPeerViewsByEndPointId(_db, pEndpointId));
     }
 }