public void ReplaceInForms(string xPath, XElement document, Element previousParam, Element param) { var nodes = document.XPathSelectElements(xPath); foreach (var node in nodes) { if (node.HasElements) { continue; } if (!node.HasAttributes || node.Attribute("Name").Value != previousParam.FormName || node.Attribute("Pdf").Value != previousParam.PdfName) { continue; } AttributeHelper.AttributeInNode("Name", previousParam.FormName, param.FormName, node); AttributeHelper.AttributeInNode("Pdf", previousParam.PdfName, param.PdfName, node); AttributeHelper.AttributeInNode("Doctype", previousParam.Doctype, param.Doctype, node); AttributeHelper.AttributeInNode("DataNamePrefix", previousParam.DataNamePrefix, param.DataNamePrefix, node); AttributeHelper.AttributeInNode("Docdesc", previousParam.Docdesc, param.Docdesc, node); AttributeHelper.AttributeInNode("MergeID", previousParam.MergeId, param.MergeId, node); AttributeHelper.AttributeInNode("Attachment", previousParam.Attachment, param.Attachment, node); } }
public XElement Edit(Element oldParam, Element newParam) { if (oldParam == null || newParam == null) { return null; } var doc = _document; try { _replace.ReplaceInPdfs(ConstPath.Pdfs, _document, oldParam, newParam); Logger.Log(LogLevel.Trace, "Edited Information In Pdfs In Config File"); _replace.ReplaceInForms(ConstPath.Forms, _document, oldParam, newParam); Logger.Log(LogLevel.Trace, "Edited Information In Forms In Config File"); _replace.ReplaceInPackages(ConstPath.FormsInPackages, _document, oldParam, newParam); Logger.Log(LogLevel.Trace, "Edited Information In Packages In Config File"); Logger.Log(LogLevel.Info, "Edited Information In Config File"); return _document; } catch (Exception ex) { Logger.Log(LogLevel.Error, ex.Message); return doc; } }
public XElement Add(Element param) { if (param == null) { return null; } var doc = _document; try { _add.AddToPackages(ConstPath.Packages, _document, param); Logger.Log(LogLevel.Trace, "Added Information To All Packages In Config File"); _add.AddToForms(ConstPath.Form, _document, param); Logger.Log(LogLevel.Trace, "Added Information To Forms In Config File"); _add.AddToPdfs(ConstPath.Pdf, _document, param); Logger.Log(LogLevel.Trace, "Added Information To Pdfs In Config File"); Logger.Log(LogLevel.Info, "Added Information To Config File"); return _document; } catch (Exception ex) { Logger.Log(LogLevel.Error, ex.Message); return doc; } }
public void AddToForms(string xPath, XElement document, Element element) { var nodes = document.XPathSelectElements(xPath); foreach (var node in nodes) { node.Add(AttributeHelper.AddNodeToForm(element)); } }
public void RemoveFromPackages(string xPath, XElement document, Element param) { var nodes = document.XPathSelectElements(xPath); foreach (var node in nodes.Where(node => node.Name == "Form" && node.Attribute("Name") != null && node.Attribute("Name").Value == param.FormName)) { node.Remove(); } }
public void ReplaceInPdfs(string xPath, XElement document, Element previousParam, Element param) { var nodes = document.XPathSelectElements(xPath); foreach (var node in nodes.Where(node => node.HasAttributes && node.Attribute("Name").Value == previousParam.PdfName && node.Attribute("File").Value == previousParam.PdfFilePath)) { node.Attribute("Name").Value = param.PdfName; node.Attribute("File").Value = param.PdfFilePath; } }
public void RemoveFromPdfs(string xPath, XElement document, Element param) { var nodes = document.XPathSelectElements(xPath); foreach (var node in nodes.Where(node => node.HasElements == false && node.HasAttributes && node.Attribute("Name") != null && node.Attribute("Name").Value == param.PdfName && node.Attribute("File") != null && node.Attribute("File").Value == param.PdfFilePath)) { node.Remove(); } }
public void AddToPdfs(string xPath, XElement document, Element element) { var nodes = document.XPathSelectElements(xPath); foreach (var node in nodes) { var newNode = new XElement("Pdf"); newNode.SetAttributeValue("Name", element.PdfName); newNode.SetAttributeValue("File", element.PdfFilePath); node.Add(newNode); } }
public static XElement AddNodeToForm(Element param) { var node = new XElement("Form"); var formElement = new FormElement(param); var properties = formElement.GetType().GetProperties(); foreach (var property in properties) { var value = property.GetValue(formElement, null); if (value != null && !string.IsNullOrEmpty(value.ToString())) { AddAttributeInNode(property.Name, value.ToString(), node); } } return node; }
public void ReplaceInPackages(string xPath, XElement document, Element previousParam, Element param) { if (previousParam.FormName != param.FormName) { foreach (var save in previousParam.UsedPackages.Where(previous => param.UsedPackages.Contains(previous))) { ReplaceFormNameInPackage(xPath, document, save, previousParam.FormName, param.FormName); } } foreach (var del in previousParam.UsedPackages.Where(previous => param.UsedPackages.Contains(previous) == false)) { new Remove().RemoveFromPackage(xPath, document, del, previousParam.FormName); } foreach (var add in param.UsedPackages.Where(package => previousParam.UsedPackages.Contains(package) == false)) { new Add().AddToPackage(ConstPath.Packages, document, add, param.FormName); } }
public void AddToPackages(string xPath, XElement document, Element element) { var nodes = document.XPathSelectElements(xPath); foreach (var package in element.UsedPackages) { foreach (var node in nodes.Where(node => node.HasAttributes && node.HasAttributes && node.Attribute("Name") != null && node.Attribute("Name").Value == package)) { foreach (var child in node.Elements()) { if (child.Name != "OutputForms") { continue; } var newNode = new XElement("Form"); newNode.SetAttributeValue("Name", element.FormName); child.Add(newNode); } } } }
public XElement Remove(Element param) { if (param == null) { return null; } var doc = _document; try { _remove.RemoveFromPdfs(ConstPath.Pdfs, _document, param); Logger.Log(LogLevel.Trace, "Removed Information From Pdfs In Config File"); _remove.RemoveFromForms(ConstPath.Forms, _document, param); Logger.Log(LogLevel.Trace, "Removed Information From Forms In Config File"); _remove.RemoveFromPackages(ConstPath.FormsInPackages, _document, param); Logger.Log(LogLevel.Trace, "Removed Information From All Packages In Config File"); Logger.Log(LogLevel.Info, "Removed Information From Config File"); return _document; } catch (Exception ex) { Logger.Log(LogLevel.Error, ex.Message); return doc; } }