public StashDownloadWaitWindow(PoeAccHandler pwr, string leagueName) { InitializeComponent(); this.pwr = pwr; LeagueName = leagueName; }
private void Window_Closed(object sender, EventArgs e) { pwr.StashProgressChanged -= new PoeAccHandler.StashRetrieveProgressReport(pwr_StashProgressChanged); pwr = null; }
private void bRefreshAccStash_Click(object sender, RoutedEventArgs e) { PoeAccHandler pwr = ((PoeAccHandler)((FrameworkElement)e.OriginalSource).DataContext); bool rechecked = false; repeatStashQuery: if (!pwr.LoggedIn) { if (!pwr.Login()) { AddLogEntry("Can't update stash. Unable to connect or log-in"); return; } else { AccManager.SaveAccounts(); } } string owner = pwr.UserDisplayName; string leagueName = StaticVariables.LeagueNames[(int)ActiveLeagueId]; StashDownloadWaitWindow sdww = new StashDownloadWaitWindow(pwr, leagueName); sdww.Owner = this; sdww.ShowDialog(); string[] jsonStashes = sdww.JsonStash; if (jsonStashes == null) { AddLogEntry("[" + owner + "|" + leagueName + "] Unable to connect. Aborting"); return; } if (jsonStashes.Length == 1 && !rechecked) { if (!pwr.CheckLogin()) { AddLogEntry("[" + owner + "|" + leagueName + "] Error while downloading stashes. Re-loging in to website and trying again."); rechecked = true; goto repeatStashQuery; } } if (jsonStashes.Length == 0 || jsonStashes[0] == null) { AddLogEntry("[" + owner + "|" + leagueName + "] No stashes have been found. Probably this account has no characters in [" + leagueName + "] league."); return; } var stashList = PoeStashParser.DeserializeStashes(jsonStashes, owner); if (stashList == null) { AddLogEntry("[" + owner + "|" + leagueName + "] Error while parsing json stashes. Aborting"); return; } if (stashList.Count == 0) { AddLogEntry("[" + owner + "|" + leagueName + "] No acceptable items have been found in the stash. Aborting"); return; } bool parseSuccess = ItemsManagers[(int)ActiveLeagueId].ParseStashList(stashList); if (parseSuccess && Properties.Settings.Default.SyncKey != "") //save only if changes been made { //ItemManager.ItemsByCatForListView.SortTree(); //Properties.Settings.Default.Items = Serializer<PoeItemsManager>.SerializeToString(ItemManager); //Properties.Settings.Default.Save(); //ItemManager[(int)ActiveLeagueId].Export(owner, "Export\\" + owner + "." + leagueName + ".poe"); SyncDataHelper sdh = new SyncDataHelper(); sdh.owner = owner; sdh.leagueId = (int)ActiveLeagueId; sdh.version = ItemsManagers[(int)ActiveLeagueId].OwnerItemsListUpdateTime[owner]; OwnersNeedingSync.Enqueue(sdh); } AccManager.SaveAccounts(); //save changed acc data like login if needed or last refresh. PrintItemChanges((int)ActiveLeagueId); SaveAllItemsManagers(); }