public void PopulateValues(ServiceRow row) { txtJobID.Text = row.JobID; txtFault.Text = row.Fault; txtDate.Text = row.LoggedDate == "" ? "":DateTime.Parse(row.LoggedDate).GetUniversalDateTimeFormat(); txtDownTime.Text = row.DownTime; if (row.IsClear) { txtClearHeader.Visibility = Visibility.Visible; //= "Clear Service Call"; txtHeader.Visibility = Visibility.Hidden; btnAdd.Visibility = Visibility.Hidden; btnClear.Visibility = Visibility.Visible; //btnAddClear.Content = "Clear Call"; } else { txtClearHeader.Visibility = Visibility.Hidden; txtHeader.Visibility = Visibility.Visible; if (!Security.SecurityHelper.HasAccess("BMC.Presentation.CFieldService.btnReview.AddNote")) { btnAdd.Visibility = Visibility.Hidden; } else { btnAdd.Visibility = Visibility.Visible; } btnClear.Visibility = Visibility.Hidden; //txtHeader.Text = "Service Call Notes"; //btnAddClear.Content = "Add Note"; } BindControl(row.IsClear, row.JobID); }
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 RetailService(long pAccessNumber) { AccessNumberListRow _accessNumberRow; using (var _db = new Rbr_Db()) { _accessNumberRow = _db.AccessNumberListCollection.GetByPrimaryKey(pAccessNumber); } if (_accessNumberRow == null) { throw new Exception(string.Format("Service.Ctor: AccessNumber NOT FOUND, AccessNumber={0}", pAccessNumber)); } accessNumber = new AccessNumber(_accessNumberRow); using (var _db = new Rbr_Db()) { serviceRow = _db.ServiceCollection.GetByPrimaryKey(_accessNumberRow.Service_id); } if (serviceRow == null) { throw new Exception(string.Format("Service.Ctor: Service NOT FOUND, ServiceID={0}", _accessNumberRow.Service_id)); } //-- init PayphoneSurchargeInfo = SurchargeInfo.Empty; if (serviceRow.Payphone_surcharge_id > 0) { using (var _db = new Rbr_Db()) { var _payphoneSurchargeRow = _db.PayphoneSurchargeCollection.GetByPrimaryKey(serviceRow.Payphone_surcharge_id); if (_payphoneSurchargeRow != null) { PayphoneSurchargeInfo = new SurchargeInfo(_payphoneSurchargeRow.Surcharge, _payphoneSurchargeRow.SurchargeType); } } } }
public void PopulateValues(ServiceRow row) { txtJobID.Text = row.JobID; txtFault.Text = row.Fault; txtDate.Text = row.LoggedDate == "" ? "":DateTime.Parse(row.LoggedDate).GetUniversalDateTimeFormat(); txtDownTime.Text = row.DownTime; if (row.IsClear) { txtClearHeader.Visibility = Visibility.Visible; //= "Clear Service Call"; txtHeader.Visibility = Visibility.Hidden; btnAdd.Visibility = Visibility.Hidden; btnClear.Visibility = Visibility.Visible; //btnAddClear.Content = "Clear Call"; } else { txtClearHeader.Visibility = Visibility.Hidden; txtHeader.Visibility = Visibility.Visible; if (!Security.SecurityHelper.HasAccess("BMC.Presentation.CFieldService.btnReview.AddNote")) btnAdd.Visibility = Visibility.Hidden; else btnAdd.Visibility = Visibility.Visible; btnClear.Visibility = Visibility.Hidden; //txtHeader.Text = "Service Call Notes"; //btnAddClear.Content = "Add Note"; } BindControl(row.IsClear, row.JobID); }
static ServiceDto mapToService(ServiceRow pServiceRow, RoutingPlanDto pDefaultRoutingPlan, PayphoneSurchargeRow pPayphoneSurchargeRow, ICollection <AccessNumberListRow> pAccessNumberListRows, RatingInfoDto pDefaultRatingInfo) { if (pServiceRow == null) { return(null); } var _service = new ServiceDto { ServiceId = pServiceRow.Service_id, Name = pServiceRow.Name, Status = ((Status)pServiceRow.Status), ServiceType = pServiceRow.ServiceType, RetailType = pServiceRow.RetailType, IsShared = pServiceRow.IsShared, RatingType = pServiceRow.RatingType, PinLength = pServiceRow.Pin_length, DefaultRatingInfo = pDefaultRatingInfo, DefaultRoutingPlan = pDefaultRoutingPlan, AccessNumbers = mapToAccessNumbers(pAccessNumberListRows), PayphoneSurcharge = RetailAccountManager.MapToPayphoneSurcharge(pPayphoneSurchargeRow), SweepScheduleId = pServiceRow.Sweep_schedule_id, SweepFee = pServiceRow.Sweep_fee, SweepRule = pServiceRow.Sweep_rule, BalancePromptType = pServiceRow.BalancePromptType, BalancePromptPerUnit = pServiceRow.Balance_prompt_per_unit, VirtualSwitchId = pServiceRow.Virtual_switch_id }; return(_service); }
internal static void AddService(Rbr_Db pDb, ServiceDto pService, int[] pSelectedBaseRouteIds) { //TODO: NEW DAL - VirtualSwitch pService.VirtualSwitchId = AppConstants.DefaultVirtualSwitchId; if (pService.RetailType == RetailType.PhoneCard) { if (pService.PayphoneSurcharge != null) { pService.PayphoneSurcharge.PayphoneSurchargeId = RetailAccountManager.AddPayphoneSurcharge(pDb, pService.PayphoneSurcharge); } } else { pService.PayphoneSurcharge = null; } ServiceRow _serviceRow = mapToServiceRow(pService); Add(pDb, _serviceRow); pService.ServiceId = _serviceRow.Service_id; //Create Default WholesaleRoute int _defaultWholesaleRouteId; CustomerRouteManager.AddDefault(pDb, pService, out _defaultWholesaleRouteId); pService.DefaultRoute.RatedRouteId = _defaultWholesaleRouteId; CustomerRouteManager.Add(pDb, pService.ServiceId, pSelectedBaseRouteIds); }
internal static ServiceDto GetService(Rbr_Db pDb, short pServiceId) { ServiceRow _serviceRow = pDb.ServiceCollection.GetByPrimaryKey(pServiceId); if (_serviceRow == null) { return(null); } return(getService(pDb, _serviceRow, 0)); }
internal static void Add(Rbr_Db pDb, ServiceRow pServiceRow /*, AccessNumberListRow[] pAccessNumberRows*/) { try { pDb.ServiceCollection.Insert(pServiceRow); } catch { if (pServiceRow != null) { pServiceRow.Service_id = 0; } throw; } }
RetailAccountDto get(Rbr_Db pDb, short pServiceId, RetailAccountRow pRetailAccountRow) { if (pRetailAccountRow != null) { ServiceRow _serviceRow = ServiceManager.Get(pDb, pServiceId); RetailAccountDto _retailAccount = mapToRetailAccount(pRetailAccountRow); _retailAccount.ServiceId = pServiceId; _retailAccount.RetailType = _serviceRow.RetailType; _retailAccount.Person = PersonManager.GetByRetailAcctId(pDb, pRetailAccountRow.Retail_acct_id); PhoneCardDto[] _phoneCards = mapToPhoneCards(pDb.PhoneCardCollection.GetByRetail_acct_id(_retailAccount.RetailAcctId)); if (_phoneCards != null && _phoneCards.Length > 0) { _retailAccount.PhoneCards = _phoneCards; foreach (PhoneCardDto _phoneCard in _phoneCards) { if (_retailAccount.ServiceId != _phoneCard.ServiceId) { throw new Exception("Retail Account has a card from a different Service. [RetailAcctId=" + _retailAccount.RetailAcctId + "] [RetailAccount.ServiceId=" + _retailAccount.ServiceId + "] [PhoneCard.ServiceId=" + _phoneCard.ServiceId + "]"); } } } ResidentialPSTNDto[] _residentialPSTNs = mapToResidentialPSTNs(pDb.ResidentialPSTNCollection.GetByRetail_acct_id(_retailAccount.RetailAcctId)); if (_residentialPSTNs != null && _residentialPSTNs.Length > 0) { _retailAccount.ResidentialPSTNs = _residentialPSTNs; foreach (ResidentialPSTNDto _residentialPSTN in _residentialPSTNs) { if (_retailAccount.ServiceId != _residentialPSTN.ServiceId) { throw new Exception("Retail Account has a ResidentialPSTN from a different Service. [RetailAcctId=" + _retailAccount.RetailAcctId + "] [RetailAccount.ServiceId=" + _retailAccount.ServiceId + "] [ResidentialPSTN.ServiceId=" + _residentialPSTN.ServiceId + "]"); } } } //ResidentialVoIP[] _residentialVoIPs = mapToResidentialVoIPs(pDb.ResidentialVoIPCollection.GetByRetail_acct_id(_retailAccount.RetailAcctId)); //if (_residentialVoIPs != null && _residentialVoIPs.Length > 0) { // _retailAccount.ResidentialVoIPs = _residentialVoIPs; // foreach (ResidentialVoIP _residentialVoIP in _residentialVoIPs) { // if (_retailAccount.ServiceId != _residentialVoIP.ServiceId) { // throw new Exception("Retail Account has a ResidentialVoIP from a different Service. [RetailAcctId=" + _retailAccount.RetailAcctId + "] [RetailAccount.ServiceId=" + _retailAccount.ServiceId + "] [ResidentialVoIP.ServiceId=" + _residentialVoIP.ServiceId + "]"); // } // } //} return(_retailAccount); } return(null); }
public ViewClearServiceCall(ServiceRow row) { InitializeComponent(); if (!Security.SecurityHelper.HasAccess("BMC.Presentation.CFieldService.btnReview.AddNote")) btnAdd.Visibility = Visibility.Hidden; if (!row.IsClear) { ClearCall.Visibility = Visibility.Hidden; AddNote.Visibility = Visibility.Visible; } BarPos = row.BarPos; Asset = row.sAsset; PopulateValues(row); }
internal static void UpdateService(Rbr_Db pDb, ServiceDto pService) { if (pService.IsRatingEnabled) { //Update Service's Default RatingInfo //NOTE: DefaultRatingInfo is always created on Add, no metter is RatingEnabled or not RatingManager.UpdateRatingInfo(pDb, pService.DefaultRatingInfo); //check RatingInfo for all others WholesaleRoutes, if they have no RatingInfo - create it //if WholesaleRoute already have Rates, just leave it as is WholesaleRouteRow[] _wholesaleRouteRows = pDb.WholesaleRouteCollection.GetByService_id(pService.ServiceId); foreach (WholesaleRouteRow _wholesaleRouteRow in _wholesaleRouteRows) { WholesaleRateHistoryRow[] _wholesaleRateHistoryRows = pDb.WholesaleRateHistoryCollection.GetByWholesale_route_id(_wholesaleRouteRow.Wholesale_route_id); if (_wholesaleRateHistoryRows.Length == 0) { //route has no rates, create them using Default RatingManager.AddDefaultRatingInfo(pDb, _wholesaleRouteRow.Wholesale_route_id, pService.DefaultRatingInfo, RouteType.Wholesale); } } if (pService.PayphoneSurcharge != null) { if (pService.PayphoneSurcharge.PayphoneSurchargeId == 0) { pService.PayphoneSurcharge.PayphoneSurchargeId = RetailAccountManager.AddPayphoneSurcharge(pDb, pService.PayphoneSurcharge); } else { RetailAccountManager.UpdatePayphoneSurcharge(pDb, pService); } } } CustomerRouteManager.Update(pDb, pService.DefaultRoute); ServiceRow _serviceRow = mapToServiceRow(pService); Update(pDb, _serviceRow); //pDb.AddChangedObject(new ServiceKey(TxType.Delete, pService.ServiceId)); ServiceRow _originalServiceRow = Get(pDb, pService.ServiceId); if (pService.PayphoneSurcharge == null && !_originalServiceRow.IsPayphone_surcharge_idNull) { pDb.PayphoneSurchargeCollection.DeleteByPrimaryKey(_originalServiceRow.Payphone_surcharge_id); } }
public ViewClearServiceCall(ServiceRow row) { InitializeComponent(); if (!Security.SecurityHelper.HasAccess("BMC.Presentation.CFieldService.btnReview.AddNote")) { btnAdd.Visibility = Visibility.Hidden; } if (!row.IsClear) { ClearCall.Visibility = Visibility.Hidden; AddNote.Visibility = Visibility.Visible; } BarPos = row.BarPos; Asset = row.sAsset; PopulateValues(row); }
//BUG: will not work on remote (replicated nodes //TODO: !!!! public static void Import(PhoneCardBatch pPhoneCardBatch, BackgroundWorker pBackgroundWorker) { reportStatus("Connecting to DB...", pBackgroundWorker); using (var _db = new Rbr_Db()) { //using (Transaction _tx = new Transaction(_db, pPhoneCardBatch, null)) { ServiceRow _serviceRow = ServiceManager.Get(_db, pPhoneCardBatch.ServiceId); if (_serviceRow == null) { throw new Exception("Service not found [Id: " + pPhoneCardBatch.ServiceId + "]"); } checkPendingCancellation(pBackgroundWorker); reportStatus("Data Import Stated", pBackgroundWorker); importBatch(_db, pPhoneCardBatch, pBackgroundWorker); //_tx.Commit(); //} } }
static ServiceDto getService(Rbr_Db pDb, ServiceRow pServiceRow, short pCustomerAcctId) { if (pServiceRow == null) { return(null); } AccessNumberListRow[] _accessNumberRows; if (pCustomerAcctId > 0) { _accessNumberRows = pDb.AccessNumberListCollection.GetByCustomer_acct_id(pCustomerAcctId); } else { _accessNumberRows = pDb.AccessNumberListCollection.GetByService_id(pServiceRow.Service_id); } var _defaultRoutingPlan = RoutingManager.GetRoutingPlan(pDb, pServiceRow.Default_routing_plan_id); PayphoneSurchargeRow _payphoneSurchargeRow = null; if (!pServiceRow.IsPayphone_surcharge_idNull) { _payphoneSurchargeRow = pDb.PayphoneSurchargeCollection.GetByPrimaryKey(pServiceRow.Payphone_surcharge_id); } //if (pServiceRow.IsRatingEnabled) { //NOTE: DefaultRatingInfo is always created no metter what //and it should be loaded as well no metter what var _defaultRatingInfo = getDefaultServiceRatingInfo(pDb, pServiceRow.Service_id); //} var _service = mapToService(pServiceRow, _defaultRoutingPlan, _payphoneSurchargeRow, _accessNumberRows, _defaultRatingInfo); //NOTE: DefaultServiceRoute's ID = [negative] -ServiceId var _defaultWholesaleRouteRow = pDb.WholesaleRouteCollection.GetByPrimaryKey(-pServiceRow.Service_id); _service.DefaultRoute = CustomerRouteManager.Get(pDb, _service, _service.DefaultRoutingPlanId, _defaultWholesaleRouteRow); return(_service); }
static void generateTestSerialNumberPIN(Rbr_Db pDb, ServiceRow pServiceRow, out long pSerialNumber, out long pPIN) { var _rnd = new Random(); pPIN = 0; pSerialNumber = getRandomNumber(_rnd, -597893, -307800); // negative number; int _tryCount = 0; //!!! check if already exists... while (RetailAccountManager.PhoneCardExistsBySerialNumber(pDb, pServiceRow.Service_id, pSerialNumber)) { _tryCount++; if (_tryCount > 7) { pSerialNumber = 0; throw new Exception("Failed to generate Test SerialNumber"); } pSerialNumber = getRandomNumber(_rnd, -597893, -307800); // negative number; } if (pServiceRow.RetailType == RetailType.PhoneCard) { _tryCount = 0; pPIN = getRandomNumber(_rnd, 307800, 597893); //6 numbers //!!! check if already exists... while (RetailAccountManager.PhoneCardExistsByCardNumber(pDb, pServiceRow.Service_id, pPIN)) { _tryCount++; if (_tryCount > 7) { pPIN = 0; throw new Exception("Failed to generate Test PIN"); } pPIN = getRandomNumber(_rnd, 307800, 597893); //6 numbers } } }
static ServiceRow mapToServiceRow(ServiceDto pService) { if (pService == null) { return(null); } var _serviceRow = new ServiceRow { Service_id = pService.ServiceId, Name = pService.Name, Status = ((byte)pService.Status), ServiceType = pService.ServiceType, RetailType = pService.RetailType, Calling_plan_id = pService.CallingPlanId, Default_routing_plan_id = pService.DefaultRoutingPlanId, IsShared = pService.IsShared, RatingType = pService.RatingType, Pin_length = pService.PinLength, Sweep_fee = pService.SweepFee, Sweep_rule = pService.SweepRule, BalancePromptType = pService.BalancePromptType, Balance_prompt_per_unit = pService.BalancePromptPerUnit, Virtual_switch_id = pService.VirtualSwitchId }; if (pService.PayphoneSurcharge != null) { _serviceRow.Payphone_surcharge_id = pService.PayphoneSurchargeId; } if (pService.SweepScheduleId > 0) { _serviceRow.Sweep_schedule_id = pService.SweepScheduleId; } return(_serviceRow); }
public static void Add(string pSalt, RetailAccountDto pRetailAccount) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pSalt, pRetailAccount)) { RetailAccountRow _retailAccountRow = RetailAccountManager.MapToRetailAccountRow(pRetailAccount); //TODO: ! CONFIRM IT before implementing // CustomerAcctRow _customerAcctRow = _db.CustomerAcctCollection.GetByPrimaryKey(pRetailAccount.CustomerAcctId); // if (_customerAcctRow.BonusMinutesType == BonusMinutesType.None) { // _retailAccountRow.Current_bonus_minutes = -1; // } _retailAccountRow.Date_created = DateTime.Now; _retailAccountRow.Date_expired = Configuration.Instance.Db.SqlSmallDateTimeMaxValue; _retailAccountRow.Current_balance = _retailAccountRow.Start_balance; _retailAccountRow.Current_bonus_minutes = _retailAccountRow.Start_bonus_minutes; if (_retailAccountRow.AccountStatus == Status.Active) { _retailAccountRow.Date_active = _retailAccountRow.Date_created; } else { _retailAccountRow.Date_active = Configuration.Instance.Db.SqlSmallDateTimeMaxValue; } RetailAccountManager.Instance.Add(_db, _retailAccountRow); pRetailAccount.RetailAcctId = _retailAccountRow.Retail_acct_id; //prepare PhoneCard (s) if (pRetailAccount.PhoneCards != null && pRetailAccount.PhoneCards.Length > 0) { //NOTE: !!! in this virsion only ONE PhoneCard p/RetailAccount allowed!!! if (pRetailAccount.PhoneCards.Length > 1) { throw new Exception("In this virsion only ONE PhoneCard p/RetailAccount allowed!!!"); } foreach (PhoneCardDto _phoneCard in pRetailAccount.PhoneCards) { long _pin = 0; if (_phoneCard.SerialNumber == 0) { ServiceRow _serviceRow = ServiceManager.Get(_db, pRetailAccount.ServiceId); long _serialNumber; generateTestSerialNumberPIN(_db, _serviceRow, out _serialNumber, out _pin); _phoneCard.SerialNumber = _serialNumber; } if (_phoneCard.Pin == 0) { _phoneCard.Pin = _pin; } switch (pRetailAccount.Status) { case Status.Active: _phoneCard.InventoryStatus = InventoryStatus.Activated; break; case Status.Pending: case Status.Blocked: case Status.Archived: case Status.InUse: default: throw new ArgumentException(string.Format("Unexpected Status [{0}]", pRetailAccount.Status)); } _phoneCard.ServiceId = pRetailAccount.ServiceId; _phoneCard.RetailAcctId = pRetailAccount.RetailAcctId; _phoneCard.Status = pRetailAccount.Status; //TODO: ??? set it based on RetAcct status ??? _phoneCard.InventoryStatus = InventoryStatus.Activated; _phoneCard.DateLoaded = _retailAccountRow.Date_created; _phoneCard.DateActive = _retailAccountRow.Date_created; _phoneCard.DateToExpire = _retailAccountRow.Date_to_expire; _phoneCard.DateDeactivated = Configuration.Instance.Db.SqlSmallDateTimeMaxValue; _phoneCard.DateArchived = Configuration.Instance.Db.SqlSmallDateTimeMaxValue; } } //prepare ResidentialPSTN (s) if (pRetailAccount.ResidentialPSTNs != null && pRetailAccount.ResidentialPSTNs.Length > 0) { //NOTE: !!! in this virsion only ONE ResidentialPSTN p/RetailAccount allowed!!! if (pRetailAccount.ResidentialPSTNs.Length > 1) { throw new Exception("In this virsion only ONE ResidentialPSTN p/RetailAccount allowed!!!"); } foreach (var _residentialPSTN in pRetailAccount.ResidentialPSTNs) { _residentialPSTN.Status = pRetailAccount.Status; _residentialPSTN.ServiceId = pRetailAccount.ServiceId; _residentialPSTN.RetailAcctId = pRetailAccount.RetailAcctId; } } ////prepare ResidentialVoIP (s) //if (pRetailAccount.ResidentialVoIPs != null && pRetailAccount.ResidentialVoIPs.Length > 0) { // //NOTE: !!! in this virsion only ONE ResidentialVoIP p/RetailAccount allowed!!! // if (pRetailAccount.ResidentialVoIPs.Length > 1) { // throw new Exception("In this virsion only ONE ResidentialVoIP p/RetailAccount allowed!!!"); // } // foreach (ResidentialVoIP _residentialVoIP in pRetailAccount.ResidentialVoIPs) { // _residentialVoIP.Status = pRetailAccount.Status; // _residentialVoIP.ServiceId = pRetailAccount.ServiceId; // _residentialVoIP.RetailAcctId = pRetailAccount.RetailAcctId; // } //} if (pRetailAccount.AccessEnabled) { pRetailAccount.Person.RetailAcctId = pRetailAccount.RetailAcctId; PersonManager.Save(_db, pSalt, pRetailAccount.Person); } if (pRetailAccount.PhoneCards != null && pRetailAccount.PhoneCards.Length > 0) { //Insert PhoneCard //TODO: now works only with 1 (one) card per RetailAcct PhoneCardRow _phoneCardRow = RetailAccountManager.MapToPhoneCardRow(pRetailAccount.PhoneCards[0]); RetailAccountManager.AddPhoneCard(_db, _phoneCardRow); } if (pRetailAccount.ResidentialPSTNs != null && pRetailAccount.ResidentialPSTNs.Length > 0) { //Insert ResidentialPSTN //TODO: now works only with 1 (one) PSTN # per RetailAcct ResidentialPSTNRow _residentialPSTNRow = RetailAccountManager.MapToResidentialPSTNRow(pRetailAccount.ResidentialPSTNs[0]); RetailAccountManager.AddResidentialPSTNSubAcct(_db, _residentialPSTNRow); } _tx.Commit(); } } }
public ServiceRowChangeEvent(ServiceRow row, global::System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; }
internal static void Update(Rbr_Db pDb, ServiceRow pServiceRow) { pDb.ServiceCollection.Update(pServiceRow); }