private static async Task <(CGetExtendedUpdateInfoResponse.GetExtendedUpdateInfoResponse, string)> GetExtendedUpdateInfo( CSOAPCommon.Cookie cookie, string token, string[] revisionId, CTAC ctac) { CSOAPCommon.Envelope envelope = GetEnveloppe("GetExtendedUpdateInfo", token, false); envelope.Body.GetExtendedUpdateInfo = new CGetExtendedUpdateInfoRequest.GetExtendedUpdateInfo() { Cookie = cookie, RevisionIDs = new CGetExtendedUpdateInfoRequest.RevisionIDs() { Int = revisionId }, InfoTypes = new CSOAPCommon.InfoTypes() { XmlUpdateFragmentType = new string[] { "FileUrl", "FileDecryption", "Extended", "LocalizedProperties", "Eula", "Published", "Core", "VerificationRule" } }, Locales = new CSOAPCommon.Locales() { String = new string[] { "en-US", "en" } }, DeviceAttributes = ctac.DeviceAttributes }; string message = SerializeSOAPEnvelope(envelope); string response = await PostToWindowsUpdateAsync("GetCookie", message, false); CSOAPCommon.Envelope renvelope = DeserializeSOAPEnvelope(response); return(renvelope.Body.GetExtendedUpdateInfoResponse, response); }
private static async Task <(CGetExtendedUpdateInfo2Response.GetExtendedUpdateInfo2Response, string)> GetExtendedUpdateInfo2( string token, string UpdateID, string RevisionNumber, CTAC ctac ) { CSOAPCommon.Envelope envelope = GetEnveloppe("GetExtendedUpdateInfo2", token, true); envelope.Body.GetExtendedUpdateInfo2 = new CGetExtendedUpdateInfo2Request.GetExtendedUpdateInfo2() { UpdateIDs = new CGetExtendedUpdateInfo2Request.UpdateIDs() { UpdateIdentity = new CGetExtendedUpdateInfo2Request.UpdateIdentity() { UpdateID = UpdateID, RevisionNumber = RevisionNumber } }, InfoTypes = new CSOAPCommon.InfoTypes() { XmlUpdateFragmentType = new string[] { "FileUrl", "FileDecryption", "EsrpDecryptionInformation", "PiecesHashUrl", "BlockMapUrl" } }, DeviceAttributes = ctac.DeviceAttributes }; string message = SerializeSOAPEnvelope(envelope); string response = await PostToWindowsUpdateAsync("GetExtendedUpdateInfo2", message, true); CSOAPCommon.Envelope renvelope = DeserializeSOAPEnvelope(response); return(renvelope.Body.GetExtendedUpdateInfo2Response, response); }
private static async Task <IEnumerable <UpdateData> > GetUpdates(MachineType MachineType) { HashSet <UpdateData> updates = new HashSet <UpdateData>(); CTAC[] ctacs = new CTAC[] { new CTAC(OSSkuId.PPIPro, "10.0.15063.534", MachineType, "WIS", "", "CB", "rs2_release", "Production", false), new CTAC(OSSkuId.PPIPro, "10.0.15063.534", MachineType, "WIF", "", "CB", "rs2_release", "Production", false), new CTAC(OSSkuId.PPIPro, "10.0.19041.84", MachineType, "Retail", "", "CB", "vb_release", "Production", false), new CTAC(OSSkuId.Professional, "10.0.16299.15", MachineType, "Retail", "", "CB", "rs3_release", "Production", true), new CTAC(OSSkuId.Professional, "10.0.17134.1", MachineType, "Retail", "", "CB", "rs4_release", "Production", true), new CTAC(OSSkuId.Professional, "10.0.17763.1217", MachineType, "Retail", "", "CB", "rs5_release", "Production", true), new CTAC(OSSkuId.Professional, "10.0.18362.836", MachineType, "Retail", "", "CB", "19h1_release", "Production", true), new CTAC(OSSkuId.Professional, "10.0.19041.84", MachineType, "Retail", "", "CB", "vb_release", "Production", false), new CTAC(OSSkuId.Professional, "10.0.19041.84", MachineType, "External", "ReleasePreview", "CB", "vb_release", "Production", false), new CTAC(OSSkuId.Professional, "10.0.19041.84", MachineType, "External", "FeaturePreview", "CB", "vb_release", "Production", false), new CTAC(OSSkuId.Professional, "10.0.19041.84", MachineType, "External", "Beta", "CB", "vb_release", "Production", false), new CTAC(OSSkuId.Professional, "10.0.19041.84", MachineType, "External", "Dev", "CB", "vb_release", "Production", false) }; List <Task <IEnumerable <UpdateData> > > tasks = new List <Task <IEnumerable <UpdateData> > >(); foreach (var ctac in ctacs) { tasks.Add(FE3Handler.GetUpdates(null, ctac, null, FileExchangeV3UpdateFilter.ProductRelease)); } IEnumerable <UpdateData>[] datas = await Task.WhenAll(tasks); foreach (var data in datas) { AddUpdatesIfNotPresentAlready(updates, data); } return(updates); }
public static async Task <IEnumerable <UpdateData> > GetUpdates(string categoryId, CTAC ctac, string token, FileExchangeV3UpdateFilter filter = FileExchangeV3UpdateFilter.Application) // Or ProductRelease { (CGetCookieResponse.GetCookieResponse cookie, string cookieresp) = await GetCookie(); HashSet <string> InstalledNonLeafUpdateIDs = new HashSet <string>(); HashSet <string> OtherCachedUpdateIDs = new HashSet <string>(); HashSet <(CSyncUpdatesResponse.SyncUpdatesResponse, string)> responses = new HashSet <(CSyncUpdatesResponse.SyncUpdatesResponse, string)>(); // // Scan all updates // WU will not return all updates in one go // So we need to perform multiple scans and cache the ids // while (true) { var result = await SyncUpdates(cookie.GetCookieResult, token, InstalledNonLeafUpdateIDs, OtherCachedUpdateIDs, new string[] { categoryId }, ctac); // Refresh the cookie cookie.GetCookieResult.EncryptedData = result.Item1.SyncUpdatesResult.NewCookie.EncryptedData; cookie.GetCookieResult.Expiration = result.Item1.SyncUpdatesResult.NewCookie.Expiration; if (result.Item1.SyncUpdatesResult.ExtendedUpdateInfo == null || result.Item1.SyncUpdatesResult.ExtendedUpdateInfo.Updates.Update == null || result.Item1.SyncUpdatesResult.ExtendedUpdateInfo.Updates.Update.Count() == 0) { break; } foreach (var update in result.Item1.SyncUpdatesResult.ExtendedUpdateInfo.Updates.Update) { InstalledNonLeafUpdateIDs.Add(update.ID); OtherCachedUpdateIDs.Add(update.ID); } responses.Add(result); } HashSet <UpdateData> updateDatas = new HashSet <UpdateData>(); foreach (var response in responses) { foreach (var update in response.Item1.SyncUpdatesResult.ExtendedUpdateInfo.Updates.Update) { UpdateData data = new UpdateData() { Update = update }; foreach (var updateInfo in response.Item1.SyncUpdatesResult.NewUpdates.UpdateInfo) { if (ulong.Parse(update.ID) == ulong.Parse(updateInfo.ID)) { data.UpdateInfo = updateInfo; break; } } CExtendedUpdateInfoXml.Xml updateXml = DeserializeInfoXML(data.Update.Xml + data.UpdateInfo.Xml); data.Xml = updateXml; if (data.Xml.ApplicabilityRules != null && data.Xml.ApplicabilityRules.Metadata != null && data.Xml.ApplicabilityRules.Metadata.AppxPackageMetadata != null && data.Xml.ApplicabilityRules.Metadata.AppxPackageMetadata.AppxMetadata != null) { data.AppxMetadata = DeserializeAppxJSON(data.Xml.ApplicabilityRules.Metadata.AppxPackageMetadata.AppxMetadata.ApplicabilityBlob); } if (updateDatas.Any(x => x.Update.ID == update.ID)) { var updateData = updateDatas.First(x => x.Update.ID == update.ID); if (data.Xml.LocalizedProperties == null) { var backup = updateData.Xml; updateData.Xml = data.Xml; updateData.Xml.LocalizedProperties = backup.LocalizedProperties; } if (updateData.Xml.LocalizedProperties == null) { updateData.Xml.LocalizedProperties = data.Xml.LocalizedProperties; } continue; } data.SyncUpdatesResponse = response.Item2; updateDatas.Add(data); } } HashSet <UpdateData> relevantUpdateDatas = new HashSet <UpdateData>(); foreach (var updateData in updateDatas) { if (updateData.Xml.ExtendedProperties != null) { if (updateData.Xml.ExtendedProperties.ContentType == filter.ToString() && updateData.Xml.Files != null) { updateData.CTAC = ctac; relevantUpdateDatas.Add(updateData); } } } return(relevantUpdateDatas); }
private static async Task <(CSyncUpdatesResponse.SyncUpdatesResponse, string)> SyncUpdates( CSOAPCommon.Cookie cookie, string token, IEnumerable <string> InstalledNonLeafUpdateIDs, IEnumerable <string> OtherCachedUpdateIDs, string[] CategoryIdentifiers, CTAC ctac ) { string[] _InstalledNonLeafUpdateIDs = Constants.InstalledNonLeafUpdateIDs.Select(x => x.ToString()).ToArray(); if (InstalledNonLeafUpdateIDs != null) { var tmplist = _InstalledNonLeafUpdateIDs.ToList(); tmplist.AddRange(InstalledNonLeafUpdateIDs); _InstalledNonLeafUpdateIDs = tmplist.ToArray(); } CSOAPCommon.Envelope envelope = GetEnveloppe("SyncUpdates", token, false); envelope.Body.SyncUpdates = new CSyncUpdatesRequest.SyncUpdates() { Cookie = cookie, Parameters = new CSyncUpdatesRequest.Parameters() { ExpressQuery = "false", InstalledNonLeafUpdateIDs = new CSyncUpdatesRequest.InstalledNonLeafUpdateIDs() { Int = _InstalledNonLeafUpdateIDs }, OtherCachedUpdateIDs = new CSyncUpdatesRequest.OtherCachedUpdateIDs() { Int = OtherCachedUpdateIDs != null?OtherCachedUpdateIDs.ToArray() : new string[0] }, SkipSoftwareSync = "false", NeedTwoGroupOutOfScopeUpdates = "true", FilterAppCategoryIds = CategoryIdentifiers != null && CategoryIdentifiers.Length != 0 ? new CSyncUpdatesRequest.FilterAppCategoryIds() { CategoryIdentifier = new CSyncUpdatesRequest.CategoryIdentifier() { Id = CategoryIdentifiers != null ? CategoryIdentifiers : new string[0] } } : null, AlsoPerformRegularSync = "false", ComputerSpec = "", ExtendedUpdateInfoParameters = new CSyncUpdatesRequest.ExtendedUpdateInfoParameters() { XmlUpdateFragmentTypes = new CSyncUpdatesRequest.XmlUpdateFragmentTypes() { XmlUpdateFragmentType = new string[] { "Extended", "LocalizedProperties", "Eula", "Published", "Core" } }, Locales = new CSOAPCommon.Locales() { String = new string[] { "en-US", "en" } } }, ClientPreferredLanguages = "", ProductsParameters = new CSyncUpdatesRequest.ProductsParameters() { SyncCurrentVersionOnly = ctac.SyncCurrentVersionOnly ? "true" : "false", DeviceAttributes = ctac.DeviceAttributes, CallerAttributes = ctac.CallerAttributes, Products = ctac.Products } } }; string message = SerializeSOAPEnvelope(envelope); string response = await PostToWindowsUpdateAsync("SyncUpdates", message, false); CSOAPCommon.Envelope renvelope = DeserializeSOAPEnvelope(response); return(renvelope.Body.SyncUpdatesResponse, response); }