public async Task SaveDetails(dsreplay replay, string detaildir = Program.detaildir) { string mydir = detaildir + "/" + replay.ID.ToString(); if (!Directory.Exists(mydir)) { Directory.CreateDirectory(mydir); WriteToBinaryFile(mydir + "/mid.bin", replay.MIDDLE); foreach (dsplayer pl in replay.PLAYERS) { PlStats st = new PlStats(); st.Loops = new List <int>(pl.STATS.Keys.ToList()); st.Stats = new List <M_stats>(pl.STATS.Values.ToList()); try { WriteToBinaryFile(mydir + "/" + pl.REALPOS.ToString() + "_stats.bin", st); } catch (Exception e) { Console.WriteLine(e.ToString()); } } } }
public async Task GetDetails(dsreplay replay, string detaildir = Program.detaildir) { await Task.Run(() => { // /data/tournaments/20190921/replays/Team5_vs_Team6_1.SC2Replay // /data/tournaments/20190921/7 string mydir = detaildir + "/" + replay.ID.ToString(); if (replay.REPLAY.Contains("tournaments")) { mydir = Path.GetDirectoryName(Path.GetDirectoryName(replay.REPLAY)) + "/" + replay.ID; } if (Directory.Exists(mydir)) { if (File.Exists(mydir + "/mid.bin")) { replay.MIDDLE = ReadFromBinaryFile <List <KeyValuePair <int, int> > >(mydir + "/mid.bin"); } foreach (dsplayer pl in replay.PLAYERS) { PlStats st = new PlStats(); if (File.Exists(mydir + "/" + pl.REALPOS.ToString() + "_stats.bin")) { st = ReadFromBinaryFile <PlStats>(mydir + "/" + pl.REALPOS.ToString() + "_stats.bin"); } int i = 0; foreach (var ent in st.Loops) { pl.STATS[ent] = st.Stats.ElementAt(i); i++; } } } }); }