コード例 #1
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Currencies.Clear();
                var items = await repository.GetItemsAsync(1);

                foreach (var item in items)
                {
                    Currencies.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #2
0
ファイル: AdminView.cs プロジェクト: DanilaRozanov/Exchange1
 public void UpdateCurrencies(List <Currency> currencies)
 {
     Currencies.Clear();
     currencies.ForEach(currency => { Currencies.Add(currency); });
     currenciesGrid.Update();
     currenciesGrid.Refresh();
 }
コード例 #3
0
        private void retrieveSymbolLists()
        {
            var r = _influxDb.QueryMultipleSeriesAsync("SHOW SERIES");

            r.Wait();
            Currencies = r.Result.Select(v => (string)v[0][0]).ToList();
            Currencies.Add("USD");
            CurrencyPairs = new List <CurrencyPair>();

            for (var i = 0; i < Currencies.Count; ++i)
            {
                for (var j = 0; j < Currencies.Count; ++j)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    var cp = new CurrencyPair
                    {
                        Currency           = Currencies[i],
                        CurrencyRelativeTo = Currencies[j]
                    };
                    CurrencyPairs.Add(cp);
                }
            }
        }
コード例 #4
0
ファイル: CurrenciesLut.cs プロジェクト: bg0jr/RaynMaker
        public void Reload()
        {
            myMaxCurrencyTranslationsAgeInDays = -1;
            Currencies.Clear();

            var ctx = myProjectHost.Project.GetAssetsContext();

            if (!ctx.Currencies.Any())
            {
                ctx.Currencies.Add(new Currency {
                    Symbol = "EUR", Name = "Euro"
                });
                ctx.Currencies.Add(new Currency {
                    Symbol = "USD", Name = "U.S. Dollar"
                });

                ctx.SaveChanges();
            }

            // first load all currencies so that when loading the translations all currencies are loaded and so a translation
            // can be initialized completely before setting IsMaterialized = true.
            // without that we face the problem that IsMaterialized = true is set BEFORE the Target is set. This causes
            // unwanted Timestamp updates
            ctx.Currencies.Load();

            foreach (var currency in ctx.Currencies.Include(c => c.Translations))
            {
                Currencies.Add(currency);
            }
        }
コード例 #5
0
        public override bool UpdateCurrencies() {
            string address = "https://bittrex.com/api/v1.1/public/getcurrencies";
            byte[] bytes = null;
            try {
                bytes = GetDownloadBytes(address);
            }
            catch(Exception) {
                return false;
            }
            if(bytes == null)
                return false;

            int startIndex = 1;
            if(!JSonHelper.Default.SkipSymbol(bytes, ':', 3, ref startIndex))
                return false;

            List<string[]> res = JSonHelper.Default.DeserializeArrayOfObjects(bytes, ref startIndex, new string[] { "Currency", "CurrencyLong", "MinConfirmation", "TxFee", "IsActive", "CoinType", "BaseAddress", "Notice" });
            for(int i = 0; i < res.Count; i++) {
                string[] item = res[i];
                string currency = item[0];
                BitFinexCurrencyInfo c = (BitFinexCurrencyInfo)Currencies.FirstOrDefault(curr => curr.Currency == currency);
                if(c == null) {
                    c = new BitFinexCurrencyInfo();
                    c.Currency = item[0];
                    c.CurrencyLong = item[1];
                    c.MinConfirmation = int.Parse(item[2]);
                    c.TxFee = FastValueConverter.Convert(item[3]);
                    c.CoinType = item[5];
                    c.BaseAddress = item[6];
                    Currencies.Add(c);
                }
                c.IsActive = item[4].Length == 4;
            }
            return true;
        }
コード例 #6
0
        public async void getCurrencies()
        {
            var curr = await AutocompleteAPI.GetAllCurrencyAsync();

            foreach (var c in curr)
            {
                Currencies.Add(c.Key);
                FullCurrency.Add(c.Key + " - " + c.Value);
            }
        }
コード例 #7
0
        internal void sortCurrencies()
        {
            List <Currency> tmp = Currencies.OrderBy(Currency => Currency.State).ToList();

            Currencies.Clear();
            for (int i = tmp.Count - 1; i >= 0; i--)
            {
                Currencies.Add(tmp[i]);
            }
        }
