internal static CustomerAcctSupportMapDto GetCustomerAcctSupportMap(Rbr_Db pDb, short pCustomerAcctId, int pVendorId) { CustomerAcctSupportMapRow _customerAcctSupportMapRow = pDb.CustomerAcctSupportMapCollection.GetByPrimaryKey(pCustomerAcctId, pVendorId); CustomerAcctDto _customerAcct = CustomerAcctManager.GetAcct(pDb, pCustomerAcctId); return(mapToCustomerAcctSupportMap(_customerAcctSupportMapRow, _customerAcct)); }
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(); } } }
internal static CustomerAcctSupportMapDto[] GetAllCustomerAcctSupportMaps(Rbr_Db pDb, int pVendorId) { ArrayList _list = new ArrayList(); //get mapped CustomerAcctSupportMapRow[] _customerAcctSupportMapRows = pDb.CustomerAcctSupportMapCollection.GetByVendor_id(pVendorId); foreach (CustomerAcctSupportMapRow _customerAcctSupportMapRow in _customerAcctSupportMapRows) { CustomerAcctDto _customerAcct = CustomerAcctManager.GetAcct(pDb, _customerAcctSupportMapRow.Customer_acct_id); _list.Add(mapToCustomerAcctSupportMap(_customerAcctSupportMapRow, _customerAcct)); } //get unmapped too, as not Assigned CustomerAcctDto[] _unmappedCustomerAccts = CustomerAcctManager.GetUnmapped(pDb, pVendorId); foreach (CustomerAcctDto _unmappedCustomerAcct in _unmappedCustomerAccts) { _list.Add(mapToCustomerAcctSupportMap(null, _unmappedCustomerAcct)); } if (_list.Count > 1) { //TODO: should we sort it by Assigned as well??? _list.Sort(new GenericComparer(CustomerAcctSupportMapDto.CustomerAcctName_PropName, System.ComponentModel.ListSortDirection.Ascending)); } return((CustomerAcctSupportMapDto[])_list.ToArray(typeof(CustomerAcctSupportMapDto))); }
internal static void AddCustomerAcctsAndRoutes(Rbr_Db Db, CustomerAcctDto pCustomerAcct, int[] pSelectedBaseRouteIds) { if (pCustomerAcct.ServiceDto.IsDedicated) { pCustomerAcct.ServiceDto.Name = AppConstants.CustomerServiceNamePrefix + pCustomerAcct.Name; ServiceManager.AddService(Db, pCustomerAcct.ServiceDto, pSelectedBaseRouteIds); } var _customerAcctRow = MapToCustomerAcctRow(pCustomerAcct); Add(Db, _customerAcctRow); pCustomerAcct.CustomerAcctId = _customerAcctRow.Customer_acct_id; if (pCustomerAcct.ServiceDto.IsDedicated) { ServiceManager.SaveAccessNumbers(Db, pCustomerAcct); } if (pCustomerAcct.ResellAccount != null) { pCustomerAcct.ResellAccount.CustomerAcctId = pCustomerAcct.CustomerAcctId; AddResellAccount(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); //} #endregion for the next rev }
static CustomerAcctDto mapToCustomerAcct(CustomerAcctRow pCustomerAcctRow, PartnerDto pPartner) { if (pCustomerAcctRow == null) { return(null); } var _customerAcct = new CustomerAcctDto { CustomerAcctId = pCustomerAcctRow.Customer_acct_id, ServiceId = pCustomerAcctRow.Service_id, RoutingPlanId = pCustomerAcctRow.Routing_plan_id, AllowRerouting = pCustomerAcctRow.AllowRerouting, DefaultBonusMinutesType = pCustomerAcctRow.DefaultBonusMinutesType, DefaultStartBonusMinutes = pCustomerAcctRow.Default_start_bonus_minutes, IsPrepaid = pCustomerAcctRow.IsPrepaid, ConcurrentUse = pCustomerAcctRow.ConcurrentUse, CurrentAmount = pCustomerAcctRow.Current_amount, LimitAmount = pCustomerAcctRow.Limit_amount, Name = pCustomerAcctRow.Name, PrefixIn = pCustomerAcctRow.Prefix_in, PrefixInTypeId = pCustomerAcctRow.Prefix_in_type_id, PrefixOut = pCustomerAcctRow.Prefix_out, Status = pCustomerAcctRow.AccountStatus, WarningAmount = pCustomerAcctRow.Warning_amount, MaxCallLength = pCustomerAcctRow.Max_call_length, Partner = pPartner, ServiceDto = null, RoutingPlan = null }; return(_customerAcct); }
public static void DeleteByCustomerAcct(CustomerAcctDto pCustomerAcct) { using (Rbr_Db _db = new Rbr_Db()) { using (Transaction _tx = new Transaction(_db, pCustomerAcct)) { LoadBalancingMapManager.Delete(_db, pCustomerAcct); _tx.Commit(); } } }
public static void Delete(NodeViewRow pNodeViewRow, CustomerAcctDto pCustomerAcct) { using (Rbr_Db _db = new Rbr_Db()) { using (Transaction _tx = new Transaction(_db, pNodeViewRow, pCustomerAcct)) { LoadBalancingMapRow _loadBalancingMapRow = LoadBalancingMapManager.Get(_db, pNodeViewRow.Node_id, pCustomerAcct.CustomerAcctId); LoadBalancingMapManager.Delete(_db, _loadBalancingMapRow); _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 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 SaveAccessNumbers(Rbr_Db pDb, CustomerAcctDto pCustomerAcct) { if (pCustomerAcct.ServiceDto.RetailType == RetailType.PhoneCard || pCustomerAcct.ServiceDto.RetailType == RetailType.Residential) { if (pCustomerAcct.ServiceDto.AccessNumbers != null) { var _accessNumberListRowsFromView = mapToAccessNumberRows(pCustomerAcct.ServiceDto.AccessNumbers); var _accessNumberRowsFromDb = pDb.AccessNumberListCollection.GetByCustomer_acct_id(pCustomerAcct.CustomerAcctId); detachAccessNumbers(pDb, pCustomerAcct, _accessNumberListRowsFromView, _accessNumberRowsFromDb); attachAccessNumbers(pDb, pCustomerAcct, _accessNumberListRowsFromView); //if (pCustomerAcct.ServiceDto.ServiceId != 0) { //var _serviceRow = mapToServiceRow(pCustomerAcct.ServiceDto); //pDb.AddChangedObject(new ServiceKey(TxType.Delete, _serviceRow.Service_id)); //} } } }
static void attachAccessNumbers(Rbr_Db pDb, CustomerAcctDto pCustomerAcct, IEnumerable <AccessNumberListRow> pAccessNumberRowsFromView) { foreach (var _accessNumberRowFromView in pAccessNumberRowsFromView) { _accessNumberRowFromView.Customer_acct_id = pCustomerAcct.CustomerAcctId; _accessNumberRowFromView.Service_id = pCustomerAcct.ServiceDto.ServiceId; var _accessNumberRowFromDb = pDb.AccessNumberListCollection.GetByPrimaryKey(_accessNumberRowFromView.Access_number); if (_accessNumberRowFromDb == null || _accessNumberRowFromDb.IsCustomer_acct_idNull) { pDb.AccessNumberListCollection.Insert(_accessNumberRowFromView); //-- Add retail_dial_peers var _endpointRows = pDb.EndPointCollection.GetByCustomerAcctId(pCustomerAcct.CustomerAcctId, new[] { Status.Pending, Status.Active, Status.Blocked, Status.Archived }); foreach (var _endpointRow in _endpointRows) { var _dialPeerRow = new DialPeerRow { End_point_id = _endpointRow.End_point_id, Prefix_in = _accessNumberRowFromView.Access_number.ToString(), Customer_acct_id = pCustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(pDb, _dialPeerRow, _endpointRow); } continue; } if (_accessNumberRowFromDb.Customer_acct_id != pCustomerAcct.CustomerAcctId) { var _otherCustomerAcctRow = pDb.CustomerAcctCollection.GetByPrimaryKey(_accessNumberRowFromDb.Customer_acct_id); throw new Exception(string.Format("Access Number={0} already in use by other Customer Account={1}", _accessNumberRowFromView.Access_number, _otherCustomerAcctRow.Name)); } _accessNumberRowFromDb.Customer_acct_id = pCustomerAcct.CustomerAcctId; _accessNumberRowFromDb.Service_id = pCustomerAcct.ServiceDto.ServiceId; _accessNumberRowFromDb.ScriptType = _accessNumberRowFromView.ScriptType; _accessNumberRowFromDb.ScriptLanguage = _accessNumberRowFromView.ScriptLanguage; _accessNumberRowFromDb.Surcharge = _accessNumberRowFromView.Surcharge; _accessNumberRowFromDb.SurchargeType = _accessNumberRowFromView.SurchargeType; pDb.AccessNumberListCollection.Update(_accessNumberRowFromDb); //pDb.AddChangedObject(new AccessNumberKey(TxType.Delete, _accessNumberRowFromDb.Access_number)); } }
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 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(); } } }
static void detachAccessNumbers(Rbr_Db pDb, CustomerAcctDto pCustomerAcct, ICollection <AccessNumberListRow> pAccessNumberRowsFromView, IEnumerable <AccessNumberListRow> pAccessNumberRowsFromDb) { foreach (var _accessNumberRowFromDb in pAccessNumberRowsFromDb) { if (deleted(_accessNumberRowFromDb, pAccessNumberRowsFromView)) { _accessNumberRowFromDb.IsCustomer_acct_idNull = true; _accessNumberRowFromDb.IsService_idNull = true; pDb.AccessNumberListCollection.DeleteByPrimaryKey(_accessNumberRowFromDb.Access_number); //pDb.AddChangedObject(new AccessNumberKey(TxType.Delete, _accessNumberRowFromDb.Access_number)); //-- Remove retail_dial_peers var _dialPeerRows = CustomerAcctManager.GetDialPeersByAcctId(pDb, pCustomerAcct.CustomerAcctId); foreach (var _dialPeerRow in _dialPeerRows) { if (_dialPeerRow.Prefix_in == _accessNumberRowFromDb.Access_number.ToString()) { CustomerAcctManager.DeleteDialPeer(pDb, _dialPeerRow.End_point_id, _dialPeerRow.Prefix_in); } } //pDb.AddChangedObject(new CustomerAcctKey(TxType.Delete, pCustomerAcct.CustomerAcctId)); } } }
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); }
internal static CustomerAcctRow MapToCustomerAcctRow(CustomerAcctDto pCustomerAcct) { if (pCustomerAcct == null) { return(null); } var _customerAcctRow = new CustomerAcctRow { Customer_acct_id = pCustomerAcct.CustomerAcctId, AllowRerouting = pCustomerAcct.AllowRerouting, DefaultBonusMinutesType = pCustomerAcct.DefaultBonusMinutesType, Default_start_bonus_minutes = pCustomerAcct.DefaultStartBonusMinutes, IsPrepaid = pCustomerAcct.IsPrepaid, ConcurrentUse = pCustomerAcct.ConcurrentUse, Current_amount = pCustomerAcct.CurrentAmount, Limit_amount = pCustomerAcct.LimitAmount, Name = pCustomerAcct.Name, Prefix_in = pCustomerAcct.PrefixIn, Prefix_in_type_id = pCustomerAcct.PrefixInTypeId, Prefix_out = pCustomerAcct.PrefixOut, AccountStatus = pCustomerAcct.Status, Warning_amount = pCustomerAcct.WarningAmount, Max_call_length = pCustomerAcct.MaxCallLength, Partner_id = pCustomerAcct.PartnerId, Service_id = pCustomerAcct.ServiceDto.ServiceId, Routing_plan_id = pCustomerAcct.RoutingPlanId }; //TODO: NEW DAL //if (pCustomerAcct.RetailCallingPlan != null) { // _customerAcctRow.Retail_calling_plan_id = pCustomerAcct.RetailCallingPlanId; //} return(_customerAcctRow); }
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; } } } }
static void delete(Rbr_Db pDb, CustomerAcctDto pCustomerAcct) { pDb.LoadBalancingMapCollection.DeleteByCustomer_acct_id(pCustomerAcct.CustomerAcctId); }
internal static void UpdateAcct(Rbr_Db pDb, CustomerAcctDto pCustomerAcct) { pDb.CustomerAcctCollection.Update(MapToCustomerAcctRow(pCustomerAcct)); //pDb.AddChangedObject(new CustomerAcctKey(TxType.Delete, pCustomerAcct.CustomerAcctId)); }
internal static void Delete(Rbr_Db pDb, CustomerAcctDto pCustomerAcct) { delete(pDb, pCustomerAcct); //pDb.AddChangedObject(new CustomerAcctKey(TxType.Delete, pCustomerAcct.CustomerAcctId)); }
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 CustomerCdrExportInfo(CustomerAcctDto pCustomerAcct, string pExportDirectory, DateTime pDateStart, DateTime pDateEnd, CdrExportMapDto pCdrExportMap, string pDecimalFormatString, ViewContext pContext, bool pWithRerating) : base(pExportDirectory, pDateStart, pDateEnd, pCdrExportMap, pDecimalFormatString, pContext, pWithRerating) { CustomerAcct = pCustomerAcct; }
static CustomerAcctSupportMapDto mapToCustomerAcctSupportMap(CustomerAcctSupportMapRow pCustomerAcctSupportMapRow, CustomerAcctDto pCustomerAcct) { if (pCustomerAcct == null) { return(null); } CustomerAcctSupportMapDto _customerAcctSupportMap = new CustomerAcctSupportMapDto(); _customerAcctSupportMap.CustomerAcctId = pCustomerAcct.CustomerAcctId; _customerAcctSupportMap.CustomerAcct = pCustomerAcct; if (pCustomerAcctSupportMapRow != null) { _customerAcctSupportMap.VendorId = pCustomerAcctSupportMapRow.Vendor_id; } _customerAcctSupportMap.Assigned = _customerAcctSupportMap.VendorId != 0; return(_customerAcctSupportMap); }