public Account(string steamId64, string login, string password) { this.login = login; this.password = password; this.steamId64 = steamId64; SteamParser steamParser = new SteamParser(steamId64); steamParser.parseAccInfo(); steamParser.parseVacs(); this.nickname = steamParser.getNickname(); this.steamPicture = steamParser.getSteamPicture(); this.vacCount = steamParser.getVacCount(); Dota2RankParser d2RankParser = new Dota2RankParser(steamId64); d2RankParser.parseDota2Rank(); this.d2Rank = d2RankParser.getD2Rank(); CSGORankParser cSRankParser = new CSGORankParser(steamId64); cSRankParser.parseCSGORank(); this.cSRank = cSRankParser.getCSRank(); }
private async Task editAccount(int id, string steamId64) { Config config = Config.getInstance(); if (CheckForInternetConnection()) { var task = Task.Factory.StartNew(() => { SteamLinkValidation slv = new SteamLinkValidation(_steamLink); if (slv.getSteamLinkType() == SteamLinkValidation.steamLinkTypes.errorType) { ErrorMessage = (string)Application.Current.FindResource("error_invalid_steamlink"); } else if (SteamLogin == "" || SteamLogin.Contains(" ")) { if (SteamLogin == "") { ErrorMessage = (string)Application.Current.FindResource("error_empty_login"); } else { ErrorMessage = (string)Application.Current.FindResource("error_invalid_login"); } } else if (SteamPassword == "") { ErrorMessage = (string)Application.Current.FindResource("error_empty_password"); } else { if (SteamLink != "https://steamcommunity.com/profiles/" + steamId64 + "/") { MainViewModel.AddOrEditAccountGridVisible = true; MainViewModel.AddOrEditAccountTitle = (string)Application.Current.FindResource("mw_account_editing"); config.accounts.RemoveAt(id); string steamNickname, steamPicture; int vacCount; D2Rank d2Rank; CSRank cSRank; SteamParser steamParser = new SteamParser(slv.getSteamId64()); MainViewModel.AddOrEditAccountProgress = (string)Application.Current.FindResource("mw_account_steam_data"); steamParser.parseAccInfo(); steamParser.parseVacs(); steamNickname = steamParser.getNickname(); steamPicture = steamParser.getSteamPicture(); vacCount = steamParser.getVacCount(); Dota2RankParser d2RankParser = new Dota2RankParser(slv.getSteamId64()); MainViewModel.AddOrEditAccountProgress = (string)Application.Current.FindResource("mw_account_dota2_data"); d2RankParser.parseDota2Rank(); d2Rank = d2RankParser.getD2Rank(); CSGORankParser cSRankParser = new CSGORankParser(slv.getSteamId64()); MainViewModel.AddOrEditAccountProgress = (string)Application.Current.FindResource("mw_account_csgo_data"); cSRankParser.parseCSGORank(); cSRank = cSRankParser.getCSRank(); config.accounts.Insert(id, new Model.Account(slv.getSteamId64(), SteamLogin, SteamPassword, steamNickname, steamPicture, vacCount, d2Rank, cSRank)); MainViewModel.AddOrEditAccountGridVisible = false; MainViewModel.AddOrEditAccountTitle = ""; MainViewModel.AddOrEditAccountProgress = ""; } else { config.accounts[id].login = SteamLogin; config.accounts[id].password = SteamPassword; } config.saveChanges(); MainViewModel.AccountsViewCommand.Execute(null); } }); await task; } else { if (SteamLink == "https://steamcommunity.com/profiles/" + steamId64 + "/") { config.accounts[id].login = SteamLogin; config.accounts[id].password = SteamPassword; config.saveChanges(); MainViewModel.AccountsViewCommand.Execute(null); } else { CustomMessageBox.show((string)Application.Current.FindResource("mb_no_internet_connection")); } } }
private async Task addAccount(object o) { var task = Task.Factory.StartNew(() => { if (CheckForInternetConnection()) { SteamLinkValidation slv = new SteamLinkValidation(_steamLink); if (slv.getSteamLinkType() == SteamLinkValidation.steamLinkTypes.errorType) { ErrorMessage = (string)Application.Current.FindResource( "error_invalid_steamlink"); //"Некорректная ссылка на аккаунт стим."; } else if (SteamLogin == "" || SteamLogin.Contains(" ")) { if (SteamLogin == "") { ErrorMessage = (string)Application.Current.FindResource( "error_empty_login"); //"Поле с логином пустое."; } else { ErrorMessage = (string)Application.Current.FindResource( "error_invalid_login"); //"Некорректное поле с логином."; } } else if (SteamPassword == "") { ErrorMessage = (string)Application.Current.FindResource( "error_empty_password"); //"Поле с паролем пустое."; } else { MainViewModel.AddOrEditAccountGridVisible = true; MainViewModel.AddOrEditAccountTitle = (string)Application.Current.FindResource("mw_account_adding"); Config config = Config.getInstance(); string steamNickname, steamPicture; int vacCount; D2Rank d2Rank; CSRank cSRank; SteamParser steamParser = new SteamParser(slv.getSteamId64()); MainViewModel.AddOrEditAccountProgress = (string)Application.Current.FindResource("mw_account_steam_data"); steamParser.parseAccInfo(); steamParser.parseVacs(); steamNickname = steamParser.getNickname(); steamPicture = steamParser.getSteamPicture(); vacCount = steamParser.getVacCount(); Dota2RankParser d2RankParser = new Dota2RankParser(slv.getSteamId64()); MainViewModel.AddOrEditAccountProgress = (string)Application.Current.FindResource("mw_account_dota2_data"); d2RankParser.parseDota2Rank(); d2Rank = d2RankParser.getD2Rank(); CSGORankParser cSRankParser = new CSGORankParser(slv.getSteamId64()); MainViewModel.AddOrEditAccountProgress = (string)Application.Current.FindResource("mw_account_csgo_data"); cSRankParser.parseCSGORank(); cSRank = cSRankParser.getCSRank(); config.accounts.Add(new Model.Account(slv.getSteamId64(), SteamLogin, SteamPassword, steamNickname, steamPicture, vacCount, d2Rank, cSRank)); config.saveChanges(); MainViewModel.AccountsViewCommand.Execute(null); MainViewModel.AddOrEditAccountGridVisible = false; MainViewModel.AddOrEditAccountTitle = ""; MainViewModel.AddOrEditAccountProgress = ""; } } else { CustomMessageBox.show((string)Application.Current.FindResource("mb_no_internet_connection")); } }); await task; }