Пример #1
0
        public static async Task <Dictionary <uint, string> > GetFilesByBuild(string buildConfig)
        {
            var config = await Config.GetBuildConfig(buildConfig);

            var rootHash = "";

            using (var connection = new MySqlConnection(SettingsManager.connectionString))
            {
                await connection.OpenAsync();

                using var cmd   = connection.CreateCommand();
                cmd.CommandText = "SELECT root_cdn FROM wow_buildconfig WHERE hash = @hash";
                cmd.Parameters.AddWithValue("@hash", buildConfig);
                using var reader = await cmd.ExecuteReaderAsync();

                while (await reader.ReadAsync())
                {
                    rootHash = reader["root_cdn"].ToString();
                }
            }

            if (NGDP.encodingDictionary.TryGetValue(config.root, out var rootEntry))
            {
                rootHash = rootEntry.ToHexString().ToLower();
            }

            if (rootHash == "")
            {
                EncodingFile encoding;

                if (config.encodingSize == null || config.encodingSize.Count() < 2)
                {
                    encoding = await NGDP.GetEncoding(config.encoding[1].ToHexString(), 0);
                }
                else
                {
                    encoding = await NGDP.GetEncoding(config.encoding[1].ToHexString(), int.Parse(config.encodingSize[1]));
                }

                if (encoding.aEntries.TryGetValue(config.root, out var bakRootEntry))
                {
                    rootHash = bakRootEntry.eKey.ToHexString().ToLower();
                }
                else
                {
                    throw new KeyNotFoundException("Root encoding key not found!");
                }
            }

            return(await GetFilesByRoot(rootHash));
        }
Пример #2
0
        public static Dictionary <uint, string> GetFilesByBuild(string buildConfig)
        {
            var config = Config.GetBuildConfig("http://cdn.blizzard.com/tpr/wow/", buildConfig);

            var rootHash = "";

            using (var connection = new MySqlConnection(SettingsManager.connectionString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT root_cdn FROM wow_buildconfig WHERE hash = @hash";
                    cmd.Parameters.AddWithValue("@hash", buildConfig);
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            rootHash = reader["root_cdn"].ToString();
                        }
                    }
                }
            }

            if (rootHash == "")
            {
                EncodingFile encoding;

                if (config.encodingSize == null || config.encodingSize.Count() < 2)
                {
                    encoding = NGDP.GetEncoding("http://cdn.blizzard.com/tpr/wow/", config.encoding[1].ToHexString(), 0);
                }
                else
                {
                    encoding = NGDP.GetEncoding("http://cdn.blizzard.com/tpr/wow/", config.encoding[1].ToHexString(), int.Parse(config.encodingSize[1]));
                }


                if (encoding.aEntries.TryGetValue(config.root, out var rootEntry))
                {
                    rootHash = rootEntry.eKey.ToHexString().ToLower();
                }
                else
                {
                    throw new KeyNotFoundException("Root encoding key not found!");
                }
            }

            return(GetFilesByRoot(rootHash));
        }