Ejemplo n.º 1
0
    protected void OfferDataRowBound(GridViewRow row, GridView gridView)
    {
        decimal             amount         = Decimal.Parse(row.Cells[2].Text);
        decimal             value          = Decimal.Parse(row.Cells[3].Text);
        DateTime            offerDateTime  = DateTime.Parse(row.Cells[6].Text);
        ExchangeOfferStatus status         = (ExchangeOfferStatus)Int32.Parse(row.Cells[7].Text);
        decimal             originalAmount = Decimal.Parse(row.Cells[10].Text);

        row.Cells[2].Text = FormatDecimal(amount);
        row.Cells[3].Text = FormatDecimal(value);
        row.Cells[4].Controls.Add(GetFreezedValueOfOfferLabel(amount, value));
        row.Cells[5].Controls.Add(GetCurrentOfferVolumeLabel(amount, originalAmount));
        //row.Cells[8].Style.Add("width", "15%");

        //If offer lifetime is lower than limit, user can't withdraw it
        if (status == ExchangeOfferStatus.Open &&
            AppSettings.InternalExchange.InternalExchangeLockWithdraw &&
            offerDateTime > AppSettings.ServerTime.AddMinutes(-AppSettings.InternalExchange.InternalExchangeLockWithdrawTime))
        {
            row.Cells[8].Controls[1].Visible = false;
            row.Cells[8].Style.Add("color", "green");
            row.Cells[8].Style.Add("width", "13px");
            row.Cells[8].Controls.Add(GetOfferWithdrawalCounterLabel(offerDateTime));
        }
        else if (status != ExchangeOfferStatus.Open)
        {
            row.Cells[8].Controls[1].Visible = false;
        }

        if (amount == originalAmount)
        {
            row.Cells[9].Controls[1].Visible = false;
        }

        if (status == ExchangeOfferStatus.Open && amount != originalAmount)
        {
            status = ExchangeOfferStatus.Partial;
        }

        Label statusLabel = new Label();

        statusLabel.Text     = status.ToString();
        statusLabel.CssClass = String.Format("badge {0}", ExchangeOfferStatusHelper.ColorDictionary[status]);
        row.Cells[7].Controls.Add(statusLabel);

        int    tradeDetailIndex = (int)ViewState[tradeDetailIndexString];
        string tradeDetailGrid  = ViewState[tradeDetailGridString].ToString();

        bool show =
            tradeDetailIndex == row.RowIndex &&
            tradeDetailGrid == gridView.ID;

        var placeHolder = (PlaceHolder)row.Cells[11].Controls[1];

        if (show)
        {
            int offerId       = Int32.Parse(row.Cells[0].Text);
            var childGridView = (GridView)placeHolder.Controls[1];

            List <InternalExchangeTransaction> date = tradeDetailGrid == UserCurrentAsksGridView.ID ?
                                                      InternalExchangeTransaction.GetAskDetail(offerId) :
                                                      InternalExchangeTransaction.GetBidDetail(offerId);

            childGridView.DataSource = date;
            childGridView.DataBind();
        }

        placeHolder.Visible = show;
    }
Ejemplo n.º 2
0
    private void UpdateStatisticsData()
    {
        Regex rgx = new Regex("[0-9]+([.,][0-9]+)?");

        var test = rgx.Match(Last24LowValue.Text).NextMatch();

        //LAST STOCK VALUE
        tmpLastStockValue = InternalExchangeTransaction.GetLastStockValue(FirstIncome);
        if (FirstIncome)
        {
            tmpCurrentStockValue = InternalExchangeTransaction.GetLastStockValue(!FirstIncome);
        }
        else
        {
            tmpCurrentStockValue = rgx.IsMatch(LastStockValue.Text) ? Decimal.Parse(rgx.Match(LastStockValue.Text).Value) : 0.0m;
        }

        //LAST ASK VALUE
        tmpLastAskValue = InternalExchangeTransaction.GetLastAskValue(FirstIncome);
        if (FirstIncome)
        {
            tmpCurrentLastAskValue = InternalExchangeTransaction.GetLastAskValue(!FirstIncome);
        }
        else
        {
            tmpCurrentLastAskValue = rgx.IsMatch(LastAskValue.Text) ? Decimal.Parse(rgx.Match(LastAskValue.Text).Value) : 0.0m;
        }

        //LAST BID VALUE
        tmpLastBidValue = InternalExchangeTransaction.GetLastBidValue(FirstIncome);
        if (FirstIncome)
        {
            tmpCurrentLastBidValue = InternalExchangeTransaction.GetLastBidValue(!FirstIncome);
        }
        else
        {
            tmpCurrentLastBidValue = rgx.IsMatch(LastBidValue.Text) ? Decimal.Parse(rgx.Match(LastBidValue.Text).Value) : 0.0m;
        }

        //LAST 24H HIGH
        tmpLast24HighValue = InternalExchangeTransaction.GetLast24hHigh(FirstIncome);
        if (FirstIncome)
        {
            tmpCurrentLast24HighValue = InternalExchangeTransaction.GetLast24hHigh(!FirstIncome);
        }
        else
        {
            tmpCurrentLast24HighValue = rgx.IsMatch(Last24HighValue.Text) ? Decimal.Parse(rgx.Match(Last24HighValue.Text).NextMatch().Value) : 0.0m;
        }

        //LAST 24H LOW
        tmpLast24LowValue = InternalExchangeTransaction.GetLast24hLow(FirstIncome);
        if (FirstIncome)
        {
            tmpCurrentLast24LowValue = InternalExchangeTransaction.GetLast24hLow(!FirstIncome);
        }
        else
        {
            tmpCurrentLast24LowValue = rgx.IsMatch(Last24LowValue.Text) ? Decimal.Parse(rgx.Match(Last24LowValue.Text).NextMatch().Value) : 0.0m;
        }

        //LAST 24H VOLUME
        tmpLast24Volume = InternalExchangeTransaction.GetLast24hVolume(FirstIncome);
        if (FirstIncome)
        {
            tmpCurrentLast24Volume = InternalExchangeTransaction.GetLast24hVolume(!FirstIncome);
        }
        else
        {
            tmpCurrentLast24Volume = rgx.IsMatch(Last24Volume.Text) ? Decimal.Parse(rgx.Match(Last24Volume.Text).NextMatch().Value) : 0.0m;
        }

        FirstIncome = false;
    }
