public override void Execute(TelegramBotClient botClient, System.Object message)
        {
            IStandartCommand standartCommand = new ThisIncomeChannel();

            if (standartCommand.SetCallbackQuery(message, out _message))
            {
                return;
            }

            if (standartCommand.SetDataBase(out db))
            {
                return;
            }

            if (standartCommand.SetUserAndCheckIsNull(botClient, _message, out user, db))
            {
                return;
            }
            if (IsBan.Ban(botClient, message))
            {
                if (user.IsAdmin >= 2)
                {
                    SendMessage(botClient);

                    IncomeChannel[] income = db.GetIncomeChannels();

                    PrintExel.GetAnaliticsIncomeChannel(income, botClient, _message, user);
                }
            }
        }
예제 #2
0
        private void SetIncomeChannel(Int32 id, Single total, PostTemplate postTemplate = null)
        {
            DataBase           db      = Singleton.GetInstance().Context;
            List <ChannelInfo> channel = null;

            if (postTemplate == null)
            {
                channel = StartSession.Test(db.GetChannelsList(), id);
            }
            else
            {
                List <Channel> channels = new List <Channel>();
                foreach (var item in postTemplate.PostChannel)
                {
                    Channel Thischannel = db.GetChannel(item.ChannelId);
                    channels.Add(Thischannel);
                }
                channel = StartSession.Test(channels, id);
            }

            Int32 temp = channel.Count;

            foreach (var item in channel)
            {
                IncomeChannel incomeChannel = db.GetIncomeChannels((item.Channel.Id + 1000000000000) * -1);
                if (incomeChannel == null)
                {
                    db.SetValue <IncomeChannel>(new IncomeChannel()
                    {
                        ChannelId = (item.Channel.Id + 1000000000000) * -1, DateTime = System.DateTime.Today, SumIncome = total / temp
                    });
                }
                else
                {
                    incomeChannel.SumIncome = (total / temp) + incomeChannel.SumIncome;
                }
            }
            db.Save();
            SetIncome(channel, id, total);
            SetIncomeChannelAdmin(channel, total);
        }