Exemplo n.º 1
0
        private void ProcessResendProductInformationToWehkampProducts(IEnumerable <ProductInformationSize> products)
        {
            var productIDs = products.Where(p => p.ResendProductInformationToWehkamp != null && p.ResendProductInformationToWehkamp.ToLowerInvariant() == "true").Select(product => product.ProductID).ToList();

            if (productIDs.Count == 0)
            {
                return;
            }

            var sql = string.Empty;

            try
            {
                using (var db = new PetaPoco.Database(Environments.Current.Connection, "System.Data.SqlClient"))
                {
                    db.CommandTimeout = 600; //10 minutes
                    sql = string.Format("UPDATE ProductAttributeValue SET Value = 'false' WHERE AttributeID = (SELECT AttributeID FROM ProductAttributeMetaData pamd WHERE pamd.AttributeCode = 'SentToWehkamp') AND ProductID IN (SELECT DISTINCT ParentProductID FROM Product WHERE ProductID IN ({0}))", string.Join(",", productIDs.ToArray()));
                    db.Execute(sql);

                    sql = string.Format("DELETE FROM ProductAttributeValue WHERE AttributeID = {0} AND ProductID IN (SELECT DISTINCT ParentProductID FROM Product WHERE ProductID IN ({1}))", VendorSettingsHelper.GetResendProductInformationToWehkampAttributeID(), string.Join(",", productIDs.ToArray()));
                    db.Execute(sql);
                }
            }
            catch (Exception ex)
            {
                log.AuditError(String.Format("ProcessResendPriceUpdateToWehkampProducts. ProductID's : {0}; SQL used: {1}", string.Join(",", productIDs.ToArray()), sql), ex);
            }
        }