public static RatingMemberInfo Get(int userId)
    {
        Dictionary <int, RatingMemberInfo> dictionary;

        if (AppSettings.Side == ScriptSide.Client)
        {
            if (HttpContext.Current.Cache[Name] != null)
            {
                dictionary = (Dictionary <int, RatingMemberInfo>)HttpContext.Current.Cache[Name];
            }
            else
            {
                dictionary = new Dictionary <int, RatingMemberInfo>();
            }

            if (dictionary.ContainsKey(userId))
            {
                return(dictionary[userId]);
            }
            else
            {
                dictionary[userId] = CryptocurrencyPlatformManager.LoadNewUserData(userId);;
                HttpContext.Current.Cache.Insert(Name, dictionary, null, DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration,
                                                 CacheItemPriority.Normal, null);

                return(dictionary[userId]);
            }
        }
        else
        {
            return(CryptocurrencyPlatformManager.LoadNewUserData(userId));
        }
    }
Example #2
0
    public static RatingMemberInfo LoadNewUserData(int userId)
    {
        int TotalActions         = CryptocurrencyPlatformManager.GetNumberOfTransactions(userId);
        int TotalPositiveActions = CryptocurrencyPlatformManager.GetNumberOfPositiveTransactions(userId);

        return(new RatingMemberInfo(TotalActions, TotalPositiveActions));
    }
Example #3
0
    protected void AllSellOffersGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var    CurrentOffer = new CryptocurrencyTradeOffer(Int32.Parse(e.Row.Cells[0].Text));
            Member User         = new Member(Int32.Parse(e.Row.Cells[1].Text));

            e.Row.Cells[1].Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                HtmlCreator.CreateAvatarPlusUsername(User),
                                                CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

            e.Row.Cells[3].Text = String.Format("<b>{0}</b>/{1}", Money.Parse(e.Row.Cells[3].Text).ToString(), AppSettings.CryptocurrencyTrading.CryptocurrencyCode);
            e.Row.Cells[4].Text = CurrentOffer.MinOfferValue + " - " + CurrentOffer.MaxOfferValue;
            e.Row.Cells[5].Text = CryptocurrencyMoney.Parse(e.Row.Cells[5].Text).ToString();
        }
    }
Example #4
0
    public static void ProceedFrequentDistribution()
    {
        try
        {
            log = new StringBuilder();

            // [1]Escrow for Representatives Actions
            ConversationManager.CRON();

            // [2]Escrow for Cryptocurrency Trading
            CryptocurrencyPlatformManager.CRON();
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message, LogType.CRON);
            Log("FrequentCRON error: " + ex.Message);
        }
    }
