Exemplo n.º 1
0
        void setRates(TypeOfDayChoice pTypeOfDayChoice, TimeOfDayPolicy pTimeOfDayPolicy, DayTimeDto[] pDayTimePeriods, RateDto[] pRateList, bool pIsPotentiallyUnknownDayPolicy)
        {
            if (!validateTimePeriods(pDayTimePeriods, pTimeOfDayPolicy))
            {
                throw new ArgumentException("Invalid TimePeriod(s) for TypeOfDayChoice: [" + pTypeOfDayChoice + "] TimeOfDayPolicy: [" + pTimeOfDayPolicy + "]");
            }

            if (pTypeOfDayChoice == TypeOfDayChoice.RegularDay)
            {
                regularDay = new DayTypeDto(pDayTimePeriods, pTimeOfDayPolicy, true, pIsPotentiallyUnknownDayPolicy);

                regularDayRateEntry = new TypeOfDayRateEntryDto {
                    TypeOfDayChoice = pTypeOfDayChoice, Rates = pRateList
                };
            }
            if (pTypeOfDayChoice == TypeOfDayChoice.Weekend)
            {
                weekend = new DayTypeDto(pDayTimePeriods, pTimeOfDayPolicy, true, pIsPotentiallyUnknownDayPolicy);

                weekendRateEntry = new TypeOfDayRateEntryDto {
                    TypeOfDayChoice = pTypeOfDayChoice, Rates = pRateList
                };
            }
            if (pTypeOfDayChoice == TypeOfDayChoice.Holiday)
            {
                holiday = new DayTypeDto(pDayTimePeriods, pTimeOfDayPolicy, true, pIsPotentiallyUnknownDayPolicy);

                holidayRateEntry = new TypeOfDayRateEntryDto {
                    TypeOfDayChoice = pTypeOfDayChoice, Rates = pRateList
                };
            }
        }
Exemplo n.º 2
0
        //-------------------------------- ctors -------------------------------------------------------

        void init()
        {
            perCallCost      = decimal.Zero;
            perCallTimeLimit = 0;

            regularDay = new DayTypeDto(new DayTimeDto[0], TimeOfDayPolicy.Flat, false, false);
            weekend    = new DayTypeDto(new DayTimeDto[0], TimeOfDayPolicy.Flat, false, false);
            holiday    = new DayTypeDto(new DayTimeDto[0], TimeOfDayPolicy.Flat, false, false);

            regularDayRateEntry = new TypeOfDayRateEntryDto();

            weekendRateEntry = new TypeOfDayRateEntryDto {
                TypeOfDayChoice = TypeOfDayChoice.Weekend
            };
            foreach (var _rate in weekendRateEntry.Rates)
            {
                _rate.TypeOfDayChoice = weekendRateEntry.TypeOfDayChoice;
            }

            holidayRateEntry = new TypeOfDayRateEntryDto {
                TypeOfDayChoice = TypeOfDayChoice.Holiday
            };
            foreach (var _rate in holidayRateEntry.Rates)
            {
                _rate.TypeOfDayChoice = holidayRateEntry.TypeOfDayChoice;
            }

            holidayList = new HolidayListDto();

            badRouteLines = new ArrayList();
        }
