示例#1
0
        public static void UpdateFile(string realm, string region, bool forceAll = false)
        {
            string _realm = Realm, _region = Region;

            Realm  = realm;
            Region = region;
            string        fileName = $"map_{Realm}_{Region}.txt";
            List <string> versions = Utils.GetSolutionVersions("lol_game_client_sln"), toDownload = new List <string>(versions), i;
            Dictionary <string, string> output = new Dictionary <string, string>();

            if (!forceAll && File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    string   str;
                    string[] split;
                    while ((str = sr.ReadLine()) != null)
                    {
                        split = str.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
                        toDownload.Remove(split[0]);
                        output.Add(split[0], split[1]);
                    }
                }
            }

            Console.WriteLine($"Updating {toDownload.Count} items for {region}@{realm}");



            while (toDownload.Count > 0)
            {
                int all = toDownload.Count, ok = 0;
                i = new List <string>(toDownload);
                toDownload.Clear();
                Parallel.ForEach(i, new ParallelOptions()
                {
                    MaxDegreeOfParallelism = 4
                }, version =>
                {
                    try
                    {
                        Console.Title      = $"Left {all - ok}";
                        SolutionManifest m = new SolutionManifest("lol_game_client_sln", version);
                        ReleaseManifest rm = m.Projects[0].GetReleaseManifest();
                        string v           = Utils.GetClientVersion(rm) + $" ({m.Projects[0].Version})";
                        GC.Collect();
                        lock (output)
                        {
                            output.Add(version, v);
                        }
                        Interlocked.Increment(ref ok);
                        Log(string.Format("{0} -> {1}", version, v));
                    }
                    catch
                    {
                        Console.WriteLine("Retrying {0}..", version);
                        lock (toDownload) { toDownload.Add(version); }
                    }
                });
            }

            using (StreamWriter sw = new StreamWriter(fileName, false))
            {
                foreach (string v in versions)
                {
                    sw.WriteLine($"{v} -> {output[v]}");
                }
            }

            File.Copy(fileName, $@"..\..\..\..\output\{fileName}", true);

            Realm  = _realm;
            Region = _region;
        }
示例#2
0
        public static void UpdateFile(string realm, string region, bool forceAll = false)
        {
            string _realm = Realm, _region = Region;
            Realm = realm;
            Region = region;
            string fileName = $"map_{Realm}_{Region}.txt";
            List<string> versions = Utils.GetSolutionVersions("lol_game_client_sln"), toDownload = new List<string>(versions), i;
            Dictionary<string, string> output = new Dictionary<string, string>();
            if(!forceAll && File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    string str;
                    string[] split;
                    while((str = sr.ReadLine()) != null)
                    {
                        split = str.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
                        toDownload.Remove(split[0]);
                        output.Add(split[0], split[1]);
                    }
                }
            }

            Console.WriteLine($"Updating {toDownload.Count} items for {region}@{realm}");

            while (toDownload.Count > 0)
            {
                int all = toDownload.Count, ok = 0;
                i = new List<string>(toDownload);
                toDownload.Clear();
                Parallel.ForEach(i, new ParallelOptions() { MaxDegreeOfParallelism = 4 }, version =>
                {
                    try
                    {
                        Console.Title = $"Left {all - ok}";
                        SolutionManifest m = new SolutionManifest("lol_game_client_sln", version);
                        ReleaseManifest rm = m.Projects[0].GetReleaseManifest();
                        string v = Utils.GetClientVersion(rm) + $" ({m.Projects[0].Version})";
                        GC.Collect();
                        lock (output)
                        {
                            output.Add(version, v);
                        }
                        Interlocked.Increment(ref ok);
                        Log(string.Format("{0} -> {1}", version, v));
                    }
                    catch
                    {
                        Console.WriteLine("Retrying {0}..", version);
                        lock (toDownload) { toDownload.Add(version); }
                    }
                });
            }

            using (StreamWriter sw = new StreamWriter(fileName, false))
            {
                foreach (string v in versions)
                {
                    sw.WriteLine($"{v} -> {output[v]}");
                }
            }

            File.Copy(fileName, $@"..\..\..\..\output\{fileName}", true);

            Realm = _realm;
            Region = _region;
        }