public static void LoadOldEmmaXML(string filename, Dictionary<int, int> IDChanges) { EMMADataSet.WebLinksDataTable table = new EMMADataSet.WebLinksDataTable(); XmlDocument xml = new XmlDocument(); xml.Load(filename); XmlNodeList nodes = xml.SelectNodes("/DocumentElement/WebLinks"); int counter = 0; //UpdateStatus(0, 0, "", "Extracting data from XML", false); foreach (XmlNode node in nodes) { int oldID = int.Parse(node.SelectSingleNode("CorpID").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); if (IDChanges.ContainsKey(oldID)) { int newID = IDChanges[oldID]; string link = node.SelectSingleNode("Link").FirstChild.Value; string description = node.SelectSingleNode("Description").FirstChild.Value; EMMADataSet.WebLinksRow newLink = table.NewWebLinksRow(); newLink.CorpID = newID; newLink.Description = description; newLink.Link = link; table.AddWebLinksRow(newLink); } counter++; //UpdateStatus(counter, nodes.Count, "", "", false); } //UpdateStatus(1, 1, "", "Complete", false); //UpdateStatus(0, 0, "", "Updating database", false); lock (tableAdapter) { tableAdapter.Update(table); } //UpdateStatus(1, 1, "", "Complete", false); }
public static void StoreLink(WebLink link) { bool newRow = false; EMMADataSet.WebLinksDataTable table = new EMMADataSet.WebLinksDataTable(); EMMADataSet.WebLinksRow row; tableAdapter.FillByID(table, link.ID); if (table.Count > 0) { row = table[0]; } else { row = table.NewWebLinksRow(); newRow = true; } row.CorpID = link.CorpID; row.Description = link.Description; row.Link = link.Link; if (newRow) { table.AddWebLinksRow(row); } tableAdapter.Update(table); }