Exemplo n.º 1
0
        public void AddSMSReportDetail(Int64 userID, string phoneNumer, tbl_SMSDetail detailItem, tbl_SMSSenderInfo smsSenderInfo)
        {
            CRUDOperation cRUDOperation = new CRUDOperation();
            int           _outMsjCountSame = 0, _outMsjCountOther = 0, _outMsjForeignCount = 0, _outMsjRoamingCount = 0;
            int           _inMsjCount = 0, _inMsjForeignCount = 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.IsShortMessage == 0)
                {
                    if (detailItem.InOutType == 1)
                    {
                        if (detailItem.IsForeign == 0 || detailItem.IsForeign == null)
                        {
                            bool IsSame = NumberHelper.ControlSameOrOther(phoneNumer, detailItem.PhonePrefix);
                            if (IsSame)
                            {
                                _outMsjCountSame     = 1;
                                _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutSameCount, (int)OperatorChanelType.Message);
                                if (_OperatorInformation != null)
                                {
                                    pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point;
                                    priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price;
                                    AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS);
                                }
                            }
                            else
                            {
                                _outMsjCountOther    = 1;
                                _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutOtherCount, (int)OperatorChanelType.Message);
                                if (_OperatorInformation != null)
                                {
                                    pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point;
                                    priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price;
                                    AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS);
                                }
                            }
                        }
                        else if (detailItem.IsForeign == 1)
                        {
                            _outMsjForeignCount  = 1;
                            _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutSameCount, (int)OperatorChanelType.Message);
                            if (_OperatorInformation != null)
                            {
                                pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point;
                                priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price;
                                AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS);
                            }
                        }
                    }
                    else
                    {
                        if (detailItem.IsForeign == 0 || detailItem.IsForeign == null)
                        {
                            _inMsjCount          = 1;
                            _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.INCount, (int)OperatorChanelType.Message);
                            if (_OperatorInformation != null)
                            {
                                pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point;
                                priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price;
                                AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS);
                            }
                        }
                        else if (detailItem.IsForeign == 1)
                        {
                            _inMsjForeignCount   = 1;
                            _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.INCount, (int)OperatorChanelType.Message);
                            if (_OperatorInformation != null)
                            {
                                pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point;
                                priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price;
                                AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS);
                            }
                        }
                    }

                    tbl_SMSReport smsReport = new tbl_SMSReport()
                    {
                        SMSModelID         = detailItem.SMSModelID,
                        SMSDetailID        = detailItem.ID,
                        UserID             = userID,
                        Month              = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0,
                        Year               = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0,
                        OutMsjCountSame    = _outMsjCountSame,
                        OutMsjCountOther   = _outMsjCountOther,
                        OutMsjForeignCount = _outMsjForeignCount,
                        InMsjCount         = _inMsjCount,
                        InMsjForeignCount  = _inMsjForeignCount,
                    };

                    cRUDOperation.AddSMSReport(smsReport);
                }
                else if (detailItem.IsShortMessage == 1)
                {
                    if (smsSenderInfo != null)
                    {
                        pointValue = 1 * (smsSenderInfo.Point == null ? 0 : (decimal)smsSenderInfo.Point);
                        priceValue = 1 * (smsSenderInfo.Price == null ? 0 : (decimal)smsSenderInfo.Price);
                        AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS);
                    }

                    if (detailItem.IsParse == 1)
                    {
                        if (detailItem.SenderName == "Azericard")
                        {
                            tbl_SMSReportShort smsRepotShort = ParseAzeriCard(detailItem, userID);
                            //Mebleg:-30.00 AZN
                            if (smsRepotShort != null)
                            {
                                cRUDOperation.AddSMSReportShort(smsRepotShort);
                                decimal priceAzeriCardValue = 0;
                                priceAzeriCardValue = smsRepotShort.Amount;
                                if (smsRepotShort.IsExpense == 1)
                                {
                                    if (smsRepotShort.Currency == "AZN")
                                    {
                                        AddUserPointAndPrice(userID, month, year, 0, priceAzeriCardValue, (int)ChanelType.AzeriCard);
                                        AddUserExpenseAbility(userID, "Azericard", "Xərc", month, year, priceAzeriCardValue, (int)ChanelType.AzeriCard);
                                    }
                                }
                                else
                                {
                                    AddUserIncomeAbility(userID, true, "Azericard", "Gəlir", month, year, priceAzeriCardValue, (int)ChanelType.AzeriCard);
                                }
                            }
                        }
                        if (detailItem.SenderName.ToLower() == "bakcell")
                        {
                            tbl_SMSReportShort smsRepotShort = ParseBakcell(detailItem, userID);
                            //Mebleg:-30.00 AZN
                            if (smsRepotShort != null)
                            {
                                cRUDOperation.AddSMSReportShort(smsRepotShort);
                                if (smsRepotShort.IsExpense == 1)
                                {
                                    AddUserPointAndPrice(userID, month, year, 0, smsRepotShort.Amount, (int)ChanelType.Bakcell);
                                    AddUserExpenseAbility(userID, "Bakcell", "Kontur", month, year, smsRepotShort.Amount, (int)ChanelType.Bakcell);
                                    AddUserIncomeAbility(userID, false, "Bakcell", "Kontur", month, year, smsRepotShort.Amount, (int)ChanelType.Bakcell);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }