private void OnRunWorkerCompleted(object o, RunWorkerCompletedEventArgs runWorkerCompletedEventArgs) { pbLoader.Visible = false; if (string.IsNullOrEmpty(m_RawJson)) { toolStripStatusLabel.Text = "Failed getting data!" + m_LoadException.Message; return; } #if DEBUG Console.WriteLine(m_RawJson); #endif m_StashData = JsonConvert.DeserializeObject <ExpandoObject>(m_RawJson); flpItems.Controls.Clear(); flpItems.Visible = true; TabInfo tabInfo = StashService.GetTabInfo(m_StashData, m_TabIndex); Text += $" / {tabInfo.Name}"; foreach (dynamic item in m_StashData.items) { ProcessItemLine(item, tabInfo.Name); } ListItems(); }
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(); }