Пример #1
0
        private double CalculatePackageOffer(CDR cdr)
        {
            bool itIsALocalCall        = ((int)(cdr.calledPartyNumber / 10000000) == (int)(cdr.callingPartyNumber / 10000000));
            bool itIsALongDistanceCall = ((int)(cdr.calledPartyNumber / 10000000) != (int)(cdr.callingPartyNumber / 10000000));

            bool inOffPeakTime = (((cdr.startingTimeOfTheCall.Hour < startingHourOfPeakTime) && (cdr.startingTimeOfTheCall.Hour >= 0)) || ((cdr.startingTimeOfTheCall.Hour >= startingHourOfOffPeakTime) && (cdr.startingTimeOfTheCall.Hour <= 24)));
            bool inPeakTime    = ((cdr.startingTimeOfTheCall.Hour >= startingHourOfPeakTime) && (cdr.startingTimeOfTheCall.Hour < startingHourOfOffPeakTime));

            double packageOffer = 0;

            if (customer.packageCode == 'C' && itIsALocalCall)
            {
                if (inOffPeakTime)
                {
                    packageOffer = this._offPeakHoursLocalPerMiniuteCharge;
                }
                else
                {
                    packageOffer = this._peakHoursLocalPerMiniuteCharge;
                }
            }

            return(packageOffer);
        }
Пример #2
0
        public void CalculateTotalCallCharges(ref CDR cdr, double peakHoursLocalPerMiniuteOrPerSecondCharge, double offPeakHoursLocalPerMiniuteOrPerSecondCharge, double peakHoursLongDistancePerMiniuteOrPerSecondCharge, double offPeakHoursLongDistancePerMiniuteOrPerSecondCharge, ref double totalCallCharges, bool isPerMinute)
        {
            bool itIsALocalCall        = ((int)(cdr.calledPartyNumber / 10000000) == (int)(cdr.callingPartyNumber / 10000000));
            bool itIsALongDistanceCall = ((int)(cdr.calledPartyNumber / 10000000) != (int)(cdr.callingPartyNumber / 10000000));

            bool inOffPeakTime = (((cdr.startingTimeOfTheCall.Hour < _startingHourOfPeakTime) && (cdr.startingTimeOfTheCall.Hour >= 0)) || ((cdr.startingTimeOfTheCall.Hour >= _startingHourOfOffPeakTime) && (cdr.startingTimeOfTheCall.Hour <= 24)));
            bool inPeakTime    = ((cdr.startingTimeOfTheCall.Hour >= _startingHourOfPeakTime) && (cdr.startingTimeOfTheCall.Hour < _startingHourOfOffPeakTime));

            int totalMinutes = 0;


            if (isPerMinute)
            {
                //Code Original...
                //Finding number of mins to add...
                totalMinutes = CalculateMinutesToAdd(cdr.callDurationInSeconds);
            }
            else
            {
                totalMinutes = CalculateMinutesToAdd(cdr.callDurationInSeconds);
                if (cdr.callDurationInSeconds % 60 > 0)
                {
                    totalMinutes--;
                }
            }
            //Calculating Total Call Charges...
            for (int i = 0; i < totalMinutes; i++)
            {
                //Finding whethter the call is a long sitance call or a local one...
                //If it's a local one...
                if (itIsALocalCall)
                {
                    // Calculating Tatal Call Charges For Peak Hours Local Calls...
                    if (inPeakTime)
                    {
                        totalCallCharges += peakHoursLocalPerMiniuteOrPerSecondCharge;
                    }
                    // Calculating Tatal Call Charges For Off Peak Hours Local Calls...
                    if (inOffPeakTime)
                    {
                        totalCallCharges += offPeakHoursLocalPerMiniuteOrPerSecondCharge;
                    }
                }
                else if (itIsALongDistanceCall)
                {
                    // Calculating Tatal Call Charges For Peak Hours Long Distance Calls...
                    if (inPeakTime)
                    {
                        totalCallCharges += peakHoursLongDistancePerMiniuteOrPerSecondCharge;
                    }
                    // Calculating Tatal Call Charges For Off Peak Hours Long Distance Calls...
                    if (inOffPeakTime)
                    {
                        totalCallCharges += offPeakHoursLongDistancePerMiniuteOrPerSecondCharge;
                    }
                }
                //Increasing the time by minute, to find the correct time period for charging...
                cdr.startingTimeOfTheCall = cdr.startingTimeOfTheCall.AddMinutes(1);
                inOffPeakTime             = (((cdr.startingTimeOfTheCall.Hour < _startingHourOfPeakTime) && (cdr.startingTimeOfTheCall.Hour >= 0)) || ((cdr.startingTimeOfTheCall.Hour >= _startingHourOfOffPeakTime) && (cdr.startingTimeOfTheCall.Hour <= 24)));
                inPeakTime = ((cdr.startingTimeOfTheCall.Hour >= _startingHourOfPeakTime) && (cdr.startingTimeOfTheCall.Hour < _startingHourOfOffPeakTime));
            }
        }
Пример #3
0
 public void AddCDRToList(CDR cdr)
 {
     this._listOfCallDetails.Add(cdr);
 }