public void ExchangeChartDashboard_Sub(string Coin, string PriceType, string PriceCode)
        {
            InitializeComponent();

            web           = new System.Windows.Forms.WebBrowser();
            this.Loaded  += ExchangeChartDashboard_Loaded;
            this.Closing += ExchangeChartDashboard_Closing;

            web.ScriptErrorsSuppressed = true;
            wfh.Child              = web;
            web.DocumentCompleted += web_DocumentCompleted;
            web.Resize            += Web_Resize;

            NowCoin        = Coin;
            NowPriceType   = PriceCode;
            txtPulbic.Text = PriceType;

            btnList = new ObservableCollection <btnInfo>();

            if (PriceType.Equals(CommonLib.StandardCurcyNm))
            {
                foreach (ResponseGetMkCoinListListtModel item in MainViewModel.CoinList.KRW)
                {
                    btnList.Add(ViewModelSource.Create(() => new btnInfo(item.curcyNm, item.curcyCd)));
                }
            }
            else if (PriceType.Equals("ETH"))
            {
                foreach (ResponseGetMkCoinListListtModel item in MainViewModel.CoinList.ETH)
                {
                    btnList.Add(ViewModelSource.Create(() => new btnInfo(item.curcyNm, item.curcyCd)));
                }
            }
            else if (PriceType.Equals("USDT"))
            {
                foreach (ResponseGetMkCoinListListtModel item in MainViewModel.CoinList.USDT)
                {
                    btnList.Add(ViewModelSource.Create(() => new btnInfo(item.curcyNm, item.curcyCd)));
                }
            }
            else if (PriceType.Equals("BTC"))
            {
                foreach (ResponseGetMkCoinListListtModel item in MainViewModel.CoinList.BTC)
                {
                    btnList.Add(ViewModelSource.Create(() => new btnInfo(item.curcyNm, item.curcyCd)));
                }
            }

            itemBtnList.ItemsSource = btnList;

            foreach (btnInfo item in btnList.ToList())
            {
                item.Cancel();

                if (item.curcyNm.Equals(StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(NowCoin).ToString()))
                {
                    item.Select();
                }
            }
        }
        public void GetArbitrageTradeList()
        {
            try
            {
                //아비트리지 거래내역 API 호출
                using (RequestArbitrageTradeHistoryModel req = new RequestArbitrageTradeHistoryModel())
                {
                    req.userEmail = MainViewModel.LoginDataModel.userEmail;
                    req.cnKndNm   = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(_OrderCode).ToString();
                    req.listSize  = listSize;

                    using (ResponseArbitrageTradeHistoryModel res = WebApiLib.SyncCallEncrypt <ResponseArbitrageTradeHistoryModel, RequestArbitrageTradeHistoryModel>(req))
                    {
                        if (res.resultStrCode == "000")
                        {
                            tradeList = new ObservableCollection <ResponseArbitrageTradeHistoryListModel>();
                            tradeList = res.data.list;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
        protected CoinExchangeReservationTradingViewModel()
        {
            try
            {
                Messenger.Default.Register <string>(this, CallSelectSetting);
                #region Combobox 초기화

                SelCoinData = new ObservableCollection <ComboBoxCoinData>();
                ChgCoinData = new ObservableCollection <ComboBoxCoinData>();


                foreach (ResponseCoinListModel item in MainViewModel.CoinData.list)
                {
                    SelCoinData.Add(new ComboBoxCoinData()
                    {
                        Name = item.CoinName, Value = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(item.CoinCode)
                    });
                    ChgCoinData.Add(new ComboBoxCoinData()
                    {
                        Name = item.CoinName, Value = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(item.CoinCode)
                    });
                }

                SelCoin = SelCoinData[0];
                ChgCoin = ChgCoinData[0];

                #endregion
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
Beispiel #4
0
        public void CmdMenuSelected(DevExpress.Xpf.Core.TabControlSelectionChangedEventArgs e)
        {
            try
            {
                string temp = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(((DevExpress.Xpf.Core.DXTabItem)e.NewSelectedItem).Tag.ToString()).ToString();

                HeaderName = temp.Equals("KRW") ? CommonLib.StandardCurcyNm : temp;
                HeaderCode = ((DevExpress.Xpf.Core.DXTabItem)e.NewSelectedItem).Tag.ToString();

                if (MainViewModel.mQClient.CoinPriceData2.ToList().Where(w => w.Key.Key == HeaderCode && w.Key.Value == SelectTime.Value).Count() > 0)
                {
                    CoinSocketData(MainViewModel.mQClient.CoinPriceData2[new KeyValuePair <string, string>(HeaderCode, SelectTime.Value)]);
                }

                if (HeaderCode.Equals(CommonLib.StandardCurcyCd))
                {
                    CommonFloat = "n0";
                }
                else
                {
                    CommonFloat = "n8";
                }

                CmdSelectCoin(SelectItem);
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
        //초기화
        public async void GetAutoCoinSetting()
        {
            try
            {
                using (RequestTradingCoinAutoTradeSelModel req = new RequestTradingCoinAutoTradeSelModel())
                {
                    req.userEmail = MainViewModel.LoginDataModel.userEmail;

                    using (ResponseTradingCoinAutoTradeSelModel res = await WebApiLib.AsyncCall <ResponseTradingCoinAutoTradeSelModel, RequestTradingCoinAutoTradeSelModel>(req))
                    {
                        ResponseTradingCoinAutoTradeSelDataModel catTemp = res.data;

                        SelCoin = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(catTemp.selCnKndCd).ToString();
                        ChgCoin = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(catTemp.chgCnKndCd).ToString();

                        CoinAutoTradeContent = catTemp;
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
Beispiel #6
0
        public void GetAsset()
        {
            try
            {
                TotAsset     = 0;
                coinTotAsset = 0;

                AssetValue  = new ObservableCollection <ResponseMainAssetListModel>();
                AssetHeight = 53;

                string CommonFloat = "n0";

                foreach (ResponseMainAssetListModel item in MainViewModel.Asset)
                {
                    if (item.trLimtAmt > 0)
                    {
                        item.trLimtColor = "Red";
                    }
                    else
                    {
                        item.trLimtColor = "Black";
                    }

                    if (item.curcyCd.Equals(StringEnum.GetStringValue(EnumLib.ExchangeCurrencyCode.KRW)))
                    {
                        item.curcyNm = CommonLib.StandardCurcyNm;

                        CommonFloat = "n" + MainViewModel.CoinData.CashDecimal;

                        item.posCn           = item.posCnPrc.ToString(CommonFloat);
                        item.impCn           = item.impCnPrc.ToString(CommonFloat);
                        item.totCn           = item.kwdPrc.ToString(CommonFloat);
                        item.trustCn         = item.trustPrc.ToString(CommonFloat);
                        item.trLimtCn        = item.trLimtAmt.ToString(CommonFloat);
                        UsdAsset             = item;
                        TotAsset            += UsdAsset.kwdPrc;
                        item.ExchangeVisible = System.Windows.Visibility.Collapsed;
                    }
                    else
                    {
                        item.curcyNm = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(item.curcyCd).ToString();

                        //ResponseCoinListModel cl = MainViewModel.CoinData.list.Where(w => w.CoinCode == item.curcyCd).FirstOrDefault();
                        CommonFloat = "n0";

                        coinTotAsset  = item.kwdPrc;
                        TotAsset     += item.kwdPrc;
                        item.posCn    = item.posCnAmt.ToString("#,0.00000000");
                        item.impCn    = item.impCnAmt.ToString("#,0.00000000");
                        item.totCn    = item.totCoinAmt.ToString("#,0.00000000");
                        item.trustCn  = item.trustAmt.ToString("#,0.00000000");
                        item.trLimtCn = item.trLimtAmt.ToString("#,0.00000000");

                        if (item.posCnPrc > 0)
                        {
                            item.posExchange = "( " + "≈" + item.posCnPrc.ToString(CommonFloat) + " " + CommonLib.StandardCurcyNm + ")";
                        }
                        else
                        {
                            item.posExchange = "( " + item.posCnPrc.ToString(CommonFloat) + " " + CommonLib.StandardCurcyNm + ")";
                        }
                        if (item.impCnPrc > 0)
                        {
                            item.impExchange = "( " + "≈" + item.impCnPrc.ToString(CommonFloat) + " " + CommonLib.StandardCurcyNm + ")";
                        }
                        else
                        {
                            item.impExchange = "( " + item.impCnPrc.ToString(CommonFloat) + " " + CommonLib.StandardCurcyNm + ")";
                        }
                        if (item.kwdPrc > 0)
                        {
                            item.totExchange = "( " + "≈" + item.kwdPrc.ToString(CommonFloat) + " " + CommonLib.StandardCurcyNm + ")";
                        }
                        else
                        {
                            item.totExchange = "( " + item.kwdPrc.ToString(CommonFloat) + " " + CommonLib.StandardCurcyNm + ")";
                        }

                        if (item.trustPrc > 0)
                        {
                            item.trustExchange = "( " + "≈" + item.trustPrc.ToString(CommonFloat) + " " + CommonLib.StandardCurcyNm + ")";
                        }
                        else
                        {
                            item.trustExchange = "( " + item.trustPrc.ToString(CommonFloat) + " " + CommonLib.StandardCurcyNm + ")";
                        }

                        item.ExchangeVisible = System.Windows.Visibility.Visible;
                    }

                    AssetValue.Add(item);
                    AssetHeight += 35;
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
        //public void OnbCheckChanged()
        //{
        //    try
        //    {
        //        if (bCheck)
        //        {
        //            ini.SetCheckID(bCheck.Equals(true) ? "T" : "F", "ViewTermAgree", "Check");
        //        }
        //        else
        //        {
        //            ini.SetCheckID(string.Empty, "ViewTermAgree", "Check");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
        //    }
        //}

        #endregion

        #region Method

        public void GetArbitrageData(string OrderCode, bool bRefresh = true)
        {
            try
            {
                if (bRefresh)
                {
                    IsBusy = true;
                }

                if (string.IsNullOrEmpty(OrderCode))
                {
                    return;
                }

                _OrderCode   = OrderCode;
                arbiDataList = new ObservableCollection <ResponseArbitrageGetAssetListModel>();
                if (IsLoadData)
                {
                    IsLoadData = false;

                    //아비트리지 코인별 현재 데이터 호출
                    using (RequestArbitrageGetAssetModel req = new RequestArbitrageGetAssetModel())
                    {
                        req.userEmail = MainViewModel.LoginDataModel.userEmail;
                        req.cnKndNm   = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(_OrderCode).ToString();
                        if (bBuy)
                        {
                            req.type = "B";
                        }
                        else if (bSell)
                        {
                            req.type = "S";
                        }

                        using (ResponseArbitrageGetAssetModel res = WebApiLib.SyncCallEncrypt <ResponseArbitrageGetAssetModel, RequestArbitrageGetAssetModel>(req))
                        {
                            if (res.resultStrCode == "000")
                            {
                                dGap = res.data.gap ?? 0;

                                foreach (ResponseArbitrageGetAssetListModel item in res.data.list)
                                {
                                    item.sFavicon   = "/Images/" + item.exchgeNm + ".ico";
                                    item.sCoinImage = "/Images/ico_nav_" + item.cnKndCd + ".png";

                                    if (bSell)
                                    {
                                        if (item.totAmt == 0)
                                        {
                                            item.sTotAmt = item.totAmt.ToString() + " (X)";
                                        }
                                        else
                                        {
                                            item.sTotAmt = decimal.Parse(item.totAmt.ToString()).ToString("###,###,##0.########") + " (O)";
                                        }

                                        if (res.data.list.Count > 1)
                                        {
                                            res.data.list[1].sImage = "/Images/ico_up_arr_red.png";
                                            dPrcGap       = res.data.list[1].prcGap;
                                            vImageVisible = Visibility.Visible;
                                        }
                                        else if (res.data.list.Count.Equals(1))
                                        {
                                            vImageVisible = Visibility.Collapsed;
                                        }
                                    }
                                    else if (bBuy)
                                    {
                                        if (item.hasPtc == 0)
                                        {
                                            item.sHasPtc = item.hasPtc.ToString() + " (X)";
                                        }
                                        else
                                        {
                                            item.sHasPtc = decimal.Parse(item.hasPtc.ToString()).ToString("###,###,###,##0") + " (O)";
                                        }

                                        if (res.data.list.Count > 1)
                                        {
                                            res.data.list[1].sImage = "/Images/ico_down_arr_blue.png";
                                            dPrcGap       = res.data.list[1].prcGap;
                                            vImageVisible = Visibility.Visible;
                                        }
                                        else if (res.data.list.Count.Equals(1))
                                        {
                                            vImageVisible = Visibility.Collapsed;
                                        }
                                    }
                                }

                                arbiDataList = res.data.list;
                            }
                        }
                    }

                    arbiListHeight = 30 + (arbiDataList.Count * 30);
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
            finally
            {
                IsBusy     = false;
                IsLoadData = true;
            }
        }
Beispiel #8
0
        public void GetData()
        {
            try
            {
                //정보 호출 API
                if (sTradeInfo.Equals("B"))
                {
                    using (RequestArbitrageGetUserAssetCashModel req = new RequestArbitrageGetUserAssetCashModel())
                    {
                        req.userEmail = MainViewModel.LoginDataModel.userEmail;
                        req.regIp     = MainViewModel.LoginDataModel.regIp;
                        if (bHereTrade)
                        {
                            req.isAllYn = "N";
                        }
                        else if (bAllTrade)
                        {
                            req.isAllYn = "Y";
                        }
                        req.targetId = sLowId;
                        req.cnKndNm  = StringEnum.ToEnum <ExchangeCurrencyCode>(sOrderCode).ToString();

                        using (ResponseArbitrageGetUserAssetCashModel res = WebApiLib.SyncCallEncrypt <ResponseArbitrageGetUserAssetCashModel, RequestArbitrageGetUserAssetCashModel>(req))
                        {
                            if (res.resultStrCode == "000")
                            {
                                if (res.data.failCd.Equals(""))
                                {
                                    //if (bHereTrade)
                                    //{
                                    //    dNowAmount = (decimal)dNowAmountTemp;
                                    //}
                                    //else if (bAllTrade)
                                    //{
                                    dNowAmount = res.data.data;
                                    //}
                                    dCoinPrc  = res.data.cnPtcPrc;
                                    sExchgeNm = res.data.exchgeNm;
                                }
                            }
                        }
                    }
                }
                else if (sTradeInfo.Equals("S"))
                {
                    using (RequestArbitrageGetUserAssetCoinModel req = new RequestArbitrageGetUserAssetCoinModel())
                    {
                        req.userEmail = MainViewModel.LoginDataModel.userEmail;
                        req.regIp     = MainViewModel.LoginDataModel.regIp;
                        if (bHereTrade)
                        {
                            req.isAllYn = "N";
                        }
                        else if (bAllTrade)
                        {
                            req.isAllYn = "Y";
                        }
                        req.targetId = sLowId;
                        req.cnKndNm  = StringEnum.ToEnum <ExchangeCurrencyCode>(sOrderCode).ToString();

                        using (ResponseArbitrageGetUserAssetCoinModel res = WebApiLib.SyncCallEncrypt <ResponseArbitrageGetUserAssetCoinModel, RequestArbitrageGetUserAssetCoinModel>(req))
                        {
                            if (res.resultStrCode == "000")
                            {
                                if (res.data.failCd.Equals(""))
                                {
                                    //if (bHereTrade)
                                    //{
                                    //    dNowAmount = (decimal)dNowAmountTemp;
                                    //}
                                    //else if (bAllTrade)
                                    //{
                                    dNowAmount = res.data.data;
                                    //}
                                    dCoinPrc  = res.data.cnPtcPrc;
                                    sCnKndCd  = res.data.cnKndCd;
                                    sExchgeNm = res.data.exchgeNm;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
        public async void CmdAlarmReserve()
        {
            try
            {
                if (!autoCheck)
                {
                    alert = new Alert(Localization.Resource.Common_Alert_12, 400);
                    alert.ShowDialog();
                    return;
                }

                if (CertifyCheck() < 3)
                {
                    alert = new Alert(Localization.Resource.Common_Alert_3, Alert.ButtonType.Ok, 450);
                    alert.ShowDialog();
                    return;
                }
                if (SelCoin.Name == ChgCoin.Name)
                {
                    alert = new Alert(Localization.Resource.CoinExchangeReservationTrading_Alert_1, 350);
                    alert.ShowDialog();
                    return;
                }

                foreach (ResponseCoinListModel item in MainViewModel.CoinData.list)
                {
                    if (SelCoin.Value.Equals(StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(item.CoinCode)))
                    {
                        if (sellCoinAmt < item.TradeMinCnt)
                        {
                            alert = new Alert(string.Format(Localization.Resource.CoinTrading_Alert_8, item.TradeMinCnt));
                            alert.ShowDialog();
                            return;
                        }
                    }
                }

                if (sellCoinAmt > coinSelAmt)
                {
                    alert = new Alert(Localization.Resource.CoinExchangeReservationTrading_Alert_2, 350);
                    alert.ShowDialog();
                    return;
                }

                IsBusy = true;

                using (RequestTradingCoinAutoTradeInsModel req = new RequestTradingCoinAutoTradeInsModel())
                {
                    req.userEmail  = MainViewModel.LoginDataModel.userEmail;
                    req.selCnKndCd = StringEnum.GetStringValue(SelCoin.Value);
                    req.selCnPrc   = nowSelPrc;
                    req.selSetRate = (decimal)SelSliderValue;
                    req.selSetPrc  = coinSelPrc;
                    req.selAmt     = sellCoinAmt;
                    req.chgCnKndCd = StringEnum.GetStringValue(ChgCoin.Value);
                    req.chgCnPrc   = nowChgPrc;
                    req.chgSetRate = (decimal)ChgSliderValue;
                    req.chgSetPrc  = coinChgPrc;
                    req.chgHopeAmt = coinChgAmt;
                    req.regIp      = MainViewModel.LoginDataModel.regIp;

                    using (ResponseTradingCoinAutoTradeInsModel res = await WebApiLib.AsyncCall <ResponseTradingCoinAutoTradeInsModel, RequestTradingCoinAutoTradeInsModel>(req))
                    {
                        AlarmReserveEnabled = false;
                        AlarmCancelEnabled  = true;

                        ExeSelCoinPrc = nowSelPrc;
                        ExeSelPer     = 0;
                        ExeSelUpDown  = "-";

                        ExeChgCoinPrc = nowChgPrc;
                        ExeChgPer     = 0;
                        ExeChgUpDown  = "-";

                        State = Localization.Resource.CoinExchangeReservationTrading_1_15_1;

                        if (MainViewModel.AutoCoinData == null)
                        {
                            MainViewModel.AutoCoinData = new ResponseTradingCoinAutoTradeSelDataModel();
                        }

                        MainViewModel.AutoCoinData.selAmt     = sellCoinAmt;
                        MainViewModel.AutoCoinData.selCnKndCd = StringEnum.GetStringValue(SelCoin.Value);
                        MainViewModel.AutoCoinData.selCnPrc   = nowSelPrc;
                        MainViewModel.AutoCoinData.selSetPrc  = coinSelPrc;
                        MainViewModel.AutoCoinData.selSetRate = (decimal)SelSliderValue;
                        MainViewModel.AutoCoinData.chgCnKndCd = StringEnum.GetStringValue(ChgCoin.Value);
                        MainViewModel.AutoCoinData.chgCnPrc   = nowChgPrc;
                        MainViewModel.AutoCoinData.chgSetRate = (decimal)ChgSliderValue;
                        MainViewModel.AutoCoinData.chgSetPrc  = coinChgPrc;
                        MainViewModel.AutoCoinData.chgHopeAmt = coinChgAmt;

                        alert = new Alert(Localization.Resource.Common_Alert_2);
                        alert.ShowDialog();

                        IsBusy = false;
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public void CmdSelectSetting()
        {
            try
            {
                if (MainViewModel.AutoCoinData != null)
                {
                    AlarmReserveEnabled = false;
                    AlarmCancelEnabled  = true;

                    State = Localization.Resource.CoinExchangeReservationTrading_1_15_1;

                    //데이터 조회
                    ResponseTradingCoinAutoTradeSelDataModel SelectData = MainViewModel.AutoCoinData;

                    #region SelCoin

                    ComboBoxCoinData SelItem = SelCoinData.Where(x => x.Value == StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(SelectData.selCnKndCd)).FirstOrDefault();

                    if (SelItem != null)
                    {
                        SelCoin = SelItem;
                    }
                    else
                    {
                        SelCoin = SelCoinData[0];
                    }

                    SelSliderValue = (double)SelectData.selSetRate;
                    coinSelPrc     = (decimal)SelectData.selSetPrc;
                    sellCoinAmt    = (decimal)SelectData.selAmt;

                    ExeSelCoinPrc = (decimal)SelectData.selCnPrc;
                    ExeSelPer     = Math.Round(((nowSelPrc / ExeSelCoinPrc) - 1) * 100);
                    if (ExeSelPer > 0)
                    {
                        ExeSelUpDown = "▲";
                    }
                    else if (ExeSelPer == 0)
                    {
                        ExeSelUpDown = "-";
                    }
                    else
                    {
                        ExeSelUpDown = "▼";
                    }

                    #endregion

                    #region ChgCoin

                    ComboBoxCoinData ChgItem = ChgCoinData.Where(x => x.Value == StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(SelectData.chgCnKndCd)).FirstOrDefault();

                    if (ChgItem != null)
                    {
                        ChgCoin = ChgItem;
                    }
                    else
                    {
                        ChgCoin = ChgCoinData[0];
                    }

                    ChgSliderValue = (double)SelectData.chgSetRate;
                    coinChgPrc     = (decimal)SelectData.chgSetPrc;
                    coinChgAmt     = (decimal)SelectData.chgHopeAmt;

                    ExeChgCoinPrc = (decimal)SelectData.chgCnPrc;
                    ExeChgPer     = Math.Round(((nowChgPrc / ExeChgCoinPrc) - 1) * 100);
                    if (ExeChgPer > 0)
                    {
                        ExeChgUpDown = "▲";
                    }
                    else if (ExeChgPer == 0)
                    {
                        ExeChgUpDown = "-";
                    }
                    else
                    {
                        ExeChgUpDown = "▼";
                    }

                    StartTime = SelectData.regDt;

                    #endregion
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
Beispiel #11
0
        public void CmdSelectCoin(ResponseExchangeDashboardCoinListModel list)
        {
            try
            {
                DispatcherService.BeginInvoke(() =>
                {
                    if (list == null)
                    {
                        return;
                    }

                    if (ParentModel == null)
                    {
                        return;
                    }

                    //if (list.coinNm.Equals("VSTC"))
                    //{
                    //    Alert alert = new Alert(Localization.Resource.Common_Alert_1);
                    //    alert.ShowDialog();
                    //    return;
                    //}

                    if (tempCoinCd != list.curcyCd || HeaderName != tempPriceType)
                    {
                        tempCoinCd    = list.curcyCd;
                        tempPriceType = HeaderName;

                        if (HeaderName == list.coinNm || CoinPriceData.Any(x => x.coinNm == list.coinNm) == false)
                        {
                            SelectItem = CoinPriceData[0];
                        }
                        else
                        {
                            SelectItem = list;
                        }

                        if (HeaderVisible == Visibility.Visible)
                        {
                            img_main_coin = "/Images/img_ex_" + SelectItem.coinNm + ".png";
                            txt_Quotes    = SelectItem.coinPrc;
                            txt_Rate      = SelectItem.volume;
                            txt_Volume    = SelectItem.svcTranAmt;
                        }

                        SelectCoinCode = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(SelectItem.curcyCd);

                        if (ParentModel.Equals("ExchangeDashboardViewModel"))
                        {
                            ((ExchangeDashboardViewModel)ParentViewModel).ChangeCoin(HeaderName, HeaderCode, StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(SelectItem.curcyCd));
                        }
                        else if (ParentModel.Equals("CoinTradingViewModel"))
                        {
                            ((CoinTradingViewModel)ParentViewModel).SetCoin(HeaderName, HeaderCode, SelectItem.curcyCd);
                        }
                        else if (ParentModel.Equals("TradeHistoryTradingViewModel"))
                        {
                            ((TradeHistoryTradingViewModel)ParentViewModel).SetCoinTradeHistory(HeaderName, SelectCoinCode);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
Beispiel #12
0
        public async void GetData()
        {
            try
            {
                IsBusy = true;

                Title = Localization.Resource.CoinDayPirce_1 + "(" + StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(sCoinCode) + "/" + sPriceType + ")";

                string CommonFloat = string.Empty;

                if (sPriceType.Equals(CommonLib.StandardCurcyNm))
                {
                    ResponseCoinListModel cl = MainViewModel.CoinData.list.Where(w => w.CoinCode == sCoinCode).FirstOrDefault();
                    CommonFloat = "n" + (cl == null ? "0" : cl.CashDecimal.ToString());
                    //CommonFloat = "###,###,###,###,##0.000";
                }
                else
                {
                    CommonFloat = "###,###,###,###,##0.00000000";
                }

                using (RequestTradingGetDayPrcModel req = new RequestTradingGetDayPrcModel())
                {
                    req.cnKndCd   = sCoinCode;
                    req.stdDate   = fromDate.ToString("yyyy-MM-dd");
                    req.endDate   = toDate.ToString("yyyy-MM-dd");
                    req.mkState   = sPriceType;
                    req.pageIndex = pageIndex;

                    using (ResponseTradingGetDayPrcModel res = await WebApiLib.AsyncCall <ResponseTradingGetDayPrcModel, RequestTradingGetDayPrcModel>(req))
                    {
                        if (res.resultStrCode == "000")
                        {
                            DayPrc = new ObservableCollection <clsDayPrc>();
                            string sColor = string.Empty;
                            if (res.resultStrCode == "000")
                            {
                                DayPrc = new ObservableCollection <clsDayPrc>();
                                foreach (ResponseTradingGetDayPrcListModel item in res.data.list)
                                {
                                    if (item.prcPer > 0)
                                    {
                                        sColor = "#FF0000";
                                    }
                                    else
                                    {
                                        sColor = "#0000FF";
                                    }

                                    DayPrc.Add(ViewModelSource.Create(() => new clsDayPrc {
                                        day = item.regDt, openPrc = decimal.Parse(item.fstPrc.ToString()).ToString(CommonFloat), lowPrc = decimal.Parse(item.minPrc.ToString()).ToString(CommonFloat), highPrc = decimal.Parse(item.maxPrc.ToString()).ToString(CommonFloat), endPrc = decimal.Parse(item.lstPrc.ToString()).ToString(CommonFloat), prevContrast = item.prcPer, prevContrastColor = sColor, tradeAmount = item.totAmt
                                    }));
                                }

                                pageSize = res.data.pageSize;

                                listVisible  = Visibility.Visible;
                                emptyVisible = Visibility.Collapsed;
                            }
                            else
                            {
                                listVisible  = Visibility.Collapsed;
                                emptyVisible = Visibility.Visible;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
            finally
            {
                IsBusy = false;
            }
        }