private void checkAndCalculateProtectedID(XmlDocument message, XmlNode invoice) { // field ProtectedID is mandatory, but if it is not suplied it is going to be calculated! XmlNodeList protectedIDs = (invoice as XmlElement).GetElementsByTagName("fu:ProtectedID"); if (protectedIDs.Count == 0) { ProtectiveMark pm = new ProtectiveMark(); string protectedIDValue = pm.Calculate(invoice as XmlElement, Settings.CryptoProvider); // ProtectedID is not the last element in XML Schema, so we must put it in the right spot // we are going from bottom up, searching for the right spot XmlNode protectedIDNode = XmlHelperFunctions.CreateElement(message, this.Settings.FursXmlNamespace, "ProtectedID", protectedIDValue); XmlNode currentNode = invoice.LastChild; while ((currentNode != null) && (this.isNodeAfterProtectedID(currentNode))) { currentNode = currentNode.PreviousSibling; } if (currentNode != null) { invoice.InsertAfter(protectedIDNode, currentNode); } } }
protected void checkHeader() { XmlNode header = XmlHelperFunctions.GetSubNode(this.Message.DocumentElement, "fu:Header"); if (header != null) return; XmlNode headerNode = XmlHelperFunctions.CreateElement(this.Message, this.Settings.FursXmlNamespace, "Header"); headerNode.AppendChild(XmlHelperFunctions.CreateElement(this.Message, this.Settings.FursXmlNamespace, "MessageID", Guid.NewGuid().ToString())); headerNode.AppendChild(XmlHelperFunctions.CreateElement(this.Message, this.Settings.FursXmlNamespace, "DateTime", DateTime.Now.ToString("s"))); this.Message.DocumentElement.InsertBefore(headerNode, this.Message.DocumentElement.FirstChild); }
private void checkAndCalculateProtectedID(XmlDocument message, XmlNode invoice) { // field ProtectedID is mandatory, but if it is not suplied it is going to be calculated! XmlNodeList protectedIDs = (invoice as XmlElement).GetElementsByTagName("fu:ProtectedID"); if (protectedIDs.Count == 0) { ProtectiveMark pm = new ProtectiveMark(); string protectedIDValue = pm.Calculate(invoice as XmlElement, Settings.CryptoProvider); invoice.AppendChild(XmlHelperFunctions.CreateElement(message, this.Settings.FursXmlNamespace, "ProtectedID", protectedIDValue)); } }