Beispiel #1
0
        public RouteRecord(int pCCode, string pCountryName, string pBreakoutName, string[] pDialCodes, ICollection <string> pRouteLines)
        {
            var _badRouteLines = new List <string>();

            CountryName = pCountryName;
            CountryCode = pCCode;
            FullName    = string.Concat(pCountryName, AppConstants.SubRouteSeparator, pBreakoutName);
            DialCodes   = new SortedList <long, long>();

            if (pDialCodes != null && pDialCodes.Length > 0)
            {
                AddDialCodes(pDialCodes);
            }
            else
            {
                RatingInfo = new RatingInfoDto(pRouteLines);
                if (RatingInfo.BadRouteLines.Length > 0)
                {
                    foreach (string _routeLine in pRouteLines)
                    {
                        if (Array.IndexOf(RatingInfo.BadRouteLines, _routeLine) > -1)
                        {
                            _badRouteLines.Add("*" + _routeLine);
                        }
                        else
                        {
                            _badRouteLines.Add(_routeLine);
                        }
                    }
                }
                BadRouteLines = _badRouteLines.ToArray();
            }
        }
Beispiel #2
0
 public RatingHistoryEntry(RouteType pRouteType, int pRatedRouteId, DateTime pFirstDate, DateTime pLastDate, RatingInfoDto pRatingInfo)
 {
     if (pFirstDate > pLastDate)
     {
         throw new ArgumentOutOfRangeException("pFirstDate", "'First Date' cannot be grater then 'Last Date'.");
     }
     RouteType    = pRouteType;
     ratedRouteId = pRatedRouteId;
     firstDate    = trimToDay(pFirstDate);
     lastDate     = trimToDay(pLastDate);
     ratingInfo   = pRatingInfo;
 }
Beispiel #3
0
        //------------------------------------- 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;
            }
        }
Beispiel #4
0
        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);
        }