public static string MakeHeaderFile(string tempXmlFilePath, string tempFolderPath, string author, string orgId, ISerializationHelper serializationHelper) { string tempXmlFilePath2 = null; try { HeaderDocumentHelperQualified headerDocumentHelper = new HeaderDocumentHelperQualified(); headerDocumentHelper.SerializationHelper = serializationHelper; headerDocumentHelper.Configure(author, orgId, null, null, null, null); XmlDocument doc = new XmlDocument(); doc.Load(tempXmlFilePath); headerDocumentHelper.AddPayload("Update-Insert", doc.DocumentElement); //Serialize to new file string fileName = Guid.NewGuid().ToString(); tempXmlFilePath2 = Path.Combine(tempFolderPath, WQX_FILE_PREFIX + fileName + ".xml"); headerDocumentHelper.Serialize(tempXmlFilePath2); return(tempXmlFilePath2); } catch (Exception) { FileUtils.SafeDeleteFile(tempXmlFilePath2); throw; } finally { FileUtils.SafeDeleteFile(tempXmlFilePath); } }
public static string RemoveHeaderFile(string tempXmlFilePath, string tempFolderPath, ISerializationHelper serializationHelper) { string tempXmlFilePath2 = null; try { HeaderDocumentHelperQualified headerDocumentHelper = new HeaderDocumentHelperQualified(); headerDocumentHelper.SerializationHelper = serializationHelper; XmlDocument doc = new XmlDocument(); doc.Load(tempXmlFilePath); if (headerDocumentHelper.TryLoad(doc.DocumentElement)) { XmlElement element = headerDocumentHelper.GetPayload("Update-Insert"); //Serialize to new file string fileName = Guid.NewGuid().ToString(); tempXmlFilePath2 = Path.Combine(tempFolderPath, WQX_FILE_PREFIX + fileName + ".xml"); serializationHelper.Serialize(element, tempXmlFilePath2); return(tempXmlFilePath2); } else { throw new Exception("Unable to load document element."); } } catch (Exception) { FileUtils.SafeDeleteFile(tempXmlFilePath2); throw; } finally { FileUtils.SafeDeleteFile(tempXmlFilePath); } }