//----------------------------------------- Public Instance Methods ------------------------------------ public int Authorize(CustomerRoute pCustomerRoute) { if (Status != Status.Active) { throw new RbrException(RbrResult.Customer_NotActive, "CustomerAcct.Authorize", string.Format("CustomerAcctId={0}", Id)); } if (NumberOfCallsCounter.ContainsKey(Id)) { if (NumberOfCallsCounter[Id] >= MaxNumberOfCalls) { throw new RbrException(RbrResult.Customer_LimitReached, "CustomerAcct.Authorize", string.Format("CustomerAcctId={0}", Id)); } } if (!IsPrepaid) { return(MaxCallLength); } //-- Check prepaid conditions if (IsBalanceLimitReached) { throw new RbrException(RbrResult.Customer_BalanceInvalid, "CustomerAcct.Authorize", string.Format("Customer Balance INVALID, CustomerAcctId={0}", Id)); } if (IsBalanceWarningLimitReached) { TimokLogger.Instance.LogRbr(LogSeverity.Error, "CustomerAcct.Authorize", string.Format("Customer Warning REACHED, CustomerAcctId={0}", Id)); } if (pCustomerRoute.Status != Status.Active) { throw new RbrException(RbrResult.Customer_RouteBlocked, "CustomerAcct.Authorize", string.Format("CustomerAcctId={0}, CustomerRouteId={1}", Id, pCustomerRoute.WholesaleRouteId)); } int _timeLimit = pCustomerRoute.GetTimeLimit(Balance); if (_timeLimit <= 0) { throw new RbrException(RbrResult.Customer_LimitReached, "CustomerAcct.Authorize", string.Format("Customer Limit REACHED, CustomerAcct={0}", Id)); } if (_timeLimit > MaxCallLength) { _timeLimit = MaxCallLength; TimokLogger.Instance.LogRbr(LogSeverity.Status, "CustomerAcct.Authorize", string.Format("Max Call Time Limit REACHED, CustomerAcct={0}, Calculated TimeLimit={1}", Id, _timeLimit)); } return(_timeLimit); }
//--------------------- End-Static ------------------------------------------------------- public void Authorize(ISession pSession, IRetailAccount pRetailAcct, CustomerRoute pCustomerRoute, out int pTimeLimit, out int pPromptTimeLimit) { pTimeLimit = 0; //--Check for Domestic Bonus minutes: if (pRetailAcct.WithBonusMinutes && pCustomerRoute.WithBonusMinutes && pRetailAcct.CurrentBonusBalance > 0) { pTimeLimit = pRetailAcct.CurrentBonusBalance * 60; } //-- Check money based balance and add to the TimeLimit if balance > 0: if (pRetailAcct.CurrentBalance > decimal.Zero) { var _accessNumberSurcharge = AccessNumberSurchargeInfo; var _payphoneSurcharge = SurchargeInfo.Empty; if (pSession.InfoDigits > 0) { _payphoneSurcharge = PayphoneSurchargeInfo; } pTimeLimit += pCustomerRoute.GetTimeLimit(pRetailAcct.CurrentBalance, _accessNumberSurcharge, _payphoneSurcharge); } if (pTimeLimit < 0) { pTimeLimit = 0; TimokLogger.Instance.LogRbr(LogSeverity.Critical, "BillingService.Authorize:", string.Format("TimeLimit less then Zero! Serial={0}, CustomerId={1} TimeLimit={2}", pRetailAcct.SerialNumber, pRetailAcct.CustomerAcctId, pTimeLimit)); } //-- propmpt multiplier if (pCustomerRoute.Multiplier > 0) { pPromptTimeLimit = (pTimeLimit * pCustomerRoute.Multiplier) / 100; } else { pPromptTimeLimit = pTimeLimit; } }