コード例 #8
0
 private void addCurrencies()
 {
     foreach (CurrencyTypeEnum currency in Enum.GetValues(typeof(CurrencyTypeEnum)))
     {
         Currencies.Add(new SelectListItem()
         {
             Text  = currency.ToString(),
             Value = ((int)currency).ToString()
         });
     }
 }
コード例 #9
0
 private void loadCurrenciesToList(DataTable table)
 {
     foreach (DataRow row in table.Rows)
     {
         if (!Currencies.Any(Currency => Currency.Name == row["kód"].ToString()) &&
             MonitoredCurrencies.Contains(row["kód"].ToString()))
         {
             Currencies.Add(new Currency(row["kód"].ToString(), row["země"].ToString()));
         }
     }
 }
コード例 #10
0
        /// <summary>
        /// Load DBt
        /// </summary>
        public void LoadCurrencyModel()
        {
            const string sqlCmd = "select * from dbo.currency";

            try
            {
                if (App.m_DB.GetDB().State == System.Data.ConnectionState.Open)
                {
                    using (SqlCommand cmd = new SqlCommand(sqlCmd, App.m_DB.GetDB()))
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Currency curreny = new Currency();
                                if (!reader.IsDBNull(1))
                                {
                                    curreny.Active_Check = reader.GetInt32(1);
                                }
                                if (!reader.IsDBNull(2))
                                {
                                    curreny.Name = reader.GetString(2);
                                }
                                if (!reader.IsDBNull(3))
                                {
                                    curreny.Code = reader.GetString(3);
                                }
                                if (!reader.IsDBNull(4))
                                {
                                    curreny.Symbol = reader.GetString(4);
                                }
                                if (!reader.IsDBNull(5))
                                {
                                    curreny.DateUpdate = reader.GetString(5);
                                }
                                if (!reader.IsDBNull(6))
                                {
                                    curreny.Exchange = reader.GetString(6);
                                }

                                Currencies.Add(new CurrencyViewModel(curreny));
                            }
                        }
                    }
                }
                return;
            }
            catch (Exception eSql)
            {
                Debug.WriteLine("Exception: " + eSql.Message);
            }
            return;
        }
コード例 #11
0
ファイル: CustomApplication.cs プロジェクト: Leoltron/PayDebt
        public override void OnCreate()
        {
            base.OnCreate();

            Currencies.Add(new Currency("USD", CultureInfo.GetCultureInfoByIetfLanguageTag("en-US")));
            Currencies.Add(new Currency("EUR", CultureInfo.GetCultureInfoByIetfLanguageTag("fr-FR")));
            Currencies.Add(new Currency("RUB", CultureInfo.GetCultureInfoByIetfLanguageTag("ru-RU")));
            ContactPickers.Add(new VkContactPicker(new VkContactProvider(), GetString(Resource.String.vk),
                                                   0, typeof(VkFriendPickerActivity)));
            ContactPickers.Add(new PhoneContactPicker(new PhoneContactProvider(), GetString(Resource.String.contacts),
                                                      1, typeof(PhoneFriendPickerActivity)));
            VKSdk.Initialize(this);
        }
コード例 #12
0
 public void LoadCurrencies(List <CurrencyData> list)
 {
     if (list is null)
     {
         return;
     }
     foreach (var c in list)
     {
         if (Currencies.Contains(c.ID))
         {
             continue;
         }
         Currencies.Add(c.ID);
     }
 }
コード例 #13
0
        private async void AddNewCurrency()
        {
            IsBusy = true;
            if (_context.Currencies.FirstOrDefault(x => x.Name.Equals(
                                                       NewCurrencyName, StringComparison.CurrentCultureIgnoreCase)) == null)
            {
                if (string.IsNullOrEmpty(NewCurrencyName))
                {
                    IsBusy = false;
                    return;
                }
                var rest          = new YahooXChangeRest();
                var foundCurrency = await rest.CheckIfCurrencyExistsAsync(NewCurrencyName, BaseCurrency.Name);

                if (foundCurrency == null)
                {
                    new ModernDialog
                    {
                        Title   = "Error",
                        Content = "No currency with symbol: " + NewCurrencyName.ToUpper()
                    }.Show();

                    NewCurrencyName = String.Empty;
                    IsBusy          = false;
                    return;
                }

                var res = foundCurrency.MapToEntity();
                _context.Currencies.Add(res);
                await _context.SaveChangesAsync();

                // adding to an observable collections
                Messenger.Default.Send(res, "newCurrencyMsg");
                Currencies.Add(res);
            }
            else
            {
                new ModernDialog
                {
                    Title   = "Error",
                    Content = "Following currency already exists: " + NewCurrencyName.ToUpper()
                }.Show();
            }

            NewCurrencyName = String.Empty;
            IsBusy          = false;
        }
