コード例 #1
0
        public override void CommitOrThrow_Send(MobileNoHandler storedNumbers, string[] telList, bool isWelcomeMessage, int MessageLength, ref Data_AppUserFile.eUserStatus accountStatus, out bool sendFooter)
        {
            sendFooter = false;

            //1)
            Data_AppUserFile_Checker_Free.VerifyAllMobileNumbers(storedNumbers, telList);

            if (isWelcomeMessage)
            {
                throw new ArgumentException("Wrong account");
            }
            else
            {
                //3) check still active
                DateTime NotAfter = new DateTime(duplicationAccount.systemDuplication_PaidUntil, DateTimeKind.Utc);
                if (DateTime.UtcNow > NotAfter)
                {
                    throw new ArgumentException("Please arrange a top up");
                }

                //4) update counters
                duplicationAccount.systemDuplication_MsgSent      += telList.Length;
                duplicationAccount.systemDuplication_LastMsgQueued = DateTime.UtcNow.Ticks;
            }
        }
コード例 #2
0
        public override void CommitOrThrow_Send(MobileNoHandler storedNumbers, string[] telList, bool isWelcomeMessage, int MessageLength, ref Data_AppUserFile.eUserStatus accountStatus, out bool sendFooter)
        {
            sendFooter = false;

            //1)
            Data_AppUserFile_Checker_Free.VerifyAllMobileNumbers(storedNumbers, telList);

            if (isWelcomeMessage)
            {
                throw new ArgumentException("Wrong account");
            }
            else
            {
                //2) checkTimeDelay()
                DateTime NotBefore = new DateTime(payAsSent.payAsSent_LastMsgQueued, DateTimeKind.Utc).AddSeconds(payAsSent.payAsSent_MinDelayInSeconds);
                if (DateTime.UtcNow < NotBefore)
                {
                    throw new ArgumentException("wait");
                }

                //3) check fonds
                Data_AppUserFile.niceMoney totalCost = payAsSent.payAsSent_CostPerMessage.MultiplyBy(telList.Length);
                if (payAsSent.payAsSent_CurrentCredit.ValueInUsCent < totalCost.ValueInUsCent)
                {
                    throw new ArgumentException("Not enouth fonds on account");
                }
                payAsSent.payAsSent_CurrentCredit.ValueInUsCent -= totalCost.ValueInUsCent;

                //4) update counters
                payAsSent.payAsSent_MsgSent      += telList.Length;
                payAsSent.payAsSent_LastMsgQueued = DateTime.UtcNow.Ticks;
            }
        }
コード例 #3
0
        public override void CommitOrThrow_Send(MobileNoHandler storedNumbers, string[] telList, bool isWelcomeMessage, int MessageLength, ref Data_AppUserFile.eUserStatus accountStatus, out bool sendFooter)
        {
            sendFooter = false;

            //1)
            Data_AppUserFile_Checker_Free.VerifyAllMobileNumbers(storedNumbers, telList);

            if (isWelcomeMessage)
            {
                throw new ArgumentException("Wrong account");
            }
            else
            {
                //2) checkTimeDelay()
                DateTime NotBefore = new DateTime(monthly.monthly_LastMsgQueued, DateTimeKind.Utc).AddSeconds(monthly.monthly_MinDelayInSeconds);
                if (DateTime.UtcNow < NotBefore)
                {
                    throw new ArgumentException("wait");
                }

                //3) check still active
                DateTime NotAfter = new DateTime(monthly.monthly_PaidUntil, DateTimeKind.Utc);
                if (DateTime.UtcNow > NotAfter)
                {
                    throw new ArgumentException("Please arrange a top up");
                }

                //4) update counters
                monthly.monthly_MsgSent      += telList.Length;
                monthly.monthly_LastMsgQueued = DateTime.UtcNow.Ticks;
            }
        }