Exemplo n.º 3
0
        //return example:
        //Brazil|55|ROC_CEL|Holiday|Blocked|0am-2am,10pm-10pm|0/0|0.0|0.0
        //Brazil|55|ROC_CEL|Holiday|Night|3am-9pm,11pm-11pm|30/6|0.1110000|0.1164000
        string[] getRateLines(DayTypeDto pDayType, TypeOfDayRateEntryDto pTypeOfDayRateEntry, bool pPerMinute)
        {
            var _rateLines = new List <string>();

            foreach (var _rate in pTypeOfDayRateEntry.Rates)
            {
                //NOTE: skip Blocked*
                var _rateLine = new StringBuilder();
                _rateLine.Append(_rate.TypeOfDayChoice);                 //RegularDay|
                _rateLine.Append(AppConstants.ImportExport_FieldDelimiter);

                if (_rate.TimeOfDay == TimeOfDay.BlockedFlat || _rate.TimeOfDay == TimeOfDay.BlockedPeakOffPeak || _rate.TimeOfDay == TimeOfDay.BlockedNightDayEve)
                {
                    _rateLine.Append(_rate.TimeOfDay.ToString().Replace(pDayType.TODPolicy.ToString(), string.Empty));                     //just leave "Blocked"
                }
                else
                {
                    _rateLine.Append(_rate.TimeOfDay.ToString());                     //|Flat| or |Night| ...
                }

                _rateLine.Append(AppConstants.ImportExport_FieldDelimiter);

                string _timeRanges = getTimeRanges(pDayType, _rate.TimeOfDay);
                _rateLine.Append(_timeRanges);                 //|2am-7am,9pm-11pm|

                _rateLine.Append(AppConstants.ImportExport_FieldDelimiter);

                _rateLine.Append(_rate.FirstIncrLen);               //|30/6|
                _rateLine.Append(AppConstants.ImportExport_RateIncrementsDelimiter);
                _rateLine.Append(_rate.AddIncrLen);                 //|30/6|
                _rateLine.Append(AppConstants.ImportExport_FieldDelimiter);

                if (pPerMinute)
                {
                    _rateLine.Append(_rate.GetPerMinuteCost());                     //|0.1110000
                }
                else
                {
                    _rateLine.Append(_rate.FirstIncrCost);                   //|0.1110000|0.1164000
                    _rateLine.Append(AppConstants.ImportExport_FieldDelimiter);
                    _rateLine.Append(_rate.AddIncrCost);                     //|0.1110000|0.1164000
                }
                _rateLines.Add(_rateLine.ToString());
            }
            return(_rateLines.ToArray());
        }
        public TypeOfDayRateEntryDto MakeCloneWithNoRates()
        {
            var _clone = new TypeOfDayRateEntryDto
            {
                RateInfoId      = 0,
                TypeOfDayChoice = TypeOfDayChoice
            };

            var _list = new List <RateDto>();

            foreach (var _rate in Rates)
            {
                _list.Add(_rate.MakeCloneWithNoRates());
            }
            _clone.Rates = _list.ToArray();

            return(_clone);
        }
Exemplo n.º 5
0
 bool validateRates(TypeOfDayRateEntryDto pTypeOfDayRateEntry)
 {
     //if (pTypeOfDayRateEntry ==  null) {
     //  return true;
     //}
     foreach (RateDto _rate in pTypeOfDayRateEntry.Rates)
     {
         if (_rate.TimeOfDay == TimeOfDay.BlockedFlat || _rate.TimeOfDay == TimeOfDay.BlockedPeakOffPeak || _rate.TimeOfDay == TimeOfDay.BlockedNightDayEve)
         {
             continue;                     //skip validation for Blocked periods
         }
         if (_rate.FirstIncrCost <= decimal.Zero || _rate.AddIncrCost <= decimal.Zero)
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 6
0
        public RatingInfoDto(int pRateInfoId, DayTypeDto[] pDayTypes, TypeOfDayRateEntryDto[] pTypeOfDayRateEntries)
        {
            perCallCost      = decimal.Zero;
            perCallTimeLimit = 0;

            rateInfoId = pRateInfoId;

            regularDay = pDayTypes[0];
            weekend    = pDayTypes[1];
            holiday    = pDayTypes[2];

            regularDayRateEntry = pTypeOfDayRateEntries[0];
            weekendRateEntry    = pTypeOfDayRateEntries[1];
            holidayRateEntry    = pTypeOfDayRateEntries[2];

            holidayList = new HolidayListDto();

            badRouteLines = new ArrayList();
        }