Esempio n. 1
0
        private async void MakeRequest(string swap, string loot)
        {
            Cursor = Cursors.WaitCursor;

            await Task.Run(() =>
            {
                SwapBL.Start(swap);
            });

            await Task.Run(() =>
            {
                lootItems = LootItems.FromJson(GetJSONData.GetLootItems(loot));
            });

            Task.WaitAll();
            toolStripStatusLabel1.Text = "Swap.gg total item: " + SwapBL.swapItems.Result.Count;
            toolStripStatusLabel2.Text = "Loot.farm total item: " + lootItems.Count;
            await Task.Run(() =>
            {
                var s = DataSource.GetDataSource(SwapBL, lootItems);
                if (s != dataGridView1.DataSource)
                {
                    BeginInvoke(new MethodInvoker(() => dataGridView1.DataSource = s));
                }
            });

            Cursor = Cursors.Default;
        }
Esempio n. 2
0
        //Gets periodically updated
        public static void LoadLiveData()
        {
            GetJSONData <TripPosition> positionsHandler = GetTripPositions;

            GetJSONData <TripUpdateCollection> tripUpdatesHandler = GetTripUpdates;

            GetJSONData <AlertData> alertsHandler = GetAlerts;

            List <Task> TaskList = new List <Task>();

            var task1 = GetListAsync(positionsHandler);
            var task2 = GetListAsync(tripUpdatesHandler);
            var task3 = GetListAsync(alertsHandler);

            TaskList.Add(task1);
            TaskList.Add(task2);
            TaskList.Add(task3);

            Task.WaitAll(TaskList.ToArray());

            TripPositionsList = task1.Result;

            TripUpdatesList = task2.Result;

            AlertsList = task3.Result;
        }
Esempio n. 3
0
        private async void GetBalance()
        {
            await Task.Run(() =>
            {
                var sbalance = Task.Run(() => GetJSONData.MakeCookieRequest(Links.SWAP_BALANCE, cfg.GenerateCookieContainer("swap")));
                toolStripStatusLabel3.Text = $"Swap.gg balance: {SwapBalance.FromJson(sbalance.Result).Result * 0.01}";

                var lbalance = Task.Run(() => GetJSONData.MakeCookieRequest(Links.LOOT_ACCOUNT_URL, cfg.GenerateCookieContainer("loot")));
                toolStripStatusLabel4.Text = $"Loot.farm balance: {LootAccount.FromJson(lbalance.Result).Balance * 0.01}";
            });
        }
Esempio n. 4
0
        public static void LoadInitialData()
        {
            GetJSONData <ServicePeriod> servicePeriodHandler = GetServicePeriodList;

            GetJSONData <StopOnTrip> stopTimesHandler = GetStopTimes;

            GetJSONData <StationObject> stationObjectHandler = GetStations;

            GetJSONData <Trip> tripListHandler = GetTrips;

            List <Task> TaskList = new List <Task>();

            var task1 = GetListAsync(servicePeriodHandler);
            var task2 = GetListAsync(stopTimesHandler);
            var task3 = GetListAsync(stationObjectHandler);
            var task4 = GetListAsync(tripListHandler);

            TaskList.Add(task1);
            TaskList.Add(task2);
            TaskList.Add(task3);
            TaskList.Add(task4);

            Task.WaitAll(TaskList.ToArray());

            ServicePeriodList = task1.Result;

            StopList = task2.Result;

            StationsList = task3.Result;

            TripsList = task4.Result;

            /*
             * Console.WriteLine(stopwatch.ElapsedMilliseconds);
             *
             * StopList = null;
             * StationsList = null;
             * TripsList = null;
             * ServicePeriodList = null;
             *
             * Stopwatch stopwatch = Stopwatch.StartNew();
             * ServicePeriodList = GetServicePeriod();
             *
             * StopList = GetStopTimes();
             *
             * StationsList = GetStations();
             *
             * TripsList = GetTrips();
             *
             * stopwatch.Stop();
             *
             * Console.WriteLine(stopwatch.ElapsedMilliseconds); //Saving 4 - 6 seconds!
             */
        }
Esempio n. 5
0
        public TradeItBL(string link)
        {
            Responce = Task.Run(() => GetJSONData.GetXHR(link));

            res = new List <Tuple <string, long, double> >();

            var d = TradeItDota.FromJson(Responce.Result);
            var r = TradeItRust.FromJson(Responce.Result);
            var h = TradeItH1Z1.FromJson(Responce.Result);

            if (link == Links.TRADE_DOTA)
            {
                foreach (var l in d)
                {
                    foreach (var item in l.GameCode.Items)
                    {
                        res.Add(Tuple.Create(new string(item.Key.SkipWhile(m => m != '_').Skip(1).ToArray()), item.Value.X, item.Value.P * 0.01));
                    }
                }
                SaveFile.ProcessWrite(Responce.Result, "tradeit");
            }
            else if (link == Links.TRADE_RUST)
            {
                foreach (var l in r)
                {
                    foreach (var item in l.GameCode.Items)
                    {
                        res.Add(Tuple.Create(new string(item.Key.SkipWhile(m => m != '_').Skip(1).ToArray()), item.Value.X, item.Value.P * 0.01));
                    }
                }
            }
            else
            {
                foreach (var l in h)
                {
                    foreach (var item in l.GameCode.Items)
                    {
                        res.Add(Tuple.Create(new string(item.Key.SkipWhile(m => m != '_').Skip(1).ToArray()), item.Value.X, item.Value.P * 0.01));
                    }
                }
            }
        }
Esempio n. 6
0
        public void Start(string link)
        {
            var res = Task.Run(() => GetJSONData.GetXHR(link));

            swapItems = SwapItems.FromJson(res.Result);
        }
Esempio n. 7
0
        public static async Task <List <T> > GetListAsync <T>(GetJSONData <T> handler)
        {
            GetJSONData <T> lst = await Task.Run(() => handler).ConfigureAwait(false);

            return(lst.Invoke());
        }