public static void DeletePlatform(PlatformDto pPlatform, out Result pResult) { pResult = new Result(); using (var _db = new Rbr_Db()) { _db.BeginTransaction(); try { var _currNode = PlatformManager.GetNode(_db, CurrentPlatformNode.Id); if (_currNode.Platform_id == pPlatform.PlatformId) { throw new Exception("Cannot delete Current Platform."); } var _platformRow = MapToPlatformRow(pPlatform); PlatformManager.DeletePlatform(_db, _platformRow); _db.CommitTransaction(); } catch (Exception _ex) { _db.RollbackTransaction(); pResult.Success = false; pResult.ErrorMessage = _ex.Message; TimokLogger.Instance.LogRbr(LogSeverity.Critical, "PlatformController.DeletePlatform", string.Format("Exception:\r\n{0}", _ex)); } } }
public static void DeleteNode(NodeDto pNode, out Result pResult) { pResult = new Result(); using (var _db = new Rbr_Db()) { _db.BeginTransaction(); try { if (pNode.NodeId == (new CurrentNode()).Id) { throw new Exception("Cannot Delete Current Node."); } //LoadBalancingMapManager.Delete(_db, pNode); var _nodeRow = MapToNodeRow(pNode); PlatformManager.DeleteNode(_db, _nodeRow); _db.CommitTransaction(); } catch (Exception _ex) { _db.RollbackTransaction(); pResult.Success = false; pResult.ErrorMessage = _ex.Message; TimokLogger.Instance.LogRbr(LogSeverity.Critical, "PlatformController.DeleteNode", string.Format("Exception:\r\n{0}", _ex)); } } }
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 void AddPlatform(PlatformDto pPlatform, out Result pResult) { pResult = new Result(); using (var _db = new Rbr_Db()) { _db.BeginTransaction(); try { if (PlatformManager.IsLocationInUse(_db, pPlatform.Location, pPlatform.PlatformId)) { throw new Exception("Platform with the same name already exists."); } var _platformRow = MapToPlatformRow(pPlatform); PlatformManager.AddPlatform(_db, _platformRow); pPlatform.PlatformId = _platformRow.Platform_id; _db.CommitTransaction(); } catch (Exception _ex) { pPlatform.PlatformId = 0; _db.RollbackTransaction(); pResult.Success = false; pResult.ErrorMessage = _ex.Message; TimokLogger.Instance.LogRbr(LogSeverity.Critical, "PlatformController.AddPlatform", string.Format("Exception:\r\n{0}", _ex)); } } }
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); }
//--------------------------------------- Static methods --------------------------------------------- public static CustomerAcct[] GetAllWithBalanceWarning() { var _customerAccts = new List <CustomerAcct>(); CustomerAcctRow[] _customerAcctRows; try { using (var _db = new Rbr_Db()) { _customerAcctRows = _db.CustomerAcctCollection.GetAll(); } } catch (Exception _ex) { throw new Exception(string.Format("Getting All CustomerAccts, Exception:\r\n{0}", _ex)); } foreach (var _customerAcctRow in _customerAcctRows) { var _customerAcct = new CustomerAcct(_customerAcctRow); if (_customerAcct.IsBalanceWarningLimitReached) { _customerAccts.Add(_customerAcct); } } return(_customerAccts.ToArray()); }
public static CustomerRoute Get(short pServiceId, int pCallingPlanId, int pRoutingPlanId, string pDestNumber) { DialCodeRow _dialCodeRow; using (var _db = new Rbr_Db()) { _dialCodeRow = _db.DialCodeCollection.GetFirstByCallingPlanIdDialedNumber(pCallingPlanId, pDestNumber); } if (_dialCodeRow == null) { throw new RbrException(RbrResult.Customer_DialCodeNotFound, "CustomerRoute.Get", string.Format("ServiceId {0}, CallingPlanId: {1} DestNumber: {2}", pServiceId, pCallingPlanId, pDestNumber)); } var _customerRoute = getCustomerRoute(pServiceId, pRoutingPlanId, _dialCodeRow.Route_id); if (_customerRoute == null) { throw new RbrException(RbrResult.Customer_RouteNotFound, "CustomerRoute.Get", string.Format("ServiceId={0}, CallingPlanId={1}, DestNumber={2}", pServiceId, pCallingPlanId, pDestNumber)); } return(_customerRoute); }
public RoutingTableDto GetRoutingTable(int pRoutingPlanId, int pBaseRouteId) { if (pRoutingPlanId > 0 && pBaseRouteId > 0) { using (var _db = new Rbr_Db()) { var _routingPlanDetailRow = _db.RoutingPlanDetailCollection.GetByPrimaryKey(pRoutingPlanId, pBaseRouteId); if (_routingPlanDetailRow == null) { return(null); } var _routingTable = new RoutingTableDto { RoutingPlanId = _routingPlanDetailRow.Routing_plan_id, BaseRouteId = _routingPlanDetailRow.Route_id, Algorithm = _routingPlanDetailRow.Algorithm, AvailableTerminations = RoutingManager.GetAvailableTerminations(_db, pBaseRouteId), Terminations = RoutingManager.GetAll(_db, pRoutingPlanId, pBaseRouteId) }; return(_routingTable); } } return(null); }
public void DeleteRoute(RatedRouteDto pRoute, ViewContext pContext) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pRoute, pContext)) { if (pContext == ViewContext.Carrier) { CarrierRouteManager.Delete(_db, pRoute); } else if (pContext == ViewContext.Customer) { CustomerRouteManager.Delete(_db, pRoute); } else if (pContext == ViewContext.Service) { CustomerRouteManager.Delete(_db, pRoute); } else { throw new NotImplementedException("ViewContext: " + pContext); } _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)); } } }
//-- Get all nodes of a particular type: public static Node[] GetNodes(params NodeRole[] pNodeRoleFilters) { NodeRow[] _nodeRows; using (var _db = new Rbr_Db()) { _nodeRows = _db.NodeCollection.GetByNodeRoleFilter(pNodeRoleFilters); } if (_nodeRows == null || _nodeRows.Length == 0) { return(null); } //-- Load all nodeRows into node array: var _nodeList = new List <Node>(); for (var _i = 0; _i < _nodeRows.Length; _i++) { var _node = new Node(); _node.init(_nodeRows[_i], _nodeRows[_i].Ip_address); _nodeList.Add(_node); } var _nodes = _nodeList.ToArray(); return(_nodes); }
void exportDialPlan() { countries = new SortedList <string, CountryRecord>(); using (var _db = new Rbr_Db()) { RouteRow[] _baseRouteRows = getBaseRouteRows(_db); if (_baseRouteRows == null || _baseRouteRows.Length <= 0) { reportStatus(LogSeverity.Status, "DialPlanExporter.exportDialPlan", "No Routes to Process..."); return; } _baseRouteRows = RoutingManager.SortRouteRows(_baseRouteRows); string _filePath = getFilePath(); using (var _swDialPlan = new StreamWriter(_filePath, false)) { int _index = 0; CountryRecord _countryRecord = null; foreach (RouteRow _baseRouteRow in _baseRouteRows) { host.ReportProgress(_index++ *100 / _baseRouteRows.Length); if (args.RoutingPlanId > 0) { RoutingPlanDetailRow _routingPlanDetailRow = _db.RoutingPlanDetailCollection.GetByPrimaryKey(args.RoutingPlanId, _baseRouteRow.Route_id); if (_routingPlanDetailRow == null) { continue; //NOTE: skip this route } } if (_countryRecord == null || _countryRecord.Name != _baseRouteRow.Name) { _countryRecord = getCountryRecord(_db, _baseRouteRow); } if (_countryRecord.Routes.ContainsKey(_baseRouteRow.Name)) { throw new Exception(string.Format("Unexpected: Route already processed? {0}", _baseRouteRow.Name)); } RouteRecord _routeRecord = getRouteRecord(_baseRouteRow, _countryRecord); _countryRecord.Routes.Add(_routeRecord.FullName, _routeRecord); reportStatus(LogSeverity.Status, "DialPlanExporter.exportDialPlanToFile", string.Format("Exporting DialCodes for Route: {0}", _routeRecord.FullName)); DialCodeRow[] _dialCodeRows = _db.DialCodeCollection.GetByRoute_id(_baseRouteRow.Route_id); if (_dialCodeRows != null && _dialCodeRows.Length > 0) { var _dialCodesAsStringArray = new string[_dialCodeRows.Length]; for (int _i = 0; _i < _dialCodeRows.Length; _i++) { _dialCodesAsStringArray[_i] = _dialCodeRows[_i].Dial_code.ToString(); } _routeRecord.AddDialCodes(_dialCodesAsStringArray); } _swDialPlan.Write(_routeRecord.DialCodesAsString); } } } }
public static CustomerSupportGroupDto[] GetByVendorId(int pVendorId) { using (Rbr_Db _db = new Rbr_Db()) { return(CustomerSupportManager.GetByVendorIdCustomerSupportGroups(_db, pVendorId)); } }
public static CustomerSupportGroupDto Get(int pCustomerSupportGroupId) { using (Rbr_Db _db = new Rbr_Db()) { return(CustomerSupportManager.GetCustomerSupportGroup(_db, pCustomerSupportGroupId)); } }
public static CustomerAcctSupportMapDto[] GetAllCustomerSupportMaps(int pVendorId) { using (Rbr_Db _db = new Rbr_Db()) { return(CustomerSupportManager.GetAllCustomerAcctSupportMaps(_db, pVendorId)); } }
/// <summary> /// Initializes a new instance of the <see cref="CallCenterCabinaCollection_Base"/> /// class with the specified <see cref="Rbr_Db"/>. /// </summary> /// <param name="db">The <see cref="Rbr_Db"/> object.</param> public CallCenterCabinaCollection_Base(Rbr_Db db) { _db = db; }
/// <summary> /// Initializes a new instance of the <see cref="InventoryHistoryCollection_Base"/> /// class with the specified <see cref="Rbr_Db"/>. /// </summary> /// <param name="db">The <see cref="Rbr_Db"/> object.</param> public InventoryHistoryCollection_Base(Rbr_Db db) { _db = db; }
/// <summary> /// Initializes a new instance of the <see cref="ResidentialPSTNCollection_Base"/> /// class with the specified <see cref="Rbr_Db"/>. /// </summary> /// <param name="db">The <see cref="Rbr_Db"/> object.</param> public ResidentialPSTNCollection_Base(Rbr_Db db) { _db = db; }
//--------------------------------- Privates ----------------------------------- private static void executeLoadCommand(Rbr_Db pDb, BackgroundWorker pBackgroundWorker, DoWorkEventArgs pEvtArg, InventoryCommandRequest pInventoryCommandRequest) { pBackgroundWorker.ReportStatus(string.Format("Loading {0} Batches", pInventoryCommandRequest.Batches)); foreach (var _batch in pInventoryCommandRequest.Batches) { string _batchFilePath = Configuration.Instance.Folders.GetInventoryBatchFilePath(_batch.ServiceId, _batch.Denomination, _batch.BatchId); pBackgroundWorker.ReportStatus("Loading Batch File: " + _batchFilePath); using (var _sr = new StreamReader(_batchFilePath)) { _batch.CustomerAcctId = pInventoryCommandRequest.CustomerAcctId; if (pInventoryCommandRequest.ActivateOnLoad) { _batch.InventoryStatus = InventoryStatus.Activated; } else { _batch.InventoryStatus = InventoryStatus.Loaded; } try { int _cardCount = 0; string _line; while ((_line = _sr.ReadLine()) != null) { //pBackgroundWorker.ReportStatus(string.Format("{0}", _line)); if (pBackgroundWorker.CancellationPending) { pBackgroundWorker.ReportStatus("Canceled"); pEvtArg.Cancel = true; return; } string[] _fields = _line.Split(FieldDelimiter); long _serial = long.Parse(_fields[0]); long _pin = long.Parse(_fields[1]); loadPhoneCardAndRetailAccount(pDb, _serial, _pin, pInventoryCommandRequest); pBackgroundWorker.ReportProgress(++_cardCount * 100 / _batch.BatchSize); } } catch (Exception _ex) { pBackgroundWorker.ReportStatus(string.Format("Exception:\r\n{0}", _ex)); pEvtArg.Cancel = true; return; } BatchRow _batchRow = MapToBatchRow(_batch); pBackgroundWorker.ReportStatus(string.Format("Mapped BatchId={0}", _batch.BatchId)); pBackgroundWorker.ReportStatus(string.Format("Updated BatchId={0}", _batch.BatchId)); pDb.BatchCollection.Update(_batchRow); logInventoryHistory(pDb, pInventoryCommandRequest.Person, DateTime.Now, pInventoryCommandRequest.ServiceId, _batch.Denomination, _batch.BatchId, _batch.BatchSize, InventoryCommand.Load, pInventoryCommandRequest.CustomerAcctId, 0, //TODO: !!! ResellerPartnerId - N/A FOR NOW 0 //TODO: !!! ResellerAgentId - N/A FOR NOW ); pBackgroundWorker.ReportStatus("Logged Inventory History"); if (pInventoryCommandRequest.ActivateOnLoad) { logInventoryHistory(pDb, pInventoryCommandRequest.Person, DateTime.Now.AddMilliseconds(11), //Just to make sure that time is different from prev History entry pInventoryCommandRequest.ServiceId, _batch.Denomination, _batch.BatchId, _batch.BatchSize, InventoryCommand.Activate, pInventoryCommandRequest.CustomerAcctId, 0, //TODO: !!! SalesRepAcctId - N/A FOR NOW 0 //TODO: !!! ResellerAgentId - N/A FOR NOW ); } pBackgroundWorker.ReportStatus("Finished Loading Batch File: " + _batchFilePath); } } }
//------------------------------------- Private ---------------------------------------------- void exportWholesaleRates() { try { countries = new SortedList <string, CountryRecord>(); using (var _db = new Rbr_Db()) { ServiceDto _service = getService(_db); RouteRow[] _baseRouteRows = _db.RouteCollection.GetByCallingPlanIdRoutingPlanId(_service.CallingPlanId, args.RoutingPlanId); if (_baseRouteRows == null || _baseRouteRows.Length <= 0) { reportStatus(LogSeverity.Status, "DialPlanExporter.exportWholesaleRates", "WARNING: No Routes to Export..."); return; } _baseRouteRows = RoutingManager.SortRouteRows(_baseRouteRows); string _filePath = getFilePath(); using (var _sw = new StreamWriter(_filePath, false)) { _sw.WriteLine(args.PerMinute ? RatesFileHeaderCostPerMinute : RatesFileHeaderCostPerIncrements); int _index = 0; CountryRecord _countryRecord = null; foreach (RouteRow _baseRouteRow in _baseRouteRows) { host.ReportProgress(_index++ *100 / _baseRouteRows.Length); WholesaleRouteRow _wholesaleRouteRow = _db.WholesaleRouteCollection.GetByServiceIdBaseRouteId(_service.ServiceId, _baseRouteRow.Route_id); if (_wholesaleRouteRow == null) { continue; } if (_countryRecord == null || _countryRecord.Name != _baseRouteRow.Name) { _countryRecord = getCountryRecord(_db, _baseRouteRow); } RouteRecord _routeRecord = getRouteRecord(_baseRouteRow, _countryRecord); _countryRecord.Routes.Add(_routeRecord.FullName, _routeRecord); WholesaleRateHistoryRow _wholesaleRateHistoryRow = _db.WholesaleRateHistoryCollection.GetByWholesaleRouteIdDate(_wholesaleRouteRow.Wholesale_route_id, DateTime.Today); if (_wholesaleRateHistoryRow != null) { RatingInfoDto _ratingInfo = RatingManager.GetRatingInfo(_db, _wholesaleRateHistoryRow.Rate_info_id, false); if (_ratingInfo == null) { reportStatus(LogSeverity.Critical, "DialPlanExporter.exportWholesaleRates", string.Format("RatingInfo == null, {0}", _wholesaleRateHistoryRow.Rate_info_id)); continue; } _routeRecord.RatingInfo = _ratingInfo; reportStatus(LogSeverity.Status, "DialPlanExporter.exportWholesaleRates", string.Format("Exporting Rates for Route: {0}", _routeRecord.FullName)); _sw.Write(_routeRecord.GetRatesAsString(args.PerMinute)); } } } } } catch (Exception _ex) { reportStatus(LogSeverity.Critical, "DialPlanExporter.exportWholesaleRates", string.Format("Exception:\r\n{0}", _ex)); throw; } }
public static RetailAccountRow CreateRetailAccount(InventoryCommandRequest pInventoryCommandRequest) { using (var _db = new Rbr_Db()) { return(createRetailAccount(_db, pInventoryCommandRequest)); } }
internal static CallingPlanRow GetCallingPlanRow(Rbr_Db pDb, int pCallingPlanId) { return(pDb.CallingPlanCollection.GetByPrimaryKey(pCallingPlanId)); }
/// <summary> /// Initializes a new instance of the <see cref="TypeOfDayChoiceCollection_Base"/> /// class with the specified <see cref="Rbr_Db"/>. /// </summary> /// <param name="db">The <see cref="Rbr_Db"/> object.</param> public TypeOfDayChoiceCollection_Base(Rbr_Db db) { _db = db; }
/// <summary> /// Initializes a new instance of the <see cref="CustomerAcctPaymentCollection_Base"/> /// class with the specified <see cref="Rbr_Db"/>. /// </summary> /// <param name="db">The <see cref="Rbr_Db"/> object.</param> public CustomerAcctPaymentCollection_Base(Rbr_Db db) { _db = db; }
/// <summary> /// Initializes a new instance of the <see cref="RetailRouteCollection_Base"/> /// class with the specified <see cref="Rbr_Db"/>. /// </summary> /// <param name="db">The <see cref="Rbr_Db"/> object.</param> public RetailRouteCollection_Base(Rbr_Db db) { _db = db; }
public static CustomerSupportVendorDto GetCustomerSupportVendor(int pVendorId) { using (Rbr_Db _db = new Rbr_Db()) { return(CustomerSupportManager.GetCustomerSupportVendor(_db, pVendorId)); } }
/// <summary> /// Initializes a new instance of the <see cref="NodeCollection_Base"/> /// class with the specified <see cref="Rbr_Db"/>. /// </summary> /// <param name="db">The <see cref="Rbr_Db"/> object.</param> public NodeCollection_Base(Rbr_Db db) { _db = db; }
public static CustomerSupportVendorDto[] GetAllCustomerSupportVendors() { using (Rbr_Db _db = new Rbr_Db()) { return(CustomerSupportManager.GetAllCustomerSupportVendors(_db)); } }
/// <summary> /// Initializes a new instance of the <see cref="ScheduleCollection_Base"/> /// class with the specified <see cref="Rbr_Db"/>. /// </summary> /// <param name="db">The <see cref="Rbr_Db"/> object.</param> public ScheduleCollection_Base(Rbr_Db db) { _db = db; }
public static CustomerAcctSupportMapDto GetCustomerSupportMap(short pCustomerAcctId, int pVendorId) { using (Rbr_Db _db = new Rbr_Db()) { return(CustomerSupportManager.GetCustomerAcctSupportMap(_db, pCustomerAcctId, pVendorId)); } }