void SetupAutoComplete() { try { try { engineList = EngineDownload.GetEngineList(); modList = downloader.PackageDownloader.Repositories.SelectMany(x => x.VersionsByTag.Keys).ToList(); } catch (Exception ex) { Trace.TraceError(ex.ToString()); InvokeIfNeeded(() => { MessageBox.Show("Failed to get list: {0}", ex.Message); Close(); }); return; } InvokeIfNeeded(() => { tbEngine.AutoCompleteCustomSource.AddRange(engineList.ToArray()); tbEngineBisectTo.AutoCompleteCustomSource.AddRange(engineList.ToArray()); tbGame.AutoCompleteCustomSource.AddRange(modList.ToArray()); tbGameBisectTo.AutoCompleteCustomSource.AddRange(modList.ToArray()); }); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } }
void SetupAutoComplete() { try { List <string> engineList = new List <string>(); List <string> modList = new List <string>(); try { engineList = EngineDownload.GetEngineList(); modList = springDownloader.PackageDownloader.Repositories.SelectMany(x => x.VersionsByTag.Keys).ToList(); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } InvokeIfNeeded(() => { tbEngine.AutoCompleteCustomSource.AddRange(engineList.ToArray()); tbGame.AutoCompleteCustomSource.AddRange(modList.ToArray()); }); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } }
/// <summary> /// Download requested Spring version, then call SetEnginePath() after finishes. /// Parameter "forSpringPaths" allow you to set a custom SpringPath for which to call SetEnginePath() /// on behalf off (is useful for Autohost which run multiple Spring version but is sharing single downloader) /// </summary> public Download GetAndSwitchEngine(string version, SpringPaths forSpringPaths=null ) { if (forSpringPaths == null) forSpringPaths = SpringPaths; lock (downloads) { downloads.RemoveAll(x => x.IsAborted || x.IsComplete != null); // remove already completed downloads from list} var existing = downloads.SingleOrDefault(x => x.Name == version); if (existing != null) return existing; if (SpringPaths.HasEngineVersion(version)) { forSpringPaths.SetEnginePath(SpringPaths.GetEngineFolderByVersion(version)); return null; } else { var down = new EngineDownload(version, forSpringPaths); downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs<Download>(down)); down.Start(); return down; } } }
static void Main(string[] args) { var ed = new EngineDownload("102.0.1-19-gfbc1b5b", new SpringPaths(null, @"c:\temp\test")); ed.Start(); ed.WaitHandle.WaitOne(); return; /*using (var archive = ArchiveFactory.Open(target)) { long done = 0; var totalSize = archive.Entries.Count() + 1; archive.EntryExtractionEnd += (sender, args) => { done++; IndividualProgress = 90 + (10 * done / totalSize); }; archive.WriteToDirectory(targetDir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite); }*/ //WikiPortingMW.DoStuff(); return; //FixStuff(); //MigrateDatabase(); //return; //DeleteOldUsers(); //return; /* //ImportWiki(); var db = new ZkDataContext(); var wikis = db.ForumCategories.First(x => x.IsWiki).ForumThreads.Select(x => new { key=x.WikiKey, text= x.ForumPosts.First().Text}).ToList(); var parser = new ForumWikiParser(); for (int i = 0; i < 100; i++) { var sw = Stopwatch.StartNew(); foreach (var w in wikis) { //Console.WriteLine(w.key); parser.ProcessToHtml(w.text, null); } sw.Stop(); Console.WriteLine("total: {0}ms, item: {1:D}ms", sw.ElapsedMilliseconds, sw.ElapsedMilliseconds/wikis.Count); }*/ //GetGameStats(new DateTime(2014,12,1)); //Thread.Sleep(10000); //var ns = new NubSimulator(); //ns.SpawnMany(); //Console.ReadLine(); //MigrateDatabase(); //FixDuplicatedAccounts(); //BcryptPasswords(); //var db = new ZkDataContext(true); //var test = db.Accounts.OrderByDescending(x => x.EffectiveElo).WithTranslations().Take(5).ToList(); //MigrateDatabase(); //var test = GlobalConst.GetContentService().DownloadFile("Zero-K v1.1.0"); //var db = new ZkDataContext(); //var post = db.ForumPosts.First(x => x.ForumPostID == 113893); //var db = new ZkDataContext(false); //db.Database.CreateIfNotExists(); //PlanetwarsFixer.StartGalaxy(24,3919,3925); //AddClanLeader(); //return; //TestPwMatch(); //var guid = Guid.NewGuid().ToString(); //var pp = new PayPalInterface(); //pp.ImportPaypalHistory(Directory.GetCurrentDirectory()); //Test1v1Elo(); //GenerateTechs(); //FixDemoEngineVersion(); //ImportSpringiePlayers(); //RecalculateBattleElo(); //FixMaps(); //PickHomworldOwners(); //PlanetwarsFixer.PurgeGalaxy(24, false, true); //PlanetwarsFixer.RandomizeMaps(24); //SetPlanetTeamSizes(); //RandomizePlanetOwners(24); //GenerateStructures(24); //PlanetwarsFixer.GenerateArtefacts(24, new int[] { 3940, 3949, 3954, 3929, 3956 }); //SwapPlanetOwners(3948, 3955); //SwapPlanetOwners(3973, 3932); //PlanetwarsFixer.AddWormholes(); //PlanetwarsFixer.RemoveTechStructures(true, true); //StartGalaxy(24); //TestPrediction(); //FixMissionScripts(); //AnalyzeModuleUsagePatterns(); //AnalyzeCommUsagePatterns(); //UpdateMissionProgression(12); //PrintNightwatchSubscriptions("zkadmin"); //RecountForumVotes(); //GetForumKarmaLadder(); //GetForumKarmaVotes(); //GetForumVotesByVoter(161294, 5340); //DeleteUserVotes(189201, null); //neon //GetClanStackWinRate(465, 2000); //Mean //GetForumVotesByUserVoterAgnostic(161294); //GetAverageElo(); //DuplicateFinder.GetDuplicates(); }
public Download GetResource(DownloadType type, string name) { if (name == "zk:dev" || name == "Zero-K $VERSION") return null; lock (downloads) { downloads.RemoveAll(x => x.IsAborted || x.IsComplete != null); // remove already completed downloads from list} var existing = downloads.FirstOrDefault(x => x.Name == name || x.Alias == name); if (existing != null) return existing; } if (scanner?.HasResource(name) == true) return null; if (SpringPaths.HasEngineVersion(name)) return null; // check rapid to determine type if (type == DownloadType.NOTKNOWN) { if (packageDownloader.GetByInternalName(name) != null || packageDownloader.GetByTag(name) != null) type = DownloadType.RAPID; else { packageDownloader.LoadMasterAndVersions().Wait(); if (packageDownloader.GetByInternalName(name) != null || packageDownloader.GetByTag(name) != null) type = DownloadType.RAPID; else type = DownloadType.MAP; } } lock (downloads) { if (type == DownloadType.DEMO) { var target = new Uri(name); var targetName = target.Segments.Last(); var filePath = Utils.MakePath(SpringPaths.WritableDirectory, "demos", targetName); if (File.Exists(filePath)) return null; var down = new WebFileDownload(name, filePath, null); down.DownloadType = type; downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs<Download>(down)); //create dowload bar (handled by MainWindow.cs) down.Start(); return down; } if (type == DownloadType.MAP || type == DownloadType.MISSION) { if (torrentDownloader == null) torrentDownloader = new TorrentDownloader(this); //lazy initialization var down = torrentDownloader.DownloadTorrent(name); if (down != null) { down.DownloadType = type; downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs<Download>(down)); return down; } } if (type == DownloadType.RAPID) { var down = packageDownloader.GetPackageDownload(name); if (down != null) { down.DownloadType = type; down.Alias = name; downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs<Download>(down)); return down; } } if (type == DownloadType.ENGINE) { var down = new EngineDownload(name, SpringPaths); down.DownloadType = type; downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs<Download>(down)); down.Start(); return down; } return null; } }
public void GetDevelopList() { var list = EngineDownload.GetEngineList(); Assert.IsTrue(list.Count > 1); }