コード例 #1
0
        private static async Task ProcessUpdateAsync(UpdateData update, string pOutputFolder, MachineType MachineType, string Language = "", string Edition = "", bool WriteMetadata = true)
        {
            HashSet <CompDBXmlClass.PayloadItem> payloadItems       = new();
            HashSet <CompDBXmlClass.PayloadItem> bannedPayloadItems = new();
            HashSet <CompDBXmlClass.CompDB>      specificCompDBs    = new();

            string buildstr = "";
            IEnumerable <string> languages = null;

            int returnCode = 0;
            IEnumerable <CExtendedUpdateInfoXml.File> filesToDownload = null;

            bool getSpecific             = !string.IsNullOrEmpty(Language) && !string.IsNullOrEmpty(Edition);
            bool getSpecificLanguageOnly = !string.IsNullOrEmpty(Language) && string.IsNullOrEmpty(Edition);

            Logging.Log("Title: " + update.Xml.LocalizedProperties.Title);
            Logging.Log("Description: " + update.Xml.LocalizedProperties.Description);

#if DEBUG
            foreach (var file in update.Xml.Files.File.Select(x => UpdateUtils.GetFilenameForCEUIFile(x, payloadItems)).OrderBy(x => x))
            {
                Console.WriteLine(file);
            }
#endif

            Logging.Log("Gathering update metadata...");

            var compDBs = await update.GetCompDBsAsync();

            await Task.WhenAll(
                Task.Run(async() => buildstr  = await update.GetBuildStringAsync()),
                Task.Run(async() => languages = await update.GetAvailableLanguagesAsync()));

            buildstr ??= "";

            if (string.IsNullOrEmpty(buildstr) && update.Xml.LocalizedProperties.Title.Contains("(UUP-CTv2)"))
            {
                string unformattedBase = update.Xml.LocalizedProperties.Title.Split(" ")[0];
                buildstr = $"10.0.{unformattedBase.Split(".")[0]}.{unformattedBase.Split(".")[1]} ({unformattedBase.Split(".")[2]}.{unformattedBase.Split(".")[3]})";
            }
            else if (string.IsNullOrEmpty(buildstr))
            {
                buildstr = update.Xml.LocalizedProperties.Title;
            }

            string name = $"{buildstr.Replace(" ", ".").Replace("(", "").Replace(")", "")}_{MachineType.ToString().ToLower()}fre_{update.Xml.UpdateIdentity.UpdateID.Split("-")[^1]}";