Example #5
0
    protected void SellOfferButton_OnClick(object sender, EventArgs e)
    {
        try
        {
            if (Request.Params.Get("oid") != null)
            {
                var SelectedOffer = new CryptocurrencyTradeOffer(Convert.ToInt32(Request.Params.Get("oid")));

                //Because when creating buy offer you don't create description, seller have to provide necessary info for buyer
                String AdditionalDescription = InfoForBuyerForOnClickSellTextBox.Text;

                if (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) == CryptocurrencyMoney.Zero)
                {
                    throw new MsgException(U6011.CANTSELLZEROCRYPTOCURRENCY);
                }

                //Check if seller don't try sell more than expected
                if ((CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) > SelectedOffer.AmountLeft) ||
                    (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) * SelectedOffer.MaxPrice > SelectedOffer.MaxOfferValue))
                {
                    throw new MsgException(U6010.ERRORTRYSELLMORE);
                }

                if (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) * SelectedOffer.MaxPrice < SelectedOffer.MinOfferValue)
                {
                    throw new MsgException(U6010.ERRORTRYSELLLESS);
                }

                CryptocurrencyPlatformManager.TryPlaceOrder(SelectedOffer.Id, CryptocurrencyMoney.Parse(AmountToSellTextBox.Text, CryptocurrencyType.BTC), AdditionalDescription);

                Response.Redirect("~/user/cctrading/sell.aspx?SelectedTab=2");
            }
        }
        catch (MsgException ex)
        {
            SellErrorPanel.Visible = true;
            SellError.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
Example #6
0
    protected void BuyOfferButton_OnClick(object sender, EventArgs e)
    {
        try
        {
            if (Request.Params.Get("oid") != null)
            {
                int ProductId     = Convert.ToInt32(Request.Params.Get("oid"));
                var SelectedOffer = new CryptocurrencyTradeOffer(ProductId);

                if (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) == CryptocurrencyMoney.Zero)
                {
                    throw new MsgException(U6011.CANTBUYZEROCRYPTOCURRENCY);
                }

                if ((CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) > SelectedOffer.AmountLeft) ||
                    (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) * SelectedOffer.MinPrice > SelectedOffer.MaxOfferValue))
                {
                    throw new MsgException(U6010.ERRORTRYBUYMORE);
                }

                if (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) * SelectedOffer.MinPrice < SelectedOffer.MinOfferValue)
                {
                    throw new MsgException(U6010.ERRORTRYBUYLESS);
                }

                CryptocurrencyPlatformManager.TryPlaceOrder(ProductId, CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text, CryptocurrencyType.BTC), String.Empty);

                Response.Redirect("~/user/cctrading/buy.aspx?SelectedTab=2");
            }
        }
        catch (MsgException ex)
        {
            BuyErrorPanel.Visible = true;
            BuyError.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region TabAimer
        int SelectedTab = (Request.Params["SelectedTab"] != null) ? Int32.Parse(Request.Params["SelectedTab"]) : -1;
        if (SelectedTab >= 0)
        {
            MenuMultiView.ActiveViewIndex = SelectedTab;
            int Counter = MenuButtonPlaceHolder.Controls.Count - 1;
            foreach (Button b in MenuButtonPlaceHolder.Controls)
            {
                if (Counter == SelectedTab)
                {
                    b.CssClass = "ViewSelected";
                }
                else
                {
                    b.CssClass = "";
                }
                Counter--;
            }
        }
        #endregion

        #region OpenOfferDetails
        if ((!IsPostBack) && Request.Params.Get("oid") != null)
        {
            try
            {
                MenuMultiView.ActiveViewIndex = 4;

                CryptocurrencyAmount = String.Empty;
                int ProductId = Convert.ToInt32(Request.Params.Get("oid"));

                CryptocurrencyTradeOffer SelectedOffer = new CryptocurrencyTradeOffer(ProductId);

                var OfferCreator        = new Member(SelectedOffer.CreatorId);
                var OfferCreatorBalance = OfferCreator.GetCryptocurrencyBalance(CryptocurrencyType.BTC);

                //If creator of offer don't have enaugh currency in balance
                if (OfferCreatorBalance < SelectedOffer.AmountLeft)
                {
                    //If Offer AmountLeft is bigger than creator's balance, set max limit of buy to creator's balacne value
                    SelectedOffer.AmountLeft = OfferCreatorBalance;

                    if (OfferCreatorBalance == CryptocurrencyMoney.Zero)
                    {
                        SelectedOffer.Status = CryptocurrencyOfferStatus.Paused;
                        SelectedOffer.Save();
                        throw new MsgException(U6010.NOCREATORBALANCETOBUYOFFER);
                    }
                    SelectedOffer.Save();
                }

                SelectedOfferId = SelectedOffer.Id;

                decimal CountedMinCurrency, CountedMaxCurrency;

                CountedMinCurrency = decimal.Parse((SelectedOffer.MinOfferValue / SelectedOffer.MinPrice).ToClearString());
                CountedMaxCurrency = decimal.Parse((SelectedOffer.MaxOfferValue / SelectedOffer.MinPrice).ToClearString());
                if (SelectedOffer.AmountLeft < CryptocurrencyMoney.Parse(CountedMaxCurrency.ToString()))
                {
                    CountedMaxCurrency = decimal.Parse(SelectedOffer.AmountLeft.ToClearString());
                }


                Member User = new Member(SelectedOffer.CreatorId);
                CreatorNameLabel.Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                      HtmlCreator.CreateAvatarPlusUsername(User),
                                                      CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

                MinOfferLabel.Text = SelectedOffer.MinOfferValue.ToString();
                MaxOfferLabel.Text = SelectedOffer.MaxOfferValue.ToString();
                CurrencyAvailableToBuyLabel.Text = SelectedOffer.AmountLeft.ToString();

                MinCryptocurrencyAmount = CountedMinCurrency;
                MaxCryptocurrencyAmount = CountedMaxCurrency;
                MinCurrencyLabel.Text   = CryptocurrencyMoney.Parse(CountedMinCurrency.ToString()).ToString();
                MaxCurrencyLabel.Text   = CryptocurrencyMoney.Parse(CountedMaxCurrency.ToString()).ToString();


                PricePerCurrencyLabel.Text = SelectedOffer.MinPrice.ToString();
                PricePerCryptocurrency     = decimal.Parse(SelectedOffer.MinPrice.ToClearString());

                AmountToBuyTextBox.Text = CountedMinCurrency.ToString();

                //Updating Total Price label after every change of Cryptocurrency Amount
                AmountToBuyTextBox.Attributes.Add("onkeyup", "updatePrice();");

                CashToPayLabel.Text = decimal.Round(PricePerCryptocurrency * MinCryptocurrencyAmount, CoreSettings.GetMaxDecimalPlaces()).ToString();

                testerTB.Text       = SelectedOffer.Description;
                Description         = SelectedOffer.Description;
                BuyOfferButton.Text = L1.BUY;
            }
            catch (MsgException ex)
            {
                AllOffersErrorPanel.Visible = true;
                AllOffersErrorLiteral.Text  = ex.Message;
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex.Message);
                throw ex;
            }
        }
        #endregion

        #region OpenAddCommentView
        if ((!IsPostBack) && Request.Params.Get("foid") != null)
        {
            MenuMultiView.ActiveViewIndex = 5;
        }
        #endregion

        if (!IsPostBack)
        {
            AddLang();
        }

        //Constraint DataBind for second ManageTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 2)
        {
            ManageTabDataBind();
        }

        //Constraint DataBind for second HistoryTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 3)
        {
            OfferHistoryGridView.DataBind();
        }
    }
