public override System.Object Handle(System.Int32 request, TelegramBotClient botClient, System.Object message)
        {
            if (request == (System.Int32)SetChain.SetPublicKeyUserTwo)
            {
                _message = message as Message;
                db       = Singleton.GetInstance().Context;

                user = db.GetUser(_message.From.Id);
                if (IsNullDataBase.IsNull(botClient, _message, user))
                {
                    return(null);
                }

                transaction = db.GetTransactionUserRecipient(user);
                if (IsNullDataBase.IsNull(botClient, _message, transaction))
                {
                    transaction = db.GetTransactionUserSender(user);
                    if (IsNullDataBase.IsNull(botClient, _message, transaction))
                    {
                        return(null);
                    }
                }


                SetPublicKey();

                ChangeUserChanin();
                ChangeTransaction();

                SendMessage(botClient, _message);

                return(null);
            }
            else
            {
                return(base.Handle(request, botClient, message));
            }
        }
Пример #2
0
        public override System.Object Handle(System.Int32 request, TelegramBotClient botClient, System.Object message)
        {
            if (request == (System.Int32)SetChain.SetIdTransaction)
            {
                _message = message as Message;
                db       = Singleton.GetInstance().Context;

                user = db.GetUser(_message.From.Id);
                if (IsNullDataBase.IsNull(botClient, _message, user))
                {
                    return(null);
                }

                transaction = db.GetTransaction(user);
                if (IsNullDataBase.IsNull(botClient, _message, transaction))
                {
                    return(null);
                }

                ChangeUserChanin();

                if (!CheckIdTransaction(botClient).Result)
                {
                    return(null);
                }

                SendMessage(botClient, _message);

                Task.Run(() => SetIncomeChannel(botClient));

                return(null);
            }
            else
            {
                return(base.Handle(request, botClient, message));
            }
        }
Пример #3
0
        private async Task <Boolean> CheckIdTransaction(TelegramBotClient botClient)
        {
            Transaction   found   = db.GetTransactionByHash(_message.Text);
            TransactionId errTran = db.GetFailedTransactionByHash(_message.Text);

            Boolean isAlreadyUsed = (found != null || errTran != null);

            if (isAlreadyUsed)
            {
                AddIdTransactionFalse();
                botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");
                botClient.EditMessage(_message.From.Id, user.MessageID, "Данная транзакция уже была использованна или она не действительная!", "51 - SetIdTransaction", user, replyMarkup: InlineButtonBlockchain.TransactionCreationGuarantor(transaction));
                return(false);
            }

            Money money = null;

            try
            {
                switch (transaction.PaymentId)
                {
                case 0:
                {
                    return(false);
                }

                case 1:                         // BTC
                {
                    addresBTC = db.GetAddresBTCInt(transaction.AddresBTCId);
                    money     = await BlockchainManager.Instance.GetBTCTransactionMoney(_message.Text, addresBTC);

                    break;
                }

                case 3:                         // Eth
                {
                    money = await BlockchainManager.Instance.GetETHTransactionMoney(_message.Text);

                    break;
                }

                case 4:                         // Ripple
                {
                    money = await BlockchainManager.Instance.GetXRPTransactionMoney(_message.Text);

                    break;
                }
                }
            }
            catch
            {
                AddIdTransactionIsNotBD();
                botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");
                botClient.EditMessage(_message.From.Id, user.MessageID, "Данная транзакция не действительная или она не была подтвержденна, попробуйте ввести транзакцию позже!", "86 - SetIdTransaction", user, replyMarkup: InlineButtonBlockchain.TransactionCreationGuarantor(transaction));
                return(false);
            }
            if (money == null)
            {
                AddIdTransactionFalse();
                botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");
                botClient.EditMessage(_message.From.Id, user.MessageID, "Данная транзакция не действительная или она не была подтвержденна, попробуйте ввести транзакцию позже!", "92 - SetIdTransaction", user, replyMarkup: InlineButtonBlockchain.TransactionCreationGuarantor(transaction));
                return(false);
            }
            Decimal dec     = money.ToDecimal(MoneyUnit.BTC);
            Decimal percent = Convert.ToDecimal(0.15);

            if (dec < transaction.SumPayNew)
            {
                switch (transaction.PaymentId)
                {
                case 1:
                {
                    addresBTC = db.GetAddresBTCInt(transaction.AddresBTCId);
                    await BlockchainManager.Instance.SendBTC(transaction.PublicKeyWalletSender, dec, 0, addresBTC);

                    break;
                }

                case 3:
                {
                    await BlockchainManager.Instance.SendETHBackByHash(_message.Text);

                    break;
                }

                case 4:
                {
                    await BlockchainManager.Instance.SendXRPBackByHash(_message.Text);

                    break;
                }
                }

                AddIdTransactionFalse();
                botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");
                botClient.EditMessage(_message.From.Id, user.MessageID, "Вы отправили меньше денег нежелеи заявили, ваши деньги были возращены на ваш кошелек!", "122 - SetIdTransaction", user, replyMarkup: InlineButtonBlockchain.TransactionCreationGuarantor(transaction));
                return(false);
            }

            AddIdTransaction();
            return(true);
        }