private void DiffAttributes(XDocument lastExportedAttributesDocument, XDocument currentExportedAttributesDocument) { var currentAttributeProducts = new SortedList <int, XElement>(currentExportedAttributesDocument.Root.Elements("ProductAttribute").ToDictionary(c => int.Parse(c.Attribute("ProductID").Value), c => c)); //if the last exported att if (lastExportedAttributesDocument == null) { ProductsToProcess = CurrentFullAssortment; //if no last exported product } else { //check for filter groups var filterGroupsNew = _currentAssortmentDocument.Root.Element("AttributeValueGroups"); var filterGroupsOld = _currentAssortmentDocument.Root.Element("AttributeValueGroups"); if (!XElement.DeepEquals(filterGroupsNew, filterGroupsOld)) { ProductsToProcess = CurrentFullAssortment; //if no last exported product return; } var lastAttributeProducts = currentExportedAttributesDocument.Root.Elements("ProductAttribute").ToLookup(c => int.Parse(c.Attribute("ProductID").Value)); var changedProductIDs = (from p in currentAttributeProducts where lastAttributeProducts.Contains(p.Key) && !XElement.DeepEquals(p.Value, lastAttributeProducts[p.Key].First()) select p.Key).ToList(); ProductsToProcess = ProductsToProcess.Union(CurrentFullAssortment.Where(c => changedProductIDs.Contains(c.ProductID))).ToList(); } }
private void DiffContent(XDocument lastExportedContentDocument, XDocument currentExportedContentDocument) { var currentAttributeProducts = new SortedList <int, XElement>(currentExportedContentDocument.Root.Elements("Product").ToDictionary(c => int.Parse(c.Attribute("ProductID").Value), c => c)); if (lastExportedContentDocument == null) { ProductsToProcess = CurrentFullAssortment; //if no last exported product } else { var lastAttributeProducts = lastExportedContentDocument.Root.Elements("Product").ToLookup(c => int.Parse(c.Attribute("ProductID").Value)); var changedProductIDs = (from p in currentAttributeProducts where lastAttributeProducts.Contains(p.Key) && !XElement.DeepEquals(p.Value, lastAttributeProducts[p.Key].First()) select p.Key).ToList(); ProductsToProcess = ProductsToProcess.Union(CurrentFullAssortment.Where(c => changedProductIDs.Contains(c.ProductID))).ToList(); } }