Example #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CryptocurrencyAmount = String.Empty;

        #region TabAimer
        int SelectedTab = (Request.Params["SelectedTab"] != null) ? Int32.Parse(Request.Params["SelectedTab"]) : -1;
        if (SelectedTab >= 0)
        {
            MenuMultiView.ActiveViewIndex = SelectedTab;
            int Counter = MenuButtonPlaceHolder.Controls.Count - 1;
            foreach (Button b in MenuButtonPlaceHolder.Controls)
            {
                if (Counter == SelectedTab)
                {
                    b.CssClass = "ViewSelected";
                }
                else
                {
                    b.CssClass = "";
                }
                Counter--;
            }
        }
        #endregion

        #region OpenDetailsInfoView
        if ((!IsPostBack) && Request.Params.Get("oid") != null)
        {
            int ProductId = Convert.ToInt32(Request.Params.Get("oid"));

            CryptocurrencyTradeOffer SelectedOffer = new CryptocurrencyTradeOffer(ProductId);
            MenuMultiView.ActiveViewIndex = 4;
            SelectedOfferId = SelectedOffer.Id;

            //Counting min-max currency amount limits to sell
            CryptocurrencyMoney CountedMinCurrency, CountedMaxCurrency;
            CountedMinCurrency = CryptocurrencyMoney.Parse((SelectedOffer.MinOfferValue / SelectedOffer.MaxPrice).ToClearString(), CryptocurrencyType.BTC);
            CountedMaxCurrency = CryptocurrencyMoney.Parse((SelectedOffer.MaxOfferValue / SelectedOffer.MaxPrice).ToClearString(), CryptocurrencyType.BTC);

            if (SelectedOffer.AmountLeft < CountedMaxCurrency)
            {
                CountedMaxCurrency = SelectedOffer.AmountLeft;
            }

            //Creator info
            Member User = new Member(SelectedOffer.CreatorId);
            CreatorNameLabel.Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                  HtmlCreator.CreateAvatarPlusUsername(User),
                                                  CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

            //Other info
            MinOfferLabel.Text = SelectedOffer.MinOfferValue.ToString();
            MaxOfferLabel.Text = SelectedOffer.MaxOfferValue.ToString();
            CurrencyAvailableToBuyLabel.Text = SelectedOffer.AmountLeft.ToString();

            MinCurrencyLabel.Text   = CountedMinCurrency.ToString();
            MaxCurrencyLabel.Text   = CountedMaxCurrency.ToString();
            MinCryptocurrencyAmount = decimal.Parse(CountedMinCurrency.ToClearString());
            MaxCryptocurrencyAmount = decimal.Parse(CountedMaxCurrency.ToClearString());

            PricePerCurrencyLabel.Text = SelectedOffer.MaxPrice.ToClearString();
            PricePerCryptocurrency     = decimal.Parse(SelectedOffer.MaxPrice.ToClearString());

            AmountToSellTextBox.Text = CountedMinCurrency.ToClearString();

            InfoForBuyerForOnClickSellTextBox.Text = String.Empty;
            Description = SelectedOffer.Description;

            //Updating Total Price label after every change of Cryptocurrency Amount
            AmountToSellTextBox.Attributes.Add("onkeyup", "updatePrice();");

            CashToPayLabel.Text = String.Format("{0}", decimal.Round(PricePerCryptocurrency * MinCryptocurrencyAmount, CoreSettings.GetMaxDecimalPlaces()).ToString());
        }
        #endregion

        #region OpenAddCommentView
        if ((!IsPostBack) && Request.Params.Get("foid") != null)
        {
            MenuMultiView.ActiveViewIndex = 5;
        }
        #endregion

        if (!IsPostBack)
        {
            AddLang();
        }

        //Constraint DataBind for second ManageTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 2)
        {
            ManageTabDataBind();
        }

        //Constraint DataBind for second HistoryTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 3)
        {
            OfferHistoryGridView.DataBind();
        }
    }