Ejemplo n.º 3
0
    public static Money GetCurrentExchangeRate(string exchangeCodeId, string currencyCode)
    {
        //Usually we takie it right from the API
        //However it differs for ERC20 Token Because we don't have its value in the API

        #region Token value

        if (exchangeCodeId == "ERC20Token")
        {
            if (AppSettings.Site.CurrencyIsTokenCryptocurrency)
            {
                return(new Money(1));
            }
            else
            {
                return(AppSettings.Ethereum.ERC20TokenRate);
            }
        }

        //We have token cryptocurrency as our main website currency and we want to fetch other official cryptocurrency value
        //We need to get token value to BTC/USD/whatever and then lookup the value in the API
        if (currencyCode == AppSettings.Site.CurrencyCode && AppSettings.Site.CurrencyIsTokenCryptocurrency)
        {
            if (AppSettings.Payments.TokenCryptocurrencyValueType == TokenCryptocurrencyValue.Static)
            {
                if (AppSettings.Ethereum.ERC20TokenRate.IsZero)
                {
                    return(Money.Zero);
                }

                //We have static value in USD (1 TOKEN = X USD)
                Money OneCryptoInUSD = CoinmarketcapHelper.GetCurrentExchangeRateFromAPI(exchangeCodeId, "USD");
                return(new Money(OneCryptoInUSD.ToDecimal() / AppSettings.Ethereum.ERC20TokenRate.ToDecimal()));
            }
            else if (AppSettings.Payments.TokenCryptocurrencyValueType == TokenCryptocurrencyValue.DynamicFromInternalExchange)
            {
                //We take value from Internal Exchange
                decimal OneStockValue = InternalExchangeTransaction.GetLastStockValue();
                if ((AppSettings.InternalExchange.InternalExchangeStockType == BalanceType.MainBalance ||
                     AppSettings.InternalExchange.InternalExchangeStockType == BalanceType.CashBalance) &&
                    AppSettings.InternalExchange.InternalExchangePurchaseVia == BalanceType.BTC)
                {
                    if (OneStockValue == 0)
                    {
                        return(Money.Zero);
                    }

                    //Stock = our token currency
                    //Purchase via BTC
                    Money OneCryptoInBTC = CoinmarketcapHelper.GetCurrentExchangeRateFromAPI(exchangeCodeId, "BTC");
                    return(new Money(OneCryptoInBTC.ToDecimal() / OneStockValue));
                }
            }

            return(new Money(1));
        }

        #endregion

        return(GetCurrentExchangeRateFromAPI(exchangeCodeId, currencyCode));
    }
Ejemplo n.º 4
0
 private void UpdateGridViewTitles()
 {
     RightTitleBidOffersLabel.Text = String.Format("{0}: <b>{1}</b>", U5001.TOTAL, InternalExchangeManager.RecognizeCurrencyAndReturnString(true, InternalExchangeTransaction.GetSumOfStockForOffers(true)));
     RightTitleAskOffersLabel.Text = String.Format("{0}: <b>{1}</b>", U5001.TOTAL, InternalExchangeManager.RecognizeCurrencyAndReturnString(false, InternalExchangeTransaction.GetValueOfOffers(false)));
 }