/// /// Reads in the XML file defied in the GlobalConstants Class and walks /// through it looking for any Products which have been flagged "Dirty" /// and passes that data to the SmartMart WebService /// /// /// String containing the results of the UpdateProduct calls made /// to the SmartMart WebService if any Rows have been flagged as "Dirty" /// public static string saveAllProductData() { bool hasErrors = false; string errorMessage = ""; string returnMessage; try { SmartMartWebService.SmartMartWebServices SmartMart = new SmartMartWebService.SmartMartWebServices(); DataSet AllProductData = Products.readAllProductData(); foreach (DataRow MyRow in AllProductData.Tables["Products"].Rows) { if (int.Parse(MyRow["Dirty"].ToString()) == 1) { int ProductId = int.Parse(MyRow["ProductId"].ToString()); string BrandName = MyRow["BrandName"].ToString(); string ProductName = MyRow["ProductName"].ToString(); double SRP = double.Parse(MyRow["SRP"].ToString()); double GrossWeight = double.Parse(MyRow["GrossWeight"].ToString()); double NetWeight = double.Parse(MyRow["NetWeight"].ToString()); double ShelfWidth = double.Parse(MyRow["ShelfWidth"].ToString()); double ShelfHeight = double.Parse(MyRow["ShelfHeight"].ToString()); double ShelfDepth = double.Parse(MyRow["ShelfDepth"].ToString()); string LastUpdated = MyRow["LastUpdated"].ToString(); if (!SmartMart.updateProduct(ProductId, BrandName, ProductName, SRP, GrossWeight, NetWeight, ShelfWidth, ShelfHeight, ShelfDepth, LastUpdated)) { hasErrors = true; errorMessage = errorMessage + MyRow["ProductId"].ToString() + " - " + MyRow["BrandName"].ToString() + " - " + MyRow["ProductName"].ToString() + "\r\n"; } } } if (hasErrors == true) { returnMessage = "The following products could not be updated\r\n\r\n" + errorMessage; } else { returnMessage = "All Products updated Successfully"; } return returnMessage; } catch (Exception ex) { throw ex; } }