// Add Doc in DB public void addInDB(Corel.Interop.VGCore.Document Doc, string FileName) { var xDoc = new XmlDocument(); xDoc.Load(RFcontrol.uPath); var root = xDoc.ChildNodes[1]; string fName = FileName.Length > 0 ? FileName : Doc.FullFileName; if (!IsFileLocked(fName)) { var d = xDoc.CreateElement("Doc"); d.SetAttribute("Title", Path.GetFileName(fName)); d.SetAttribute("FilePath", fName); d.SetAttribute("Ver", GetCDRversion(fName)); d.SetAttribute("Img", ImageToBase64(fName)); if (root.ChildNodes.Count == 0) { root.AppendChild(d); } else { root.InsertBefore(d, root.FirstChild); } xDoc.Save(RFcontrol.uPath); LoadList(); } }
// Update Doc in DB public void updateInDB(Corel.Interop.VGCore.Document Doc, string FileName) { var xDoc = new XmlDocument(); xDoc.Load(RFcontrol.uPath); string fName = FileName.Length > 0 ? FileName : Doc.FullFileName; var d = xDoc.SelectSingleNode("//Doc[@FilePath = \"" + fName + "\"]"); if (d != null) { var root = xDoc.ChildNodes[1]; root.RemoveChild(d); xDoc.Save(RFcontrol.uPath); addInDB(Doc, FileName); } else { MessageBox.Show("Item not found!", RFcontrol.mName, MessageBoxButton.OK); } }