コード例 #14
0
        private async Task LoadDataAsync()
        {
            await LoadModelAsync();

            foreach (var model in Converter.CurrencyModels)
            {
                Currencies.Add(new CurrencyViewModel()
                {
                    Code = model.Code, Name = model.Name, FlagUri = model.FlagUri
                });
            }
            foreach (var item in Currencies)
            {
                FilteredCurrencies.Add(item);
            }

            OnPropertyChanged(nameof(FilteredCurrencies));
        }
コード例 #15
0
        public async Task GetPickerValues()
        {
            var countriesList = await CountryDataStore.GetItemsAsync();

            foreach (Country c in countriesList)
            {
                Countries.Add(c);
            }

            SelectedCountry = Countries.First(x => x.Id == Model.Country.Id);


            var citiesList = await CityDataStore.GetItemsAsync();

            foreach (var item in citiesList)
            {
                Cities.Add(item);
            }

            SelectedCity = Cities.First(x => x.Id == Model.City.Id);


            var seasonsList = await SeasonDataStore.GetItemsAsync();

            foreach (var item in seasonsList)
            {
                Seasons.Add(item);
            }

            SelectedSeason = Seasons.First(x => x.Id == Model.Season.Id);


            var currenciesList = await CurrencyDataStore.GetItemsAsync();

            foreach (var item in currenciesList)
            {
                Currencies.Add(item);
            }

            SelectedCurrency = Currencies.First(x => x.Id == Model.Currency.Id);

            IsBusy = false;
        }
コード例 #16
0
ファイル: EntityUser.cs プロジェクト: Soverclysm/Exurb1aBot
        public void AddAmount(CurrencyEnum cur, double amount)
        {
            var curr = Currencies?.FirstOrDefault(c => c.Currency == cur);

            if (curr == null)
            {
                if (Currencies == null)
                {
                    Currencies = new List <CurrencyUser>();
                }

                curr = new CurrencyUser(this, amount, cur);
                Currencies.Add(curr);
            }
            else
            {
                curr.Amount = curr.Amount += amount;
            }
        }
コード例 #17
0
        private void AddInitDefaultValues()
        {
            var initialCurrencies = new List <Currency>()
            {
                new("USD", "dolar amerykański"),
                new("EUR", "euro"),
                new("CHF", "frank szwajcarski"),
                new("GBP", "funt szterling"),
                new("JPY", "jen"),
                new("HUF", "forint"),
                new("CZK", "korona czeska"),
            };

            foreach (var initialCurrency in initialCurrencies
                     .Where(initialCurrency => !Currencies.Select(c => c.Code)
                            .Contains(initialCurrency.Code)))
            {
                Currencies.Add(initialCurrency);
            }
            SaveChanges();
        }
コード例 #18
0
        public ViewMonetaryMarketViewModel()
        {
            Info = new MonetaryInfoViewModel();

            foreach (var currency in Persistent.Currencies.GetAll())
            {
                Currencies.Add(new SelectListItem()
                {
                    Value = currency.ID.ToString(),
                    Text  = currency.Symbol
                });
            }

            foreach (MonetaryOfferTypeEnum offerType in Enum.GetValues(typeof(MonetaryOfferTypeEnum)))
            {
                OfferTypes.Add(new SelectListItem()
                {
                    Text  = offerType.ToString(),
                    Value = ((int)offerType).ToString()
                });
            }
        }
コード例 #19
0
        /// <summary>
        /// Вызывается когда форма загружена
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                // Забираем текущие курсы валют
                Currencies = _converter.GetCurrenciesAsync("https://www.cbr-xml-daily.ru/daily_json.js").Result;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                label1.Text = "Сервер не отвечает";
                return;
            }

            // Добавляем рубль
            Currencies.Add(new Currency {
                Name = "Российский рубль", Value = 1, Nominal = 1, CharCode = "RUB"
            });

            // Создаем 2 доп. массива с валютами а затем привязываем их к комбо боксам
            _currencies1.AddRange(Currencies);
            _currencies2.AddRange(Currencies);

            _bindingSource1.DataSource = _currencies1;
            _bindingSource2.DataSource = _currencies2;

            comboBox1.DataSource = _bindingSource1.DataSource;
            comboBox2.DataSource = _bindingSource2.DataSource;

            //Выбираем что будет отображатся в комбо боксе ( в нашем случае символьные коды валют )
            comboBox1.DisplayMember = "CharCode";
            comboBox1.ValueMember   = "CharCode";

            comboBox2.DisplayMember = "CharCode";
            comboBox2.ValueMember   = "CharCode";

            SelectedCurrency1 = GetCurrency(comboBox1.Text);
            SelectedCurrency2 = GetCurrency(comboBox2.Text);
        }
コード例 #20
0
        private async void Initialize()
        {
            HttpClient         client  = new HttpClient();
            HttpRequestMessage request = new HttpRequestMessage();

            request.RequestUri = new Uri("https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json");
            request.Method     = HttpMethod.Get;
            request.Headers.Add("Accept", "application/json");
            HttpResponseMessage response = await client.SendAsync(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                HttpContent responseContent  = response.Content;
                var         deserializedJson = JsonConvert.DeserializeObject <List <Currency> >(responseContent.ReadAsStringAsync().Result);
                new List <string>(deserializedJson.Select(i => i.cc)).ForEach(Currencies.Add);
                Currencies.Add("UAH");
                LeftCurrency  = Currencies.FirstOrDefault(i => i == "USD");
                RightCurrency = Currencies.FirstOrDefault(i => i == "UAH");
            }

            SelectedDate = DateTime.Now;
        }
コード例 #21
0
        //Add special "currency" options
        private static void AppendCurrencies()
        {
            PoECurrencyData extra = new PoECurrencyData()
            {
                key = "RemoveCraftedMods", name = "Remove Crafted Mods", tooltip = "Remove Crafted Mods"
            };
            string extrapath = "Icons/currency/RemoveCraftedMods.png";
            Uri    extrauri  = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, extrapath));

            try
            {
                BitmapImage extraimg = new BitmapImage(extrauri);
                extra.icon = extraimg;
            }
            catch (Exception)
            {
                Debug.WriteLine("Can't find image " + extrauri);
                extra.icon = null;
            }
            Currencies.Add("RemoveCraftedMods", extra);
            extra = new PoECurrencyData()
            {
                key = "DoNothing", name = "Do Nothing", tooltip = "Skip to Post-Craft Actions"
            };
            extrapath = "Icons/currency/DoNothing.png";
            extrauri  = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, extrapath));
            try
            {
                BitmapImage extraimg = new BitmapImage(extrauri);
                extra.icon = extraimg;
            }
            catch (Exception)
            {
                Debug.WriteLine("Can't find image " + extrauri);
                extra.icon = null;
            }
            Currencies.Add("DoNothing", extra);
        }
コード例 #22
0
ファイル: LoginModel.cs プロジェクト: Pyggy-Bank-Team/uwp
        public async Task UpdateCurrencies(CancellationToken token)
        {
            var response = await _service.GetAvailableCurrencies(token);

            if (response != null)
            {
                foreach (var currency in response)
                {
                    Currencies.Add(new Currency {
                        Code = currency.Code, Symbol = currency.Symbol
                    });
                }
            }
            //If we can't get available currencies from services then we set user's currency
            else
            {
                Currencies.Add(new Currency {
                    Symbol = NumberFormatInfo.CurrentInfo.CurrencySymbol, Code = RegionInfo.CurrentRegion.ISOCurrencySymbol
                });
            }

            Currency = Currencies.First();
        }
コード例 #23
0
 private void OnCurrencyAdded(CurrencyAddedMessage message)
 {
     Currencies.Add(new CurrencyViewModel(message.Currency, _currencyManager, _messenger));
     _persistencyManager.AddSelectedCurrency(message.Currency);
 }
コード例 #24
0
 public HistoryViewModel()
 {
     _initializingTask = LoadCurrencies();
     Messenger.Default.Register <CurrencyEF>(this, "newCurrencyMsg", x => Currencies.Add(x.ToLink()));
 }