コード例 #1
0
        public async Task <bool> ShouldGoToLogin()
        {
            if (!initialized)
            {
                throw new ArgumentException("You must call Initialize first");
            }

            var settingsRepo = Locator.Current.GetService <ISettingsRepository>();
            var currentUser  = settingsRepo.GetUserLogin();

            if (currentUser != null)
            {
                // Have to revalidate the login
                if (currentUser.UpdatedAt.AddHours(2).Ticks < DateTime.Now.Ticks)
                {
                    string email    = currentUser.Email;
                    string password = currentUser.Password;
                    await settingsRepo.InvalidateUserLogin(currentUser);

                    var login = await ApiCoordinator.Login(email, password);

                    await settingsRepo.SaveOrUpdateUserLogin(login);
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #2
0
        private OhlcData GetRangeInternal(TimeRange timeRange)
        {
            if (Ctx.PrimaryApiProvider == null)
            {
                return(null);
            }

            if (Ctx.CurrencyConversionApiProvider != null)
            {
                var cr = Convert(timeRange);
                Ctx.Status(cr == null ? "Data missing" : "Received data");
                return(cr);
            }

            Ctx.Status("Requesting @" + Ctx.PrimaryApiProvider.Title);
            var r = ApiCoordinator.GetOhlc(Ctx.PrimaryApiProvider, new OhlcContext(Ctx.Pair, Ctx.TimeResolution, timeRange, L));

            if (r.IsNull)
            {
                Ctx.Status("Data missing");
                return(null);
            }

            r.Response.ForEach(x => x.CollectedNearLive = x.DateTimeUtc.IsLive(Ctx.TimeResolution));
            Ctx.Status("Received data");
            return(r.Response);
        }
コード例 #3
0
        public void TestCompareAggregatorDataWithAssetPairData()
        {
            var pub = PublicContext.I.PubData;
            var d   = new Dictionary <Network, AssetPairs>();

            foreach (var prov in Networks.I.AssetPairsProviders)
            {
                var r = ApiCoordinator.GetAssetPairs(prov);
                if (r.IsFailed)
                {
                    Assert.Fail(prov.Title + " could not perform " + nameof(ApiCoordinator.GetAssetPairs));
                }

                d.Add(prov.Network, r.Response);
            }

            var pairs = d.SelectMany(x => x.Value).ToUniqueList();

            foreach (var pair in pairs)
            {
                var apd     = pub.GetAggAssetPairData(pair);
                var aggNets = apd.Exchanges.Select(x => x.Network).ToUniqueList();
                var apNets  = d.Where(x => x.Value.Contains(pair)).Select(x => x.Key).ToUniqueList();

                foreach (var n in apNets)
                {
                    if (aggNets.Contains(n))
                    {
                        continue;
                    }
                    Assert.Fail($"Aggregated data for {pair} does not contain network: {n.Name}");
                }
            }
        }
コード例 #4
0
        private async void RefreshingMethod(object sender, EventArgs e)
        {
            MessageList.IsRefreshing = true;
            var filteredItems = await ApiCoordinator.GetPrivateMessages(ViewModel.Chat.Id);

            ViewModel.MessageList.Clear();
            ViewModel.MessageList.AddRange(filteredItems.Items);
            MessageList.IsRefreshing = false;
        }
コード例 #5
0
        private void CheckKeys()
        {
            StatusText = "Checking the keys now...";

            var apikey = new ApiKey(Service.Network, _apiName, _apiKey, _apiSecret, _apiExtra1);
            var t      = ApiCoordinator.TestApiAsync(Service, new ApiPrivateTestContext(apikey));

            t.ContinueWith(task => ApiKeyCheckResult(task, apikey));
        }
コード例 #6
0
        private async Task HandleCreateGroup(IList <UserContact> users)
        {
            //Validate group name
            if (string.IsNullOrWhiteSpace(GroupName))
            {
                return;
            }
            var newDialog = await ApiCoordinator.CreateMessageGroup(GroupName, users);

            //Save in the future
            OnGoToDialogScreen(newDialog);
        }
コード例 #7
0
    IEnumerator RunInference()
    {
        float currDeltaTime = 0;

        while (runInference)
        {
            currDeltaTime += Time.deltaTime;
            if (currDeltaTime > targetDeltaTime)
            {
                currDeltaTime = 0;
                ApiCoordinator.Predict(CameraCapture.CaptureScreenshot());
            }
            yield return(null);
        }
    }
コード例 #8
0
        private void PullWallet()
        {
            var wac = new WalletAddressAssetContext(Asset.Btc, UserContext.Current);

            foreach (var network in Networks.I.DepositProviders)
            {
                var r = ApiCoordinator.GetDepositAddresses(network, wac);
                if (r.IsNull)
                {
                    continue;
                }

                foreach (var i in r.Response)
                {
                    Addresses.Add(i);
                }
            }
        }
コード例 #9
0
        private async Task <Page <UserContact> > GetAllFromWeb()
        {
            try {
                var results = await ApiCoordinator.GetAllContacts();

                var realm = Realm.GetInstance();
                realm.Write(() => {
                    foreach (var item in results.Items)
                    {
                        var result = realm.Add <UserContact>(item, true);
                    }
                });
                System.Diagnostics.Debug.WriteLine("WORKED");
                return(results);
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            return(Page <UserContact> .Empty);
        }
コード例 #10
0
ファイル: WalletProvider.cs プロジェクト: treverson/prime
        public async Task <IReadOnlyList <WalletAddress> > GenerateNewAddressAsync(Network network, Asset asset)
        {
            var service = network.GetProviders <IDepositProvider>().Where(x => x.CanGenerateDepositAddress).FirstProvider();

            if (service == null)
            {
                return(null);
            }

            var r = await ApiCoordinator.GetDepositAddressesAsync(service, new WalletAddressAssetContext(asset, _context)).ConfigureAwait(false);

            if (r.IsNull)
            {
                return(null);
            }

            var ads = r.Response.WalletAddresses;
            var usr = Addresses;

            foreach (var a in usr)
            {
                if (ads.Contains(a))
                {
                    ads.Remove(a);
                }
            }

            if (!ads.Any())
            {
                return(null);
            }

            usr.AddRange(ads);
            _context.Finance().UserSettings.Save(_context);

            return(ads);
        }
コード例 #11
0
        public void Update()
        {
            IsQuerying = true;
            UpdateInfo();

            var r = new List <PortfolioLineItem>();

            try
            {
                BalanceResults results = null;
                try
                {
                    var ar = ApiCoordinator.GetBalances(Provider, _providerContext);
                    IsConnected = ar.Success;

                    if (!IsConnected)
                    {
                        L.Error(ar.FailReason ?? "Failed", $"in {nameof(Update)} @ {nameof(Provider.GetBalancesAsync)}");
                    }
                    else
                    {
                        results = ar.Response;
                    }

                    UpdateInfo();
                }
                catch (Exception e)
                {
                    L.Error(e, $"in {nameof(Update)} @ {nameof(Provider.GetBalancesAsync)}");
                    IsConnected = false;
                    UpdateInfo();
                }

                if (results == null)
                {
                    IsQuerying = false;
                    IsFailing  = true;
                    UpdateInfo();
                    return;
                }

                foreach (var br in results)
                {
                    var li = CreateLineItem(br, Provider);
                    if (li?.Asset == null)
                    {
                        continue;
                    }

                    r.Add(li);
                    Update(r, false, li);
                }

                IsFailing  = false;
                IsQuerying = false;
            }
            catch (Exception e)
            {
                L.Error(e, $"in {nameof(Update)}");
                IsFailing  = true;
                IsQuerying = false;
            }

            Update(r, true);

            SetTimer(_timerFrequency);
        }
コード例 #12
0
        private OhlcData Convert(TimeRange range)
        {
            Ctx.Status("Converting @" + Ctx.PrimaryApiProvider.Title + " " + Ctx.CurrencyConversionApiProvider.Title + " [1]");

            var pc = new OhlcContext(new AssetPair(Ctx.Pair.Asset1, Ctx.AssetIntermediary), Ctx.TimeResolution, range, L);
            var r1 = ApiCoordinator.GetOhlc(Ctx.PrimaryApiProvider, pc);

            if (r1.IsNull)
            {
                return(null);
            }

            var d1 = r1.Response;

            Ctx.Status("Converting @" + Ctx.PrimaryApiProvider.Title + " " + Ctx.CurrencyConversionApiProvider.Title + " [2]");

            var pc2 = new OhlcContext(new AssetPair(Ctx.AssetIntermediary, Ctx.Pair.Asset2), Ctx.TimeResolution, range, L);

            var r2 = ApiCoordinator.GetOhlc(Ctx.CurrencyConversionApiProvider, pc2);

            if (r2.IsNull)
            {
                return(null);
            }

            var d2 = r2.Response;

            if (d1.IsEmpty() || d2.IsEmpty())
            {
                return(null);
            }

            if (d1.Count != d2.Count)
            {
                return(null);
            }

            var ohcldata = new OhlcData(_adapter.TimeResolution)
            {
                ConvertedFrom = Ctx.AssetIntermediary,
                Network       = Ctx.PrimaryApiProvider.Network
            };

            var seriesid = OhlcUtilities.GetHash(Ctx.Pair, range.TimeResolution, ohcldata.Network);

            foreach (var i in d1)
            {
                var i2 = d2.FirstOrDefault(x => x.DateTimeUtc == i.DateTimeUtc);
                if (i2 == null)
                {
                    return(null);
                }

                ohcldata.Add(new OhlcEntry(seriesid, i.DateTimeUtc, Ctx.PrimaryApiProvider, Ctx.CurrencyConversionApiProvider, Ctx.AssetIntermediary)
                {
                    Open            = i.Open * i2.Open,
                    Close           = i.Close * i2.Close,
                    High            = i.High * i2.High,
                    Low             = i.Low * i2.Low,
                    VolumeTo        = 0,
                    VolumeFrom      = i2.VolumeFrom,
                    WeightedAverage = 0
                });
            }

            return(ohcldata);
        }
コード例 #13
0
 void OnMaskChanged(GameMessage msg)
 {
     ApiCoordinator.SetLabelColors();
 }
コード例 #14
0
 public Task <IList <string> > GetSuggestionList(string userId)
 {
     return(ApiCoordinator.GetSuggestionList(userId));
 }