コード例 #4
0
        public override void CommitOrThrow_Send(MobileNoHandler storedNumbers, string[] telList, bool isWelcomeMessage, int MessageLength, ref Data_AppUserFile.eUserStatus accountStatus, out bool sendFooter)
        {
            sendFooter = false;

            //1)
            Data_AppUserFile_Checker_Free.VerifyAllMobileNumbers(storedNumbers, telList);

            if (isWelcomeMessage)
            {
                throw new ArgumentException("Wrong account");
            }
            else
            {
                // 0) checkTimeDelay()
                DateTime NotBefore = new DateTime(monthlyDifPrice.monthlyDifPrice_LastMsgQueued, DateTimeKind.Utc)
                                     .AddSeconds(monthlyDifPrice.monthlyDifPrice_MinDelayInSeconds);
                if (DateTime.UtcNow < NotBefore)
                {
                    throw new ArgumentException("wait");
                }

                PriceLevelHandler levelHandler = new PriceLevelHandler(monthlyDifPrice.monthlyDifPrice_LevelDefinitions);
                if (!levelHandler.Ok)
                {
                    throw new ArgumentException("Please check configuration. (NO)");
                }

                // 0) first initialisation
                if (monthlyDifPrice.monthlyDifPrice_Level == 0)
                {
                    Data_AppUserFile.niceMoney cost1 = levelHandler.Config.FirstOrDefault(_ => _.Level == 1).Cost;
                    if (!monthlyDifPrice.monthlyDifPrice_CurrentCredit.DeductIfEnoughFund(cost1))
                    {
                        throw new ArgumentException("Please arrange a top up. (L0)");
                    }
                    else
                    {
                        monthlyDifPrice.monthlDifPricey_PeriodeStart     = DateTime.UtcNow.Ticks;
                        monthlyDifPrice.monthlyDifPrice_ThisMonthMsgSent = 0;
                        monthlyDifPrice.monthlyDifPrice_TotalMsgSent++;
                        monthlyDifPrice.monthlyDifPrice_Level         = 1;
                        monthlyDifPrice.monthlyDifPrice_LastMsgQueued = DateTime.UtcNow.Ticks;
                        commentLog($"Deducted {cost1} for initialisation", true);
                    }
                }

                // 1) Check aktive, sonst eine Periode mehr und auf Level 1
                if (monthlyDifPrice.HasExpired())
                {
                    if (!monthlyDifPrice.monthlyDifPrice_AutoRenewMonthPayment)
                    {
                        throw new ArgumentException("Please arrange a top up. (AR)");
                    }
                    Data_AppUserFile.niceMoney cost1 = levelHandler.Config.FirstOrDefault(_ => _.Level == 1).Cost;
                    if (!monthlyDifPrice.monthlyDifPrice_CurrentCredit.DeductIfEnoughFund(cost1))
                    {
                        throw new ArgumentException("Please arrange a top up. (L1)");
                    }
                    else
                    {
                        monthlyDifPrice.monthlDifPricey_PeriodeStart     = DateTime.UtcNow.Ticks;
                        monthlyDifPrice.monthlyDifPrice_ThisMonthMsgSent = 0;
                        monthlyDifPrice.monthlyDifPrice_TotalMsgSent++;
                        monthlyDifPrice.monthlyDifPrice_Level         = 1;
                        monthlyDifPrice.monthlyDifPrice_LastMsgQueued = DateTime.UtcNow.Ticks;
                        commentLog($"Deducted {cost1} to renew Month", true);
                    }
                }

                // 2) Check messageCount and go a level up if needed
                var curLev = levelHandler.Config.FirstOrDefault(_ => _.Level == monthlyDifPrice.monthlyDifPrice_Level);
                if (curLev == null)
                {
                    // bad config
                    throw new ArgumentException($"Please check configuration. (BL) - {levelHandler}");
                }
                if (curLev.MaxMessages == monthlyDifPrice.monthlyDifPrice_ThisMonthMsgSent)
                {
                    // no more messages left
                    if (!monthlyDifPrice.monthlyDifPrice_AutoInceremntLevel)
                    {
                        throw new ArgumentException("Please arrange a top up. (AI)");
                    }
                    var nextLev = levelHandler.Config.FirstOrDefault(_ => _.Level == (monthlyDifPrice.monthlyDifPrice_Level + 1));
                    if (nextLev == null)
                    {
                        // no more levels
                        throw new ArgumentException("Please arrange a top up. (NL)");
                    }
                    Data_AppUserFile.niceMoney costDif = new Data_AppUserFile.niceMoney(nextLev.Cost.ValueInUsCent - curLev.Cost.ValueInUsCent);
                    if (!monthlyDifPrice.monthlyDifPrice_CurrentCredit.DeductIfEnoughFund(costDif))
                    {
                        throw new ArgumentException("Please arrange a top up. (LN)");
                    }
                    else
                    {
                        monthlyDifPrice.monthlyDifPrice_Level = nextLev.Level;
                        monthlyDifPrice.monthlyDifPrice_ThisMonthMsgSent++;
                        monthlyDifPrice.monthlyDifPrice_TotalMsgSent++;
                        monthlyDifPrice.monthlyDifPrice_LastMsgQueued = DateTime.UtcNow.Ticks;
                        commentLog($"Deducted {costDif} to enter level {nextLev.Level}", true);
                    }
                }
                else
                {
                    //ok to send one more message
                    monthlyDifPrice.monthlyDifPrice_LastMsgQueued = DateTime.UtcNow.Ticks;
                    monthlyDifPrice.monthlyDifPrice_ThisMonthMsgSent++;
                    monthlyDifPrice.monthlyDifPrice_TotalMsgSent++;
                }
            }
        }