/// <summary> /// Executes this command. /// </summary> /// <param name="parameter">The parameter.</param> public override void Execute(object parameter, object target) { StaffListType type; using (var form = new FormStaffLists()) { if (form.ShowDialog() != DialogResult.OK) { return; } type = form.ListType; } _view.ShowStatus("Начинае очищать список"); var controller = _sourceController.Controller; new async(() => controller.ClearStaffList(type, ShowStatus)); }
/// <summary> /// Executes this command. /// </summary> /// <param name="parameter">The parameter.</param> public override void Execute(object parameter, object target) { viewer.Clear(); IRange <int> levelRange; IRange <int> pageRange; TopSearchSort sort; int minSkillDif; Race race; bool import; using (var filter = new SearchUserFilter()) { if (filter.ShowDialog(SearchUserFilter.DisplayMode.TopSearch) != DialogResult.OK) { return; } levelRange = filter.LevelRange; pageRange = filter.PageRange; minSkillDif = filter.SkillDifference; race = filter.Race; sort = (TopSearchSort)filter.SecondValue; import = filter.Import; } var controller = source.Controller; new async(delegate { viewer.Display("Начали искать топ " + sort.GetDescription()); var links = controller.GetTopUsersLinks(sort, race, pageRange); var counter = 0; var count = links.Count; viewer.Display("Всего в поиске " + count); foreach (var link in links) { try { var user = controller.GetUserByUrl(link); counter++; viewer.ShowStatus(counter + "/" + count); if (user == null) { continue; } if (user.Race != race) { continue; } if (levelRange != null && !levelRange.IsInRange(user.Level)) { continue; } if (player.GetSkillDifference(user) < minSkillDif) { continue; } // user.Guild = guildType; user.UserType = UserType.Cow; viewer.Display(user); if (import) { ImportUser(user); } } catch (Exception ex) { AppCore.LogSystem.Warn("Ошибка чтения игрока", link); } } if (pageRange == null) { viewer.ShowStatus("Поиск окончен"); } else { viewer.ShowStatus("Поиск окончен на странице " + pageRange.To); } } ); }
/// <summary> /// Executes this command. /// </summary> /// <param name="parameter">The parameter.</param> public override void Execute(object parameter, object target) { viewer.Clear(); IRange <int> levelRange; IRange <int> pageRange; GuildType guildType; Race race; bool import; using (var filter = new SearchUserFilter()) { if (filter.ShowDialog(SearchUserFilter.DisplayMode.Guild) != DialogResult.OK) { return; } levelRange = filter.LevelRange; pageRange = filter.PageRange; guildType = (GuildType)filter.SecondValue; race = filter.Race; import = filter.Import; } var controller = source.Controller; new async(delegate { viewer.Display(string.Format("Начали искать {0} в гильдии {1}", race.GetDescription(), guildType.GetDescription())); var links = controller.GetUsersLinksFromGuild(guildType, pageRange); var counter = 0; var count = links.Count; viewer.Display("Всего в поиске " + count); foreach (var link in links) { var user = controller.GetUserByUrl(link); counter++; viewer.ShowStatus(counter + "/" + count); if (user == null) { continue; } if (user.Race != race) { continue; } if (levelRange != null && !levelRange.IsInRange(user.Level)) { continue; } user.Guild = guildType; user.UserType = UserType.Cow; viewer.Display(user); if (import) { ImportUser(user); } } if (pageRange == null) { viewer.ShowStatus("Поиск окончен"); } else { viewer.ShowStatus("Поиск окончен на странице " + pageRange.To); } } ); }