private void SaveTitlesIndex() { CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingTitlesStart }); SerializeIndexToArchive(TitleIndexEntryName, UpdateTitlesIndex); CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingTitlesEnd }); }
/// <summary> /// Saves the prerequisites information to the metadata source /// </summary> private void SavePrerequisitesIndex() { CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingPrerequisitesStart }); SerializeIndexToArchive(PrerequisitesListEntryName, PrerequisitesList); CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingPrerequisitesEnd }); }
private void SaveSupersededndex() { CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.ProcessSupersedeDataStart }); SerializeIndexToArchive(SupersededIndexEntryName, SupersededUpdates); SerializeIndexToArchive(SupersedingIndexEntryName, SupersedingUpdates); CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.ProcessSupersedeDataEnd }); }
/// <summary> /// Saves the product and classification information to the metadata source /// </summary> private void SaveProductClassificationIndex() { CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingCategoriesStart }); ResolveProductsAndClassifications(); SerializeIndexToArchive( ProductClassificationEntryName, new KeyValuePair <Dictionary <int, List <Guid> >, Dictionary <int, List <Guid> > >( UpdateAndProductIndex, UpdateAndClassificationIndex)); CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingCategoriesEnd }); }
private void SaveDriversIndex() { CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingDriversStart }); SerializeIndexToArchive(DriversIndexEntryName, DriverMetadataStore); SerializeIndexToArchive(DriverToMetadataMapEntryName, DriverToMetadataMap); SerializeIndexToArchive(DriverVersionIndexEntryName, DriverVersionIndex); SerializeIndexToArchive(DriverFeatureScoreIndexEntryName, DriverFeatureScoreIndex); SerializeIndexToArchive(HardwareIdIndexEntryName, HardwareIdMap); SerializeIndexToArchive(ComputerHardwareIdIndexEntryName, MetadataToComputerHardwareIdMap); CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingDriversEnd }); }
/// <summary> /// Saves the bundling information to the metadata source /// </summary> private void SaveBundlesIndex() { if (PendingBundledUpdates.Count > 0) { throw new Exception("Unresolved bundle updates"); } CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingBundlesStart }); SerializeIndexToArchive( BundlesIndexEntryName, new KeyValuePair <Dictionary <int, List <int> >, Dictionary <int, List <int> > >(BundlesIndex, IsBundledTable)); CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.IndexingBundlesEnd }); }
private void ResolveProductsAndClassifications() { var progress = new OperationProgress() { CurrentOperation = OperationType.IndexingCategoriesProgress, Maximum = AddedUpdates.Count }; var productsList = Categories.Values.OfType <Product>().Select(p => p.Identity).ToList(); var classificationsList = Categories.Values.OfType <Classification>().Select(c => c.Identity).ToHashSet(); // Fill in product and classification information. foreach (var updateEntry in AddedUpdates) { if (AddedPrerequisites.ContainsKey(updateEntry.Value.Identity)) { // Find product information and add it to the index var updateProductsList = CategoryResolver.ResolveProductFromPrerequisites(AddedPrerequisites[updateEntry.Value.Identity], productsList); if (updateProductsList.Count > 0) { UpdateAndProductIndex.Add(updateEntry.Key, updateProductsList); } // Find classification information and add it to the index var updateClassificationsList = CategoryResolver.ResolveClassificationFromPrerequisites(AddedPrerequisites[updateEntry.Value.Identity], classificationsList); if (updateClassificationsList.Count > 0) { UpdateAndClassificationIndex.Add(updateEntry.Key, updateClassificationsList); } } progress.Current++; if (progress.Current % 1000 == 0) { CommitProgress?.Invoke(this, progress); } } }
/// <summary> /// Computes the checksum of this medata source. /// The checksum is computed from the list of triples [update index, update guid, update revision], sorted by update index /// </summary> private void ComputeChecksum() { CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.HashMetadataStart }); using (var hash = IncrementalHash.CreateHash(HashAlgorithmName.SHA512)) { foreach (var entry in IndexToIdentity) { hash.AppendData(BitConverter.GetBytes(entry.Key)); hash.AppendData(BitConverter.GetBytes(entry.Value.Revision)); hash.AppendData(entry.Value.Raw.UpdateID.ToByteArray()); } Checksum = Convert.ToBase64String(hash.GetHashAndReset()); } CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.HashMetadataEnd }); }
private void CreateGraph() { if (Graph != null) { return; } CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.PrerequisiteGraphUpdateStart }); Graph = new Dictionary <Guid, PrerequisiteGraphNode>(); var updateIndexesWithPrerequisites = IndexToIdentity.Keys.Where(i => HasPrerequisites(i)).ToList(); var progress = new OperationProgress() { CurrentOperation = OperationType.PrerequisiteGraphUpdateProgress, Maximum = updateIndexesWithPrerequisites.Count }; foreach (var updateIndex in updateIndexesWithPrerequisites) { PrerequisiteGraphNode updateNode; if (!Graph.ContainsKey(this[updateIndex].ID)) { updateNode = new PrerequisiteGraphNode(this[updateIndex].ID); Graph.Add(this[updateIndex].ID, updateNode); } else { updateNode = Graph[this[updateIndex].ID]; } var prerequisites = GetPrerequisites(updateIndex); var flatListPrerequisites = prerequisites.SelectMany(p => { if (p is Simple) { return(new List <Guid>() { (p as Simple).UpdateId }); } else if (p is AtLeastOne) { return((p as AtLeastOne).Simple.Select(s => s.UpdateId)); } else { throw new Exception("Unknown prerequisite type"); } }); foreach (var prerequisite in flatListPrerequisites) { PrerequisiteGraphNode prerequisiteNode; if (Graph.ContainsKey(prerequisite)) { prerequisiteNode = Graph[prerequisite]; } else { prerequisiteNode = new PrerequisiteGraphNode(prerequisite); Graph.Add(prerequisite, prerequisiteNode); } updateNode.Prerequisites.TryAdd(prerequisite, prerequisiteNode); prerequisiteNode.Dependents.TryAdd(this[updateIndex].ID, updateNode); } progress.Current++; if (progress.Current % 1000 == 0) { CommitProgress?.Invoke(this, progress); } } CommitProgress?.Invoke(this, new OperationProgress() { CurrentOperation = OperationType.PrerequisiteGraphUpdateEnd }); }