private int GetTabItems(int i) { string rawTabData = StashService.GetStashData(m_Account, m_League, i, m_POESESSID); if (string.IsNullOrEmpty(rawTabData)) { throw new Exception($"Failed getting tab data with id {i}!"); } #if DEBUG Console.WriteLine(rawTabData); #endif dynamic tabData = JsonConvert.DeserializeObject <ExpandoObject>(rawTabData); TabInfo tabInfo = StashService.GetTabInfo(tabData, i); AddTabItems(tabData, tabInfo.Name); return((int)Math.Ceiling(i / (float)tabInfo.NumTabs * 100)); }
private void GetStashes() { BackgroundWorker bg = new BackgroundWorker(); bg.DoWork += (sender, args) => { int progress = 0; try { string rawData = StashService.GetStashData(m_Account, m_League, 0, m_POESESSID); if (string.IsNullOrEmpty(rawData)) { throw new Exception("Failed getting initial data!"); } #if DEBUG Console.WriteLine(rawData); #endif dynamic stashData = JsonConvert.DeserializeObject <ExpandoObject>(rawData); TabInfo firstTabInfo = StashService.GetTabInfo(stashData, 0); AddTabItems(stashData, firstTabInfo.Name); progress = (int)Math.Ceiling((1 / (float)firstTabInfo.NumTabs) * 100); bg.ReportProgress(progress); for (int i = 1; i < firstTabInfo.NumTabs; ++i) { progress = GetTabItems(i); bg.ReportProgress(progress); } } catch (Exception ex) { bg.ReportProgress(progress, ex); } }; bg.ProgressChanged += (sender, args) => { tsProgressBar.ProgressBar.Value = args.ProgressPercentage; m_LoadException = (Exception)args.UserState; }; bg.RunWorkerCompleted += OnRunWorkerCompleted; bg.WorkerReportsProgress = true; bg.RunWorkerAsync(); }
private void GetStash() { BackgroundWorker bg = new BackgroundWorker(); bg.DoWork += (sender, args) => { try { m_RawJson = StashService.GetStashData(m_Account, m_League, m_TabIndex, m_POESESSID); } catch (Exception ex) { bg.ReportProgress(0, ex); } }; bg.ProgressChanged += (sender, args) => { m_LoadException = (Exception)args.UserState; }; bg.RunWorkerCompleted += OnRunWorkerCompleted; bg.WorkerReportsProgress = true; bg.RunWorkerAsync(); }