예제 #1
0
        private void ExchangeMoney(Balances balances)
        {
            eventLog1.WriteEntry("Exchange of Currencies Action Started.");
            Currency _exchangefrom = allCurrencies.Find(l => l.name == _exch_from);
            double   _from_balance = balances.available.SelectToken(_exchangefrom.id.ToString()).Value <double>();

            eventLog1.WriteEntry("Your Current Balance for " + _exchangefrom.name + " Coins is: " + _from_balance);
            if (_from_balance > 0)
            {
                eventLog1.WriteEntry("Valid Balance of " + _exchangefrom.name + " Coins. Exchange Operation is forwarding.");
            }
            else
            {
                eventLog1.WriteEntry("Invalid Balance of " + _exchangefrom.name + " Coins. No Exchange is Possible.");
                return;
            }
            Boolean IsSellSuccess = allrequests.PlaceOrder(_exchangefrom.code, "btc", _from_balance.ToString(), true);

            if (IsSellSuccess)
            {
                Currency _exchangeto = allCurrencies.Find(l => l.name == _exch_to);
                balances = allrequests.AllBalance;
                double _to_balance = balances.available.SelectToken("3").Value <double>();
                eventLog1.WriteEntry("Your Current Balance for btc Coins is: " + _to_balance);
                if (_to_balance > 0)
                {
                    eventLog1.WriteEntry("Valid Balance of btc Coins. Exchange Operation is forwarding.");
                }
                else
                {
                    eventLog1.WriteEntry("Invalid Balance of btc Coins. No Exchange is Possible.");
                    return;
                }
                Boolean IsBuySuccess = allrequests.PlaceOrder("btc", _exchangeto.code, _to_balance.ToString(), false);
                if (!IsBuySuccess)
                {
                    eventLog1.WriteEntry("Buy Order Failed.");
                }
                else
                {
                    eventLog1.WriteEntry("Buy Order Placed.");
                }
            }
            else
            {
                eventLog1.WriteEntry("Buy Can not be processed without performing Sell.");
            }
        }
예제 #2
0
        private void Withdrawl()
        {
            eventLog1.WriteEntry("Withdrawl Action Started.");
            Balances balances          = allrequests.AllBalance;
            Currency withdrawlcurrency = allCurrencies.Find(l => l.name == _with_from);
            double   bal = balances.available.SelectToken(withdrawlcurrency.id.ToString()).Value <double>();

            if (bal > 0)
            {
                allrequests.Withdraw(bal.ToString(), text_withdrawlto.Text.ToString(), withdrawlcurrency.id.ToString());
            }
            else
            {
                eventLog1.WriteEntry("Invalid Balance of " + withdrawlcurrency.name + " Coins. No Withdrawl is Possible.");
                return;
            }
        }
예제 #3
0
        private void PerformOperations(String publickey, String privatekey, String ExchangeFrom, String ExchangeTo, String WithdrawlFrom, String WithdrawlTo)
        {
            eventLog1.WriteEntry("Performing Start Action.");
            _exch_from             = ExchangeFrom;
            _exch_to               = ExchangeTo;
            _with_from             = WithdrawlFrom;
            _with_to               = WithdrawlTo;
            _pub_key               = publickey;
            _pri_key               = privatekey;
            allrequests.PrivateKey = privatekey;
            allrequests.PublicKey  = publickey;
            Balances all = allrequests.AllBalance;

            ExchangeMoney(all);
            Withdrawl();
            eventLog1.WriteEntry("Starting the Service.");
            StartTimer();
        }
예제 #4
0
 private void ExchangeMoney(Balances balances)
 {
     eventLog1.WriteEntry("Exchange of Currencies Action Started.");
     Currency _exchangefrom=allCurrencies.Find(l => l.name == _exch_from);
     double _from_balance= balances.available.SelectToken(_exchangefrom.id.ToString()).Value<double>();
     eventLog1.WriteEntry("Your Current Balance for "+_exchangefrom.name+" Coins is: "+_from_balance);
     if(_from_balance>0)
     {
         eventLog1.WriteEntry("Valid Balance of " + _exchangefrom.name + " Coins. Exchange Operation is forwarding.");
     }
     else
     {
         eventLog1.WriteEntry("Invalid Balance of " + _exchangefrom.name + " Coins. No Exchange is Possible.");
         return;
     }
     Boolean IsSellSuccess= allrequests.PlaceOrder(_exchangefrom.code, "btc", _from_balance.ToString(), true);
     if(IsSellSuccess)
     {
         Currency _exchangeto = allCurrencies.Find(l => l.name == _exch_to);
         balances = allrequests.AllBalance;
         double _to_balance = balances.available.SelectToken("3").Value<double>();
         eventLog1.WriteEntry("Your Current Balance for btc Coins is: " + _to_balance);
         if (_to_balance > 0)
         {
             eventLog1.WriteEntry("Valid Balance of btc Coins. Exchange Operation is forwarding.");
         }
         else
         {
             eventLog1.WriteEntry("Invalid Balance of btc Coins. No Exchange is Possible.");
             return;
         }
         Boolean IsBuySuccess = allrequests.PlaceOrder( "btc",_exchangeto.code, _to_balance.ToString(), false);
         if(!IsBuySuccess)
         {
             eventLog1.WriteEntry("Buy Order Failed.");
         }
         else
         {
             eventLog1.WriteEntry("Buy Order Placed.");
         }
     }
     else
     {
         eventLog1.WriteEntry("Buy Can not be processed without performing Sell.");
     }
 }