Пример #1
0
        public void HandleError(RequestItem request, Exception ex)
        {
            request.result.error     = "Request:" + request.requestString;
            request.result.exception = ex;
            if (ex == null)
            {
                request.result.errorLevel = ResultErrorLevel.ERROR;
                Logman.Log(ex, request.result.error);
                return;
            }
            if (ex.Message == null)
            {
                request.result.errorLevel = ResultErrorLevel.ERROR;
                Logman.Log(ex, request.result.error);
                return;
            }

            if
            (
                (
                    ex.Message.Contains("422") ||
                    ex.Message.Contains("503") ||
                    ex.Message.Contains("502") ||
                    ex.Message.Contains("500")
                ) ||
                (ex.Message.Contains("Ddos") && ex.Message.Contains("20-50 mins")) ||
                ex.Message.Contains("DataResult=Null")
            )
            {
                request.result.errorLevel = ResultErrorLevel.IGNORE;
                Logman.Log(request.result.error + " -> " + ex.Message);
            }
            else
            {
                request.result.errorLevel = ResultErrorLevel.ERROR;
                Logman.Log(ex, request.result.error);
            }
        }
Пример #2
0
        public void UpdateOrderBook_UIResultHandler(RequestItemGroup resultResponse)
        {
            if (RequestManager.IsResultHasErrors(resultResponse))
            {
                return;
            }

            try
            {
                AllOrders orders = (AllOrders)resultResponse.items[0].result.resultData;

                var dataViewSell = orders.sellOrders.Select(item => new
                {
                    amount = Helper.PriceToStringBtc(item.quantity),
                    price  = Helper.PriceToStringBtc(item.rate)
                }).Take(150).ToList();
                List <DGVColumn> columnsSell = new List <DGVColumn>()
                {
                    new DGVColumn("amount", "Amount", "string"),
                    new DGVColumn("price", "Price", "string")
                };
                DataGridViewWrapper gvSell = new DataGridViewWrapper(dgridSellOrders, true);
                gvSell.Create(dataViewSell, columnsSell);
                gvSell.AutoSizeFillExcept("amount");

                var dataViewBuy = orders.buyOrders.Select(item => new
                {
                    price  = Helper.PriceToStringBtc(item.rate),
                    amount = Helper.PriceToStringBtc(item.quantity)
                }).Take(150).ToList();
                DataGridViewWrapper gvBuy = new DataGridViewWrapper(dgridBuyOrders, true);
                gvBuy.Create(dataViewBuy, columnsSell);
                // gvBuy.AutoSizeFillExcept("amount");


                // contr orderbook data grid
                var dataViewContrSell = orders.sellOrders.Select(item => new
                {
                    price  = Helper.PriceToStringBtc(item.rate),
                    amount = Helper.PriceToStringBtc(item.quantity)
                }).Take(5).OrderByDescending(o => o.price).ToList();

                DataGridViewWrapper gvContrSell = new DataGridViewWrapper(dGridContrSell, true);
                gvContrSell.Create(dataViewContrSell, columnsSell);
//                if (dGridContrSell.RowCount>0)
//                  dGridContrSell.FirstDisplayedScrollingRowIndex = dGridContrSell.RowCount - 1;

                var dataViewContrBuy = orders.buyOrders.Select(item => new
                {
                    price  = Helper.PriceToStringBtc(item.rate),
                    amount = Helper.PriceToStringBtc(item.quantity)
                }).Take(5).ToList();
                DataGridViewWrapper gvContrBuy = new DataGridViewWrapper(dGridContrBuy, true);
                gvContrBuy.Create(dataViewContrBuy, columnsSell);
                gvContrBuy.ShowColumnHeaders(false);
            }
            catch (Exception ex)
            {
                Logman.Log(ex);
            }
        }