Exemplo n.º 1
0
        public BaseOutput DeleteCALLModel(Int64 id)
        {
            CRUDOperation cRUDOperation = new CRUDOperation();
            BaseOutput    baseOutput;

            try
            {
                tbl_CALLModel _CALLModel = cRUDOperation.GetCALLModelByID(id);

                if (_CALLModel != null)
                {
                    List <tbl_CALLDetail> tbl_CALLDetails = cRUDOperation.GetCALLDetailsByModelID(_CALLModel.ID);

                    foreach (var item in tbl_CALLDetails)
                    {
                        tbl_CALLDetail tbl_CALLDetail = cRUDOperation.DeleteCALLDetail(item.ID, 0);
                    }

                    tbl_CALLModel tbl_CALLModel = cRUDOperation.DeleteCALLModel(id, 0);
                }

                return(baseOutput = new BaseOutput(true, BOResultTypes.Success.GetHashCode(), BOBaseOutputResponse.SuccessResponse, ""));
            }
            catch (Exception ex)
            {
                return(baseOutput = new BaseOutput(false, BOResultTypes.Danger.GetHashCode(), BOBaseOutputResponse.DangerResponse, ex.Message));
            }
        }
Exemplo n.º 2
0
        public BaseOutput UpdateCALLModel(CALLModel item)
        {
            CRUDOperation cRUDOperation = new CRUDOperation();
            BaseOutput    baseOutput;

            try
            {
                tbl_CALLModel tblCALLModel = new tbl_CALLModel()
                {
                    ID                   = item.ID,
                    UserID               = item.UserID,
                    TotalCallCount       = item.TotalCallCount,
                    OutCallCount         = item.OutCallCount,
                    OutCallSecond        = item.OutCallSecond,
                    InCallCount          = item.InCallCount,
                    InCallSecond         = item.InCallSecond,
                    MissedCallCount      = item.MissedCallCount,
                    OutCallForeignCount  = item.OutCallForeignCount,
                    OutCallForeignSecond = item.OutCallForeignSecond,
                    InCallForeignCount   = item.InCallForeignCount,
                    InCallForeignSecond  = item.InCallForeignSecond,
                    OutCallRoamingCount  = item.OutCallRoamingCount,
                    OutCallRoamingSecond = item.OutCallRoamingSecond,
                    InCallRoamingCount   = item.InCallRoamingCount,
                    InCallRoamingSecond  = item.InCallRoamingSecond,
                    BeginDate            = item.BeginDate,
                    EndDate              = item.EndDate,
                };

                tbl_CALLModel _CALLModel = cRUDOperation.UpdateCALLModel(tblCALLModel);

                if (_CALLModel != null)
                {
                    foreach (var callDetail in item.CALLDetails)
                    {
                        tbl_CALLDetail tblCALLDetail = cRUDOperation.UpdateCALLDetail(callDetail);
                    }
                }
                return(baseOutput = new BaseOutput(true, BOResultTypes.Success.GetHashCode(), BOBaseOutputResponse.SuccessResponse, ""));
            }
            catch (Exception ex)
            {
                return(baseOutput = new BaseOutput(false, BOResultTypes.Danger.GetHashCode(), BOBaseOutputResponse.DangerResponse, ex.Message));
            }
        }
Exemplo n.º 3
0
        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)
            {
            }
        }