public void AddCALLReportDetail(Int64 userID, string phoneNumer, tbl_CALLDetail detailItem) { CRUDOperation cRUDOperation = new CRUDOperation(); int _outCallCountSame = 0, _outCallCountOther = 0, _outCallForeignCount = 0, _inCallCount = 0, _inCallForeignCount = 0, _outMissedCallCount = 0, _inMissedCallCount = 0; decimal _outCallSecondSame = 0, _outCallMinuteSame = 0, _outCallSecondOther = 0, _outCallMinuteOther = 0; decimal _outCallForeignSecond = 0, _outCallForeignMinute = 0; decimal _inCallSecond = 0, _inCallMinute = 0, _inCallForeignSecond = 0, _inCallForeignMinute = 0; tbl_OperatorInformation _OperatorInformation = new tbl_OperatorInformation(); decimal pointValue = 0; decimal priceValue = 0; int month = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0; int year = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0; try { if (detailItem.InOutType == 1) { if (detailItem.IsForeign == 0 && detailItem.Duration > 0) { bool IsSame = NumberHelper.ControlSameOrOther(phoneNumer, detailItem.PhonePrefix); if (IsSame) { _outCallCountSame = 1; _outCallSecondSame = (decimal)detailItem.Duration; _outCallMinuteSame = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.OutSameMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _outCallMinuteSame * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _outCallMinuteSame * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } else { _outCallCountOther = 1; _outCallSecondOther = (decimal)detailItem.Duration; _outCallMinuteOther = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.OutOtherMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _outCallMinuteOther * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _outCallMinuteOther * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } } else if (detailItem.IsForeign == 1 && detailItem.Duration > 0) { _outCallForeignCount = 1; _outCallForeignSecond = (decimal)detailItem.Duration; _outCallForeignMinute = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.OutForeignMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _outCallForeignMinute * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _outCallForeignMinute * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } else if (detailItem.Duration == 0) { _outMissedCallCount = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.OutMissedCount, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _outMissedCallCount * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _outMissedCallCount * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } } else { if (detailItem.IsForeign == 0 && detailItem.Duration > 0) { _inCallCount = 1; _inCallSecond = (decimal)detailItem.Duration; _inCallMinute = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.INMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _inCallMinute * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _inCallMinute * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } else if (detailItem.IsForeign == 1 && detailItem.Duration > 0) { _inCallForeignCount = 1; _inCallForeignSecond = (decimal)detailItem.Duration; _inCallForeignMinute = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.INForeignMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _inCallForeignMinute * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _inCallForeignMinute * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } else if (detailItem.Duration == 0) { _inMissedCallCount = 1; } } tbl_CALLReport callReport = new tbl_CALLReport() { CALLDetailID = detailItem.ID, CALLModelID = detailItem.CALLModelID, UserID = userID, Month = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0, Year = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0, OutCallCountSame = _outCallCountSame, OutCallSecondSame = _outCallSecondSame, OutCallMinuteSame = _outCallMinuteSame, OutCallCountOther = _outCallCountOther, OutCallSecondOther = _outCallSecondOther, OutCallMinuteOther = _outCallMinuteOther, InCallCount = _inCallCount, InCallSecond = _inCallSecond, InCallMinute = _inCallMinute, OutMissedCallCount = _outMissedCallCount, InMissedCallCount = _inMissedCallCount, OutCallForeignCount = _outCallForeignCount, OutCallForeignSecond = _outCallForeignSecond, OutCallForeignMinute = _outCallForeignMinute, InCallForeignCount = _inCallForeignCount, InCallForeignSecond = _inCallForeignSecond, InCallForeignMinute = _inCallForeignMinute, }; cRUDOperation.AddCALLReport(callReport); } catch (Exception